Re: [PATCH bpf] bpf: Disallow bpf_{g,s}etsockopt() in cgroup UNIX getname hooks

Kuniyuki Iwashima <[email protected]>
Newsgroups gmane.linux.network,gmane.linux.kernel.bpf
Message-ID <CAAVpQUCLKnN_aa4aCrufQukjuCcvZFUFy0hfPXOiGGLQw7bLAQ@mail.gmail.com>
On Wed, Aug 12, 2026 at 2:17 AM Junseo Lim <[email protected]> wrote:
>
> _bpf_setsockopt() and _bpf_getsockopt() call sock_owned_by_me() for
> full sockets, so these helpers expect the socket lock to be held.
>
> BPF_CGROUP_UNIX_GETPEERNAME and BPF_CGROUP_UNIX_GETSOCKNAME run BPF
> programs without acquiring the socket lock. A program attached to
> either hook can therefore trigger the sock_owned_by_me() warning by
> calling bpf_setsockopt() or bpf_getsockopt().
>
> Disallow bpf_setsockopt() and bpf_getsockopt() for CGROUP_UNIX_GETPEERNAME
> and CGROUP_UNIX_GETSOCKNAME.
>
> Fixes: 859051dd165e ("bpf: Implement cgroup sockaddr hooks for unix sockets")
> Reported-by: Sechang Lim <[email protected]>
> Signed-off-by: Junseo Lim <[email protected]>

Makes sense, probably no one calls getsockopt/setsockopt() at the hook.

Reviewed-by: Kuniyuki Iwashima <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.