[PATCH bpf-next v2 0/3] BPF signature hash chains
Alexei Starovoitov
alexei.starovoitov at gmail.com
Fri Oct 10 23:06:18 UTC 2025
On Fri, Oct 10, 2025 at 8:53 AM James Bottomley
<James.Bottomley at hansenpartnership.com> wrote:
>
> On Thu, 2025-10-09 at 18:00 -0700, Alexei Starovoitov wrote:
> [...]
> > James's concern is valid though:
> >
> > > However, the rub for LSM is that the verification of the program
> > > map by the loader happens *after* the security_bpf_prog_load() hook
> > > has been called.
> >
> > I understand the discomfort, but that's what the kernel module
> > loading process is doing as well, so you should be concerned with
> > both. Since both are doing pretty much the same work.
>
> OK, so let me push on this one point because I don't agree with what
> you say here. The way kernel modules and eBPF load is not equivalent.
> The kernel module signatures go over a relocateable elf binary which is
> subsequently relocated after signature verification in the kernel by
> the ELF loader. You can regard the ELF loader as being equivalent to
> the eBPF loader in terms of function, absolutely. However for security
> purposes the ELF loader is a trusted part of the kernel security
> envelope and its integrity is part of the kernel integrity and we have
> a this single trusted loader for every module. In security terms
> verification of the ELF object signature is sufficient to guarantee
> integrity of the module because the integrity of the ELF loader is
> already checked.
"integrity of ELF loader" is _not_ checked. It's part of the kernel
and you trust that the kernel is valid, because you trust the
build tools that compiled that kernel.
The kmod signature only covers the contents of the kmod.
Now, kmods are typically targeted one specific kernel version
compiled with a specific config, but some folks do load the same
kmod on different kernels. So by checking integrity of kmod only
you're skipping on the loader. If symbols are not versioned
and crc checked bad things can happen (obviously no one should
be doing that), but signature doesn't protect against that.
Compare that with the bpf signature. The whole package is signed.
The loader and what it is loading with one signature.
I argue that this is a more secure approach than kmod signatures.
Think of it as a self-extracting zip archive.
The whole .zip is covered by one signature. Inside it has the code
to self extract plus all the files inside.
The extracting code is a loader prog. Which is a normal bpf
prog that is subject to the same verification rules.
The files are other bpf progs that are also subject to the verification.
> The eBPF loader, by contrast, because it contains all the relocations,
> is different for every eBPF light skeleton. This means it's not a
> trusted part of the kernel and has to be integrity checked as well.
...and the existing mechanism already does that.
> Thus for eBPF, the integrity check must be over both the loader and the
> program; integrity checking is not complete until the integrity of both
> has been verified.
The signature covers all components: loader, the map that assists
the loading and all progs and maps that are encoded inside that
loader/map tuple.
> If you sign only the loader and embed the hash of
> the program into the loader that is a different way of doing things,
That's simply not true.
Please read the current code more carefully. There is cover letter
that describes what's happening. There are no hashes of programs.
> There are two potential solutions to this: complete the integrity check
> before running the load hook (Blaise's patch)
That's not what it's doing! Read his patch. It's adding pointless
signature to the loader/map tuple. It does nothing to progs, maps,
relocations that will be created at the end when loader completes.
You need to realize that single loader plus single map is
an implementation choice of tools/lib/bpf/gen_loader.c.
It can do the same job with a single prog and no additional map.
Hence any kinda hard coded extra map signature makes no sense.
We're not going to burden the kernel with one specific implementation
detail of gen_loader.
Tomorrow we might change the gen_loader to use a triple:
prog+map+btf or any other form.
The existing approach allows all that extensibility and freedom
to change the gen_loader.
> or add a LSM hook to
> collect the integrity information from the run of the loader. Neither
> of these is present in the scheme you put upstream.
Neither is in cards as was explained countless times.
More information about the Linux-security-module-archive
mailing list