From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Paul Moore" <paul@paul-moore.com>,
"Justin Suess" <utilityemal77@gmail.com>
Cc: <ast@kernel.org>, <daniel@iogearbox.net>, <andrii@kernel.org>,
<kpsingh@kernel.org>, <matt@bobrowski.net>, <mic@digikod.net>,
<viro@zeniv.linux.org.uk>, <brauner@kernel.org>,
<kees@kernel.org>, <casey@schaufler-ca.com>, <gnoack@google.com>,
<jack@suse.cz>, <song@kernel.org>, <yonghong.song@linux.dev>,
<martin.lau@linux.dev>, <eddyz87@gmail.com>, <memxor@gmail.com>,
<jolsa@kernel.org>, <m@maowtm.org>, <bpf@vger.kernel.org>,
<linux-security-module@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next v3 04/15] lsm: Add the bpf_lsm_policy_release kfunc and policy object destructor
Date: Fri, 11 Sep 2026 20:37:22 -0700 [thread overview]
Message-ID: <DLD0VQ3D8CYC.3V5ZT8HDMY4IH@gmail.com> (raw)
In-Reply-To: <CAHC9VhTM7emi9vxs+5Za8Hrc_e9dg7fZx+Z6BGUc4VQ1qhEAUA@mail.gmail.com>
On Wed Sep 9, 2026 at 4:08 PM PDT, Paul Moore wrote:
> On Wed, Sep 9, 2026 at 6:21 PM Justin Suess <utilityemal77@gmail.com> wrote:
>> On Wed, Sep 09, 2026 at 05:34:31PM -0400, Paul Moore wrote:
>> > On Wed, Sep 9, 2026 at 3:37 PM Justin Suess <utilityemal77@gmail.com> wrote:
>> > >
>> > > Add security/bpf_lsm_kfuncs.c, the home of the kfuncs exposing LSM
>> > > policy objects to BPF programs, with the first of them:
>> > >
>> > > bpf_lsm_policy_release(object) KF_RELEASE
>> > >
>> > > The kfuncs are the LSM framework's own BPF interface: there is no
>> > > per-LSM kfunc and no intermediate security_*() layer. Each kfunc
>> > > walks the matching hook's implementation list and calls the one
>> > > registered by the LSM whose lsmid the policy object carries. Calling
>> > > a kfunc for an LSM that is not active or has no policy object support
>> > > fails at runtime rather than hiding the kfunc at verification time,
>> > > so BPF program loading is independent of the boot-time LSM
>> > > configuration.
>> > >
>> > > A policy object reference is meant to be handed over through a map
>> > > kptr field, so also register a destructor for struct
>> > > lsm_policy_object: map-held references are dropped on map teardown,
>> > > possibly from a context that cannot sleep, which the
>> > > policy_object_put() hook contract accounts for. For the same reason
>> > > the kfunc is not KF_SLEEPABLE, and the filter adds no per-kfunc rule:
>> > > releasing a reference must be allowed wherever one can be held. The
>> > > filter itself is needed because BPF_PROG_TYPE_LSM and
>> > > BPF_PROG_TYPE_SYSCALL, the two registered program types, share their
>> > > kfunc lookup buckets with other program types.
>> > >
>> > > Cc: Paul Moore <paul@paul-moore.com>
>> > > Cc: KP Singh <kpsingh@kernel.org>
>> > > Signed-off-by: Justin Suess <utilityemal77@gmail.com>
>> > > ---
>> > >
>> > > Notes:
>> > > v2->v3:
>> > > - No change.
>> > >
>> > > MAINTAINERS | 1 +
>> > > security/Makefile | 2 +-
>> > > security/bpf_lsm_kfuncs.c | 98 +++++++++++++++++++++++++++++++++++++++
>> > > 3 files changed, 100 insertions(+), 1 deletion(-)
>> > > create mode 100644 security/bpf_lsm_kfuncs.c
>> >
>> > While not a new concern, it has been a few months so I want to mention
>> > it again to see where things stand with the BPF crowd: are the BPF
>> > folks still opposed to BPF kfuncs in security/bpf_lsm_kfuncs.c,
>> > similar to fs/bpf_fs_kfuncs.c?
>> >
>> > If the answer remains yes, the BPF devs are not able to tolerate
>> > kfuncs under security/, then I'm afraid this patchset is stuck.
>> > However, if the BPF devs are willing to ACK kfuncs in
>> > security/bpf_lsm_kfuncs.c, I'll add this patchset to the review queue
>> > for the LSM tree.
>> >
>> To avocate for the current placement:
>>
>> Placing these kfuncs outside where it is in security/ would
>> be very awkward, the kfuncs use lsm internal APIs
>> (lsm_for_each_hook, active static keys, lsm dispatch table) that
>> have no buisness outside the LSM framework.
>>
>> And logically, the kfuncs operate entirely on in-tree lsm objects.
>>
>> > > diff --git a/MAINTAINERS b/MAINTAINERS
>> > > index 6215fcb07770..ba816d7ee127 100644
>> > > --- a/MAINTAINERS
>> > > +++ b/MAINTAINERS
>> > > @@ -5081,6 +5081,7 @@ F: kernel/bpf/bpf_lsm.c
>> > > F: kernel/bpf/bpf_lsm_proto.c
>> > > F: kernel/trace/bpf_trace.c
>> > > F: security/bpf/
>> > > +F: security/bpf_lsm_kfuncs.c
>> >
>> > We would need the maintenence of security/bpf_lsm_kfuncs.c to fall to
>> > the LSM framework, just as the maintenence of bpf_fs_funcs.c falls to
>> > the VFS.
>>
>> Agreed.
>>
>> I intend that any security/ kfuncs go through both LSM and BPF
>> review at a minimum. As a bug in any of these kfuncs or their permitted
>> calling context / signatures could cause regressions in either subsystem.
>
> While some other subsystems are lax on this, it's general practice in
> the LSM space to *really* try to get ACK's from other affected
> subsystems before merging. Sometimes we move forward anyway, e.g.
> patches being ignored for almost a year, but those are exceptions
> rather than the rule.
>
> I only bring this up because the MAINTAINERS entry was pointed at the
> BPF devs, not the LSM devs. I would expect that patches going into
> security/bpf_lsm_kfuncs.c would need to be ACK'd both the LSM
> framework and BPF LSM maintainers.
There is will be no kfuncs under security/.
Period.
next prev parent reply other threads:[~2026-09-12 3:37 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 19:37 [PATCH bpf-next v3 00/15] BPF interface for applying Landlock rulesets Justin Suess
2026-09-09 19:37 ` [PATCH bpf-next v3 01/15] lsm: Add the LSM policy object lifetime hooks Justin Suess
2026-09-09 19:37 ` [PATCH bpf-next v3 02/15] lsm: Add the bprm_apply_policy_object LSM hook Justin Suess
2026-09-09 19:37 ` [PATCH bpf-next v3 03/15] lsm: Move the lsm_for_each_hook() macro to security/lsm.h Justin Suess
2026-09-09 19:37 ` [PATCH bpf-next v3 04/15] lsm: Add the bpf_lsm_policy_release kfunc and policy object destructor Justin Suess
2026-09-09 20:29 ` bot+bpf-ci
2026-09-09 21:34 ` Paul Moore
2026-09-09 22:20 ` Justin Suess
2026-09-09 23:08 ` Paul Moore
2026-09-12 3:37 ` Alexei Starovoitov [this message]
2026-09-12 5:26 ` Justin Suess
2026-09-12 19:33 ` Alexei Starovoitov
2026-09-09 19:37 ` [PATCH bpf-next v3 05/15] lsm: Add the bpf_lsm_policy_from_fd kfunc Justin Suess
2026-09-09 20:46 ` bot+bpf-ci
2026-09-09 19:37 ` [PATCH bpf-next v3 06/15] lsm: Add the bpf_lsm_policy_acquire kfunc Justin Suess
2026-09-09 20:30 ` bot+bpf-ci
2026-09-09 19:37 ` [PATCH bpf-next v3 07/15] lsm: Add the bpf_lsm_policy_apply_bprm kfunc Justin Suess
2026-09-12 3:38 ` Alexei Starovoitov
2026-09-12 5:39 ` Justin Suess
2026-09-09 19:37 ` [PATCH bpf-next v3 08/15] lsm: Document the LSM policy object interface Justin Suess
2026-09-09 19:37 ` [PATCH bpf-next v3 09/15] selftests/bpf: Add tests for the LSM policy object kfuncs Justin Suess
2026-09-09 20:30 ` bot+bpf-ci
2026-09-09 19:37 ` [PATCH bpf-next v3 10/15] landlock: Expose the ruleset fd lookup to the rest of Landlock Justin Suess
2026-09-09 19:37 ` [PATCH bpf-next v3 11/15] landlock: Factor the credential restriction out of landlock_restrict_self() Justin Suess
2026-09-09 20:29 ` bot+bpf-ci
2026-09-09 19:37 ` [PATCH bpf-next v3 12/15] landlock: Free rulesets after an RCU grace period Justin Suess
2026-09-09 20:46 ` bot+bpf-ci
2026-09-09 19:37 ` [PATCH bpf-next v3 13/15] landlock: Implement the LSM policy object hooks Justin Suess
2026-09-09 20:46 ` bot+bpf-ci
2026-09-09 19:37 ` [PATCH bpf-next v3 14/15] selftests/bpf: Test the LSM policy object kfuncs with Landlock Justin Suess
2026-09-09 20:46 ` bot+bpf-ci
2026-09-09 19:37 ` [PATCH bpf-next v3 15/15] landlock: Document the BPF policy interface Justin Suess
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=DLD0VQ3D8CYC.3V5ZT8HDMY4IH@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=brauner@kernel.org \
--cc=casey@schaufler-ca.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=gnoack@google.com \
--cc=jack@suse.cz \
--cc=jolsa@kernel.org \
--cc=kees@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=m@maowtm.org \
--cc=martin.lau@linux.dev \
--cc=matt@bobrowski.net \
--cc=memxor@gmail.com \
--cc=mic@digikod.net \
--cc=paul@paul-moore.com \
--cc=song@kernel.org \
--cc=utilityemal77@gmail.com \
--cc=viro@zeniv.linux.org.uk \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®