From: roblabla <linux@roblab.la>
To: "Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Andrii Nakryiko" <andrii.nakryiko@gmail.com>,
"Paul Moore" <paul@paul-moore.com>,
"Daan De Meyer" <daan@amutable.com>
Cc: bpf@vger.kernel.org, linux-security-module@vger.kernel.org,
"Paul Mabileau" <paul.mabileau@harfanglab.fr>,
linux-kernel@vger.kernel.org,
"Andrii Nakryiko" <andrii@kernel.org>
Subject: Re: [BUG] bpf, lsm: new first argument in 7.4 inode hooks silently breaks BPF LSMs
Date: Tue, 24 Nov 2026 12:42:17 +0100 [thread overview]
Message-ID: <05507d51-651e-4ff8-aa6e-4bbb1e788f64@app.fastmail.com> (raw)
In-Reply-To: <9695ec3d-7b81-488d-989f-0bd411d673f2@linux.dev>
For what it's worth, I don't particularly care about the argument order in this particular case. Like yes, it'd be nice to avoid the split, but I've already made the necessary changes to deal with it, so I just need to tell people stuck on an old version of my software to be careful when updating the kernel past 7.4. I can live with that.
I'm much more interested in a way to avoid a repeat of this when an argument is inevitably added/removed/changed in the LSM hooks - ergo a way to fail to load on prototype mismatch in eBPF LSM. To that end, I implemented Ihor's suggestion (using `bpf_core_type_matches` to verify the signature matches `security_list_options`) in my eBPFs, which resolves the immediate issue. While doing so, I found two problems in libbpf's implementation of `bpf_core_type_matches()`:
1. https://github.com/libbpf/libbpf/issues/995 : GCC and clang spell some integer types differently - for instance an `unsigned short` will be encoded as `short unsigned int` by gcc, while clang keeps the original name. `libbpf` claims to only compare the length/signedness of integer, but the code also checks the type name. In practice, this means an eBPF built with clang cannot use `bpf_core_type_matches` for this use-case.
2. https://github.com/libbpf/libbpf/issues/996 : `char` has an annoying story: In old versions of the kernel, its signedness followed platform ABI (ergo signed on x86_64), but because of a bug in pahole (fixed in 1.24), it was categorized as "unsigned" in the BTF. Then, in recent versions of the kernel, the `-funsigned-char` flag was added. This makes matching a prototype containing a char with `bpf_core_type_matches` essentially a coin toss whether it will work or not.
Now, in my case, I use a fork of aya to load my eBPFs, so I can afford to workaround both of these issues - see this PR adding the necessary machinery https://github.com/aya-rs/aya/pull/1889 - it has a commit to fix each of these. For the former I simply removed the typename check when looking at an integer type, and for the later, I relaxed the signedness check when looking at a `char`.
With these two fixes in place, the check does work properly across all the kernel versions and distros in my test matrix, and in fact it caught a (thankfully benign) mismatch in RedHat kernels caused by a backported commit that slipped through my monitoring.
So thanks a lot for the suggestion Ihor! I also looked at your branch with `BPF_PROG_ARGS` - that'd be great to have as well, making other kind of probes like tracepoints more robust against arguments being shuffled would be a welcome addition as well. While I'm a lot less worried about them (they don't run the risk of rendering a machine inoperable if they produce garbage output), being more robust is always nice. If this ends up in libbpf, I'll switch to it in a heartbeat (well, as soon as I add the equivalent code in aya anyways ^^').
prev parent reply other threads:[~2026-11-24 11:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <d85ece6e-27f9-4d9f-83af-4101bc76fef6@app.fastmail.com>
2026-11-06 13:38 ` roblabla
2026-11-06 15:41 ` Paul Moore
2026-11-06 19:33 ` Andrii Nakryiko
2026-11-09 15:07 ` roblabla
2026-11-12 23:00 ` Andrii Nakryiko
2026-11-13 2:41 ` Paul Moore
2026-11-17 16:51 ` Andrii Nakryiko
2026-11-17 19:30 ` Paul Moore
2026-11-17 21:44 ` Andrii Nakryiko
2026-11-17 23:04 ` Paul Moore
2026-11-18 0:52 ` Ihor Solodrai
2026-11-18 14:18 ` Daan De Meyer
2026-11-18 15:14 ` Paul Mabileau
2026-11-19 17:59 ` Andrii Nakryiko
2026-11-19 19:37 ` Paul Moore
2026-11-23 19:55 ` Andrii Nakryiko
2026-11-23 20:21 ` Paul Moore
2026-11-19 17:58 ` Andrii Nakryiko
2026-11-24 11:42 ` roblabla [this message]
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=05507d51-651e-4ff8-aa6e-4bbb1e788f64@app.fastmail.com \
--to=linux@roblab.la \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daan@amutable.com \
--cc=ihor.solodrai@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul.mabileau@harfanglab.fr \
--cc=paul@paul-moore.com \
/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®