From: "Kumar Kartikeya Dwivedi" <memxor@gmail.com>
To: "David Windsor" <dwindsor@gmail.com>, <bpf@vger.kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>
Cc: "Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"John Fastabend" <john.fastabend@gmail.com>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>
Subject: Re: [PATCH bpf-next] bpf: add BPF_F_SEALED flag to seal BPF links at creation
Date: Mon, 03 Aug 2026 05:23:58 +0200 [thread overview]
Message-ID: <DKEZJO5FZPQA.2NBTLV562CY3U@gmail.com> (raw)
In-Reply-To: <CAEXv5_iXbExVvOSyOu_BsNeAjhqBOf3880vfUDbfLNmKPgLVXA@mail.gmail.com>
On Mon Aug 3, 2026 at 4:20 AM CEST, David Windsor wrote:
> On Sun, Aug 2, 2026 at 10:16 PM David Windsor <dwindsor@gmail.com> wrote:
>>
>> Introduce a new BPF_F_SEALED flag for BPF_LINK_CREATE that creates the
>> link permanently sealed. A sealed link can never have its program
>> replaced via BPF_LINK_UPDATE, can never be detached via BPF_LINK_DETACH,
>> and holds an extra self-reference that is never released, so the link and
>> its program attachment persist until the machine reboots, even after user
>> space closes every fd referring to it. There is no way to unseal a link.
>>
>> The sealed state is tracked by a new bool field on struct bpf_link.
>>
>> Signed-off-by: David Windsor <dwindsor@gmail.com>
>> ---
>> include/linux/bpf.h | 2 ++
>> include/uapi/linux/bpf.h | 1 +
>> kernel/bpf/syscall.c | 41 +++++++++++++++++++++++++++++++---
>> tools/include/uapi/linux/bpf.h | 1 +
>> 4 files changed, 42 insertions(+), 3 deletions(-)
>>
>
> There is deliberately no selftest for this, as running any such
> selftest would necessarily create a sealed link, which cannot be
> cleaned up.
Let's wait for more comments, esp. on whether this is useful or the right path
forward, but I'd still prefer adding selftests to verify various aspects of the
behavior if we proceed.
I think the point about a user being able to create many sealed links is
definitely valid too, so it might make sense to keep this gated behind more
privileged capabilities (if not already).
For tests, we might have to force decrement the link refcount (after verifying
it stays elevated after close(2)) from the test. It might involve some creative
use of a kfunc in bpf_testmod that can do the cleanup for us to avoid wedging
the system on repeated invocations of the test. It wouldn't be available on a
real system. It depends on whether we deem it important enough that leaking the
link on VMs running tests is important enough. You'd probably have to run it
thousands of time to exhaust memory unless the VM is provisioned with a tiny
amount of memory.
Anyway, let's get into all that after seeing how others feel about the concept.
next prev parent reply other threads:[~2026-08-03 3:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 2:16 [PATCH bpf-next] bpf: add BPF_F_SEALED flag to seal BPF links at creation David Windsor
2026-08-03 2:20 ` David Windsor
2026-08-03 3:23 ` Kumar Kartikeya Dwivedi [this message]
2026-08-03 2:28 ` sashiko-bot
2026-08-03 2:44 ` Leon Hwang
2026-08-03 3:17 ` Kumar Kartikeya Dwivedi
2026-08-03 3:26 ` David Windsor
2026-08-07 22:30 ` Andrii Nakryiko
2026-08-11 21:23 ` David Windsor
2026-08-03 3:18 ` Kumar Kartikeya Dwivedi
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=DKEZJO5FZPQA.2NBTLV562CY3U@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dwindsor@gmail.com \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=martin.lau@linux.dev \
--cc=song@kernel.org \
--cc=yonghong.song@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 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.