From: sashiko-bot@kernel.org
To: "Suyuan Wang" <shyckless@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net] net: reuseport: honour SO_LOCK_FILTER in SO_DETACH_REUSEPORT_BPF
Date: Mon, 23 Nov 2026 08:17:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-228894@kernel.org> (raw)
In-Reply-To: <20261122-reuseport-lock-filter-v1-1-a3e5324c8d55@gmail.com>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] net: null pointer dereference in reuseport_attach_prog()
[1]
--
commit da8d8e1657f8b3054e3eb3aca8885a9515a8a782
Author: Suyuan Wang <stevewong@hust.edu.cn>
net: reuseport: honour SO_LOCK_FILTER in SO_DETACH_REUSEPORT_BPF
This commit checks SOCK_FILTER_LOCKED in reuseport_detach_prog() and returns
-EPERM so an unprivileged holder of a filter-locked socket cannot remove the
reuseport BPF program via SO_DETACH_REUSEPORT_BPF.
> diff --git a/net/core/sock_reuseport.c b/net/core/sock_reuseport.c
> index b9e5648fa4c51..cdff61161a70a 100644
> --- a/net/core/sock_reuseport.c
> +++ b/net/core/sock_reuseport.c
> @@ -727,6 +727,9 @@ int reuseport_detach_prog(struct sock *sk)
> struct sock_reuseport *reuse;
> struct bpf_prog *old_prog;
>
> + if (sock_flag(sk, SOCK_FILTER_LOCKED))
> + return -EPERM;
> +
> old_prog = NULL;
> spin_lock_bh(&reuseport_lock);
> reuse = rcu_dereference_protected(sk->sk_reuseport_cb,
[Severity: Critical]
This problem wasn't introduced by this patch, but can reuseport_attach_prog()
right above hit a NULL pointer dereference on reuse->prog [1]?
Unlike reuseport_detach_prog(), which re-checks reuse after acquiring
reuseport_lock, reuseport_attach_prog() checks sk->sk_reuseport_cb outside
the lock on a hashed socket and then dereferences reuse->prog without
re-checking reuse:
net/core/sock_reuseport.c:reuseport_attach_prog() {
...
} else if (!rcu_access_pointer(sk->sk_reuseport_cb)) {
/* The socket wasn't bound with SO_REUSEPORT */
return -EINVAL;
}
spin_lock_bh(&reuseport_lock);
reuse = rcu_dereference_protected(sk->sk_reuseport_cb,
lockdep_is_held(&reuseport_lock));
old_prog = rcu_dereference_protected(reuse->prog,
lockdep_is_held(&reuseport_lock));
...
}
If the socket is closed but still hashed and a concurrent reuseport_grow()
evicts it from the reuseport group before reuseport_lock is taken,
sk->sk_reuseport_cb is cleared to NULL:
CPU0 CPU1
reuseport_attach_prog()
rcu_access_pointer(sk->sk_reuseport_cb)
reuseport_grow()
rcu_assign_pointer(
sk->sk_reuseport_cb, NULL)
spin_lock_bh(&reuseport_lock)
reuse = rcu_dereference_protected(...)
reuse->prog <-- NULL pointer dereference
[1] https://sashiko.dev/#/bug/linux-08c15fbe-8ad8-46d6-a3d8-bd898520f1ab
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261122-reuseport-lock-filter-v1-1-a3e5324c8d55@gmail.com?part=1
next prev parent reply other threads:[~2026-11-23 8:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 8:17 [PATCH net] net: reuseport: honour SO_LOCK_FILTER in SO_DETACH_REUSEPORT_BPF Suyuan Wang
2026-11-22 8:17 ` Suyuan Wang via B4 Relay
2026-11-23 8:17 ` sashiko-bot [this message]
2026-11-23 8:47 ` netdev-bot+sashiko
2026-11-23 9:01 ` Wong Steve
2026-11-23 9:04 ` Wong Steve
2026-11-28 11:16 ` Kuniyuki Iwashima
2026-11-30 16:10 ` patchwork-bot+netdevbpf
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=sashiko-outbox-228894@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shyckless@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.