Skip to content

Commit

Permalink
bpf, sockmap: Fix map type error in sock_map_del_link
Browse files Browse the repository at this point in the history
sock_map_del_link() operates on both SOCKMAP and SOCKHASH, although
both types have member named "progs", the offset of "progs" member in
these two types is different, so "progs" should be accessed with the
real map type.

Fixes: 604326b ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
Reviewed-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/r/20230804073740.194770-2-xukuohai@huaweicloud.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
  • Loading branch information
Xu Kuohai authored and Martin KaFai Lau committed Aug 10, 2023
1 parent 85c2c79 commit 7e96ec0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions net/core/sock_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ static void sock_map_del_link(struct sock *sk,
list_for_each_entry_safe(link, tmp, &psock->link, list) {
if (link->link_raw == link_raw) {
struct bpf_map *map = link->map;
struct bpf_stab *stab = container_of(map, struct bpf_stab,
map);
if (psock->saved_data_ready && stab->progs.stream_parser)
struct sk_psock_progs *progs = sock_map_progs(map);

if (psock->saved_data_ready && progs->stream_parser)
strp_stop = true;
if (psock->saved_data_ready && stab->progs.stream_verdict)
if (psock->saved_data_ready && progs->stream_verdict)
verdict_stop = true;
if (psock->saved_data_ready && stab->progs.skb_verdict)
if (psock->saved_data_ready && progs->skb_verdict)
verdict_stop = true;
list_del(&link->list);
sk_psock_free_link(link);
Expand Down

0 comments on commit 7e96ec0

Please sign in to comment.