From: sashiko-bot@kernel.org
To: "Sechang Lim" <rhkrqnwk98@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 1/2] bpf, sockmap: disallow update and delete from tc, xdp, socket_filter and flow_dissector
Date: Tue, 30 Jun 2026 15:14:04 +0000 [thread overview]
Message-ID: <20260630151405.0A4F71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260630145410.3648099-2-rhkrqnwk98@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Incomplete fix for lock inversion deadlock: BPF_PROG_TYPE_SOCK_OPS can still trigger the exact same AB-BA deadlock on sockmap deletion.
--
commit a83dfc6fb81e4e2eb338be86e16b21c433de50ac
Author: Sechang Lim <rhkrqnwk98@gmail.com>
bpf, sockmap: disallow update and delete from tc, xdp, socket_filter and flow_dissector
The patch prevents a potential circular locking dependency by dropping several
BPF program types from may_update_sockmap(). This addresses a deadlock where
a sched_cls program taking stab->lock can invert the lock ordering against
sk_callback_lock held during stream parser receive.
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 25aea4271cd08..83ea3b33ff679 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -8488,12 +8488,7 @@ static bool may_update_sockmap(struct bpf_verifier_env *env, int func_id)
> if (func_id == BPF_FUNC_map_delete_elem)
> return true;
> break;
[Severity: High]
This isn't a bug introduced by this patch, but does allowing
BPF_PROG_TYPE_SOCK_OPS to call BPF_FUNC_map_delete_elem still leave the same
lock inversion deadlock open?
If CPU0 calls bpf_map_delete_elem() from process context, acquires stab->lock
via __sock_map_delete(), and blocks waiting for a write lock on
sk_callback_lock inside sock_map_del_link():
CPU0
__sock_map_delete()
takes stab->lock
sock_map_del_link()
blocks on sk_callback_lock (write)
And concurrently on CPU1, network receive processing invokes
sk_psock_strp_data_ready() and holds sk_callback_lock for read:
CPU1
sk_psock_strp_data_ready()
holds sk_callback_lock (read)
...
tcp_send_ack()
__tcp_transmit_skb()
tcp_established_options()
synchronously executes attached BPF_PROG_TYPE_SOCK_OPS program
Can the BPF program call bpf_map_delete_elem() on a SOCKMAP, attempting to
acquire stab->lock and deadlocking against CPU0?
> - case BPF_PROG_TYPE_SOCKET_FILTER:
> - case BPF_PROG_TYPE_SCHED_CLS:
> - case BPF_PROG_TYPE_SCHED_ACT:
> - case BPF_PROG_TYPE_XDP:
> case BPF_PROG_TYPE_SK_REUSEPORT:
> - case BPF_PROG_TYPE_FLOW_DISSECTOR:
> case BPF_PROG_TYPE_SK_LOOKUP:
> return true;
> default:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260630145410.3648099-1-rhkrqnwk98@gmail.com?part=1
next prev parent reply other threads:[~2026-06-30 15:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 14:54 [PATCH bpf-next v4 0/2] bpf, sockmap: disallow sockmap mutation from tc, xdp, socket_filter and flow_dissector Sechang Lim
2026-06-30 14:54 ` [PATCH bpf-next v4 1/2] bpf, sockmap: disallow update and delete " Sechang Lim
2026-06-30 15:14 ` sashiko-bot [this message]
2026-07-01 0:07 ` John Fastabend
2026-07-01 22:02 ` Emil Tsalapatis
2026-06-30 14:54 ` [PATCH bpf-next v4 2/2] selftests/bpf: drop tc/xdp/flow_dissector/socket_filter sockmap mutation tests Sechang Lim
2026-06-30 15:04 ` sashiko-bot
2026-07-01 0:10 ` John Fastabend
2026-07-01 22:04 ` Emil Tsalapatis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260630151405.0A4F71F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=rhkrqnwk98@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox