Re: [BUG] bpf, lsm: new first argument in 7.4 inode hooks silently breaks BPF LSMs
From: Andrii Nakryiko
Date: Tue Nov 17 2026 - 16:44:53 EST
On Tue, Nov 17, 2026 at 11:30 AM Paul Moore <paul@xxxxxxxxxxxxxx> wrote:
>
> 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.
I think it's a hard problem, yes. BPF selftests test latest kernel, so
this issue we are discussing here just won't come up there. Then,
e.g., for Meta, we do have internal tests that validate existing BPF
LSM programs across different kernel versions, but unless our internal
BPF LSM programs utilize specific LSMs, this won't be caught either.
>
> > > 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.
I agree, but argument order is not that big of an issue
>
> > 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.
Yes, just like it will for tracepoints, kprobes, etc. Sometimes it's
inevitable and BPF ecosystem does have tools to deal with. It's still
a friction and pain and burden to do this, so if it's avoidable at low
cost to the kernel, we should try to minimize unnecessary pain.
That's really what I'm asking about here. We did do that with
scheduling tracepoints, I think it's reasonable to do this here as
well.
> 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.
Yes, thin (and thus performant) and flexible is the design choice and
I think it's fine. That's not really the crux of the problem here. As
I mentioned, users have tools to work around changing unstable kernel
interfaces that BPF programs rely on.
But in this case we are discussing reordering a few arguments *before
they even get into final release* just to avoid unnecessary pain and
workaround. *Unnecessary* is the key here.
I really don't think that's too much to ask in this situation.
>
> --
> paul-moore.com