Re: [PATCH bpf-next 10/13] bpf: Add the bpf_landlock_restrict_binprm kfunc

Justin Suess <[email protected]> Fri, 31 Jul 2026 15:40:21 -0400
Newsgroups dev.linux.lists.sashiko-reviews,org.kernel.vger.bpf
Message-ID <amz2tVz-P5Hrwm5B@zenbox>
On Fri, Jul 31, 2026 at 02:46:37AM +0000, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] Multiple calls to bpf_landlock_restrict_binprm() do not compose; a later call replaces a previously staged restriction instead of intersecting it, violating BPF LSM composition principles.
> - [Medium] bpf_landlock_kfunc_filter incorrectly restricts the release kfunc bpf_landlock_put_ruleset to only the two bprm sleepable hooks, violating the stated design and preventing valid reference cleanup in other LSM hooks.
> 
> [Severity: High]
> Does replacing instead of intersecting the ruleset break the BPF LSM
> composition principles?
> 
> If multiple BPF LSM programs are attached to the same hook, a later call to
> bpf_landlock_restrict_binprm() replaces a previously staged restriction
> rather than layering or intersecting it.
> 
> This allows a subsequent program to completely bypass and discard the security
> policy enforced by an earlier program.
>

It was agreed upon here [1] that it's better to just replace the domain
rather than allowing multiple calls to this function to build a
multi-layer domain. Merging staged domains creates issues of running
into the maximum layers and introduces unecessary complexity.

As for multiple BPF LSM programs trying to overwrite eachother's rulesets:
that's nonesense. There is no security boundary broken here. The ruleset
composition should happen in userspace before this kfunc ever
gets called. Pathological BPF programs are not part of the threat model.

Justin

[1] https://github.com/landlock-lsm/linux/issues/56#issuecomment-4825919649

> > +}
> > +
> 
> [ ... ]