Re: [RFC PATCH 06/20] bpf: lsm: Add Landlock kfuncs
Paul Moore <[email protected]>
| Newsgroups | org.kernel.vger.linux-security-module,org.kernel.vger.bpf,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAHC9VhRp6pvQXskNU0FXBkDw=MAF8Ht1Mk7BbUeU8JnEkSk52g@mail.gmail.com> |
On Wed, Jul 1, 2026 at 2:29 PM Justin Suess <[email protected]> wrote: > On Wed, Jul 01, 2026 at 09:28:22AM -0400, Paul Moore wrote: > > On Wed, Jul 1, 2026 at 8:52 AM Justin Suess <[email protected]> wrote: > > > On Wed, Jul 01, 2026 at 08:12:34AM -0400, Paul Moore wrote: > > > > On Wed, Jul 1, 2026 at 6:59 AM Mickaël Salaün <[email protected]> wrote: > > > > > On Tue, Apr 07, 2026 at 04:01:28PM -0400, Justin Suess wrote: > > > > > > Create 2 kfuncs exposing control over Landlock functionality to BPF > > > > > > callers. Export an opaque struct bpf_landlock_ruleset preventing callers > > > > > > from accessing unstable internal Landlock fields. > > > > > > > > Generally speaking we don't want to provide APIs, either in-kernel or > > > > at the userspace/kernel boundary, that are specific to a single LSM, > > > > see the LSM syscalls or the security_current_getlsmprop_subj() > > > > function as examples. > > > > > > I would raise bpf_ima_file_hash, bpf_ima_inode_hash, as examples of > > > clear precedence for this. (BPF calling into specific LSM) > > > > The BPF IMA helpers were merged back in the v5.18 timeframe when IMA > > was still standalone, it wasn't until v6.9 that IMA and EVM became > > proper LSMs. > > > > > Kfuncs are explicitly marked as not being an ABI, and are more > > > flexible for later changes / deprecation etc. [1] > > > > The issue isn't so much the kfunc itself, it is what the kfunc > > *calls*. From what I saw in the proposed patch, the kfunc calls > > directly into Landlock instead of passing through the LSM framework, > > e.g. a function wrapper in security/security.c. > > > > > LSM framework API can mean a lot of things. I assume you are meaning > > > like a pseudo-filesystem mounted interface that controls LSM? > > > Correct me if I'm wrong. > > > > My apologies, I should have been more clear. When I speak about the > > "LSM framework", I'm talking about the abstraction layer that provides > > the interface that the kernel and userspace uses to talk to individual > > LSMs. The LSM framework is analogous to the VFS layer/framework in > > that it provides a single API for a variety of underlying subsystems. > > While not 100% correct, you can think of it the LSM framework as being > > the functions/hooks defined in security/security.c. > > > > Does that help? > > That does. security/security.c seems like a good place to enumerate the enabled > LSMs and to check to make sure that Landlock is actually enabled both in the kernel > build and that the Landlock LSM is up and running. Yep. > The above patch only checked if Landlock was compiled, when it should > actually be checking if Landlock is actively enabled. > > So I will probably make a shim for it there that gates calls to > Landlock. Please keep in mind that the LSM framework API needs to be reasonably generic. We've got some general guidance on adding new LSM hooks at the link below: https://github.com/LinuxSecurityModule/kernel/blob/main/README.md#new-lsm-hooks -- paul-moore.com