Re: [BUG] bpf, lsm: new first argument in 7.4 inode hooks silently breaks BPF LSMs
From: Paul Moore
Date: Tue Nov 17 2026 - 14:30:35 EST
On Tue, Nov 17, 2026 at 11:51 AM Andrii Nakryiko
<andrii.nakryiko@xxxxxxxxx> wrote:
> On Thu, Nov 12, 2026 at 6:41 PM Paul Moore <paul@xxxxxxxxxxxxxx> wrote:
> > On Thu, Nov 12, 2026 at 6:00 PM Andrii Nakryiko
> > <andrii.nakryiko@xxxxxxxxx> wrote:
> > > On Mon, Nov 9, 2026 at 7:08 AM roblabla <linux@xxxxxxxxx> wrote:
> > > >
> > > > Hi,
> > > >
> > > > Thanks for the replies!
> > > >
> > > > > LSMs that need to provide a stable API must provide an abstraction
> > > > > layer between the LSM hook callbacks and their stable API. The LSM
> > > > > framework is not responsible for the stability of individual LSM APIs.
> > > >
> > > > Understood, that lines up with my expectations. I think the biggest
> > > > thing here would not necessarily be stability guarantees, but rather to
> > > > make sure that the eBPFs fail to load when the compatibility is broken.
> > > > But that's probably a problem for the eBPF side, and not LSM, I assume.
> > > >
> > > > > So, in short, would it be possible to send a follow up to Daan's
> > > > > commit and move `struct mnt_idmap *idmap` to the end of LSM argument
> > > > > list?
> > > >
> > > > If this is possible, that'd be nice so that we avoid this breakage in
> > > > the short term, since the change isn't in a released kernel yet.
> > >
> > > can you please send a patch proposing that and we can continue
> > > discussion there? please cc me so I can follow along
> >
> > Considering the original patch was submitted, reviewed, and merged
> > with the BPF LSM being the only user (none of the existing in-tree
> > LSMs use the idmap parameter at present), I'm a little surprised this
> > wasn't brought up earlier.
>
> Yeah, unfortunately this was missed. Not sure it's surprising that it
> wasn't detected immediately, though, because unlikely someone tested
> an unreleased kernel in production. Luckily, this was still detected
> early enough before the final release and this gives us a chance to
> fix a mistake.
I've been surprised lately by apparently how little the BPF LSM
program interface is tested with real BPF programs before landing in
Linus' tree. I know the BPF folks have a pretty good set of CI tests,
bots, etc. but there do seem to be gaps relating to real world usage.
> > Beyond that, from a style perspective, I think I prefer the idmap at
> > the front of the parameter list in most (all?) of the hooks where it
> > was added. I'm not interested in moving it at this point in time.
>
> So on one hand we have a real user pain which is easily fixable
> without burdening kernel and LSM subsystem in particular, right?
Arguably changes that negatively impact code style and readability do
affect developers and maintainers.
> On
> the other hand there is a minor issue of argument ordering with
> mnt_idmap preferably as a first argument. I get the preference, but I
> think fixing an unnecessary (but easily fixable!) user pain should
> come first, don't you agree?
>
> Can you please reconsider?
The user pain exists because there is no abstraction layer between the
LSM hook callbacks and what the BPF LSM makes available to BPF
programs. That's a choice made by the BPF LSM devs, and while it's a
valid choice, it does have drawbacks like we are seeing here. Changes
to the callback arguments and/or the semantic behavior of the LSM
hooks are going to continue to happen regardless of what we do here.
It's better if the BPF LSM figures out how to deal with problems like
these rather than relying on a set of bandaids at the LSM framework
layer. If the decision is to push the pain up to the user to keep the
BPF program interface thin and flexible, that is their choice.
--
paul-moore.com