Re: [PATCH net] net: reuseport: honour SO_LOCK_FILTER in SO_DETACH_REUSEPORT_BPF
From: Kuniyuki Iwashima
Date: Sat Nov 28 2026 - 06:16:43 EST
On Sun, 22 Nov 2026 08:17:26 +0000, Suyuan Wang wrote:
> From: Suyuan Wang <stevewong@xxxxxxxxxxx>
>
> SO_LOCK_FILTER lets a process lock the filters on a socket before
> handing it to a less privileged one. Once it is set, the existing attach
> and detach paths reject changes to the socket's BPF filters with -EPERM,
> but SO_DETACH_REUSEPORT_BPF does not check SOCK_FILTER_LOCKED. So an
> unprivileged process that receives a locked socket can still remove the
> reuseport program, which then changes how packets and connections are
> spread over the whole reuseport group.
>
> Return -EPERM from reuseport_detach_prog() when the filter is locked,
> like sk_detach_filter() does.
>
> Found with a static analysis tool and checked by hand.
>
> Fixes: 99f3a064bc2e ("bpf: net: Add SO_DETACH_REUSEPORT_BPF")
> Cc: stable@xxxxxxxxxxxxxxx
> Co-developed-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
> Signed-off-by: Kaixuan Li <kaixuan.li@xxxxxxxxxx>
> Signed-off-by: Suyuan Wang <stevewong@xxxxxxxxxxx>
Reviewed-by: Kuniyuki Iwashima <kuniyu@xxxxxxxxxx>