The patch below does not apply to the 5.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <stable@xxxxxxxxxxxxxxx>. To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.4.y git checkout FETCH_HEAD git cherry-pick -x 7e96ec0e6605b69bb21bbf6c0ff9051e656ec2b1 # <resolve conflicts, build, test, etc.> git commit -s git send-email --to '<stable@xxxxxxxxxxxxxxx>' --in-reply-to '2023081238-calibrate-savanna-77b0@gregkh' --subject-prefix 'PATCH 5.4.y' HEAD^.. Possible dependencies: 7e96ec0e6605 ("bpf, sockmap: Fix map type error in sock_map_del_link") a7ba4558e69a ("sock_map: Introduce BPF_SK_SKB_VERDICT") b017055255d6 ("sock_map: Kill sock_map_link_no_progs()") 2004fdbd8a2b ("sock_map: Simplify sock_map_link() a bit") 4675e234b9e1 ("sock_map: Make sock_map_prog_update() static") ae8b8332fbb5 ("sock_map: Rename skb_parser and skb_verdict") 5a685cd94b21 ("skmsg: Get rid of struct sk_psock_parser") 887596095ec2 ("bpf: Clean up sockmap related Kconfigs") 83c11c17553c ("net, sockmap: Don't call bpf_prog_put() on NULL pointer") ef5659280eb1 ("bpf, sockmap: Allow skipping sk_skb parser program") 743df8b7749f ("bpf, sockmap: Check skb_verdict and skb_parser programs explicitly") 0b17ad25d8d1 ("bpf, sockmap: Add memory accounting so skbs on ingress lists are visible") 10d58d006356 ("bpf, sockmap: Remove skb_orphan and let normal skb_kfree do cleanup") 1e6c62a88215 ("bpf: Introduce sleepable BPF programs") 8ea636848aca ("bpf: Implement bpf_local_storage for inodes") 0813a841566f ("bpf: tcp: Allow bpf prog to write and parse TCP header option") c9985d09e189 ("bpf: sock_ops: Change some members of sock_ops_kern from u32 to u8") 331fca4315ef ("bpf: tcp: Add bpf_skops_hdr_opt_len() and bpf_skops_write_hdr_opt()") 00d211a4ea6f ("bpf: tcp: Add bpf_skops_parse_hdr()") 72be0fe6ba76 ("bpf: tcp: Add bpf_skops_established()") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 7e96ec0e6605b69bb21bbf6c0ff9051e656ec2b1 Mon Sep 17 00:00:00 2001 From: Xu Kuohai <xukuohai@xxxxxxxxxx> Date: Fri, 4 Aug 2023 03:37:37 -0400 Subject: [PATCH] bpf, sockmap: Fix map type error in sock_map_del_link 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: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface") Signed-off-by: Xu Kuohai <xukuohai@xxxxxxxxxx> Reviewed-by: John Fastabend <john.fastabend@xxxxxxxxx> Link: https://lore.kernel.org/r/20230804073740.194770-2-xukuohai@xxxxxxxxxxxxxxx Signed-off-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx> diff --git a/net/core/sock_map.c b/net/core/sock_map.c index 08ab108206bf..8f07fea39d9e 100644 --- a/net/core/sock_map.c +++ b/net/core/sock_map.c @@ -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);