From: manjunath.b.patil@oracle.com
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: Eric Dumazet <edumazet@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Willem de Bruijn <willemb@google.com>,
"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH net] tcp: restrict SO_ATTACH_BPF to privileged users
Date: Wed, 28 Oct 2026 16:43:54 -0700 [thread overview]
Message-ID: <c7fce0ea-888e-4e97-b4ed-ea63f92be5a5@oracle.com> (raw)
In-Reply-To: <DMGTEGTLTEUX.HECMYVCWNFQA@gmail.com>
Hi,
On 10/28/26 3:12 PM, Alexei Starovoitov wrote:
> On Wed, Oct 28, 2026 at 02: 58 PM Manjunath Patil <manjunath. b. patil@
> oracle. com> wrote: > Commit 5d39580f68e6 ("tcp: restrict
> SO_ATTACH_FILTER to priv users") > requires CAP_NET_ADMIN to attach a
> classic BPF filter to a TCP socket.
>
>
> On Wed, Oct 28, 2026 at 02:58 PM Manjunath Patil <manjunath.b.patil@oracle.com> wrote:
>> Commit 5d39580f68e6 ("tcp: restrict SO_ATTACH_FILTER to priv users")
>> requires CAP_NET_ADMIN to attach a classic BPF filter to a TCP socket.
>> However, a caller can still attach an eBPF socket filter through
>> SO_ATTACH_BPF without this capability. Both options install a filter
>> that runs on incoming TCP packets.
>
> Nack.
> SO_ATTACH_FILTER takes insns that the caller wrote.
> SO_ATTACH_BPF takes a prog FD, and BPF_PROG_LOAD is the gate for it.
Thanks for the explanation. I overlooked this distinction and treated
the different attachment checks as a missing permission check.
> unprivileged_bpf_disabled is 2 by default, so the load needs CAP_BPF.
> An admin who sets it to 0 allows every user to load socket filters.
>
>> Disabling unprivileged BPF loading does not close this gap: a caller
>> that already holds a socket-filter program file descriptor can still
>> use SO_ATTACH_BPF.
>
> That's not a gap. The FD is the permission.
> A process with CAP_BPF loads the prog and passes the FD to a process
> without caps.
My test loaded the socket-filter program as root, then retained its FD
in a worker that dropped its capabilities. That exercises supported
delegation; it does not establish a security bypass.
See the comment in bpf_prog_load() and
> commit c8644cd0efe7 ("bpf: refine kernel.unprivileged_bpf_disabled behaviour").
> This patch breaks it. It also breaks a process that has CAP_BPF and
> doesn't have CAP_NET_ADMIN.
I agree. I am withdrawing this patch.
-Thanks,
Manjunath>
> pw-bot: cr
>
next prev parent reply other threads:[~2026-10-28 23:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 21:58 [PATCH net] tcp: restrict SO_ATTACH_BPF to privileged users Manjunath Patil
2026-10-28 22:12 ` Alexei Starovoitov
2026-10-28 23:43 ` manjunath.b.patil [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-10-28 22:01 netdev-bot+sinfo
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=c7fce0ea-888e-4e97-b4ed-ea63f92be5a5@oracle.com \
--to=manjunath.b.patil@oracle.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
--cc=willemb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox