Re: [PATCH bpf-next] bpf: add BPF_F_SEALED flag to seal BPF links at creation

"Kumar Kartikeya Dwivedi" <[email protected]> Mon, 03 Aug 2026 05:17:09 +0200
Newsgroups org.kernel.vger.bpf
Message-ID <[email protected]>
On Mon Aug 3, 2026 at 4:44 AM CEST, Leon Hwang wrote:
> On 3/8/26 10:16, David Windsor 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.
>
>
> Why do you want BPF_F_SEALED? What's your case for it?
>
> I think 'sealed' should be set before allocating the FD to avoid the
> race issues reported by Sashiko.
>

Agreed, then we would not need READ_ONCE() on the sealed bit either since the
it stays immutable through the lifetime of the link.

> Thanks,
> Leon
>
>> [...]