[RFC PATCH v10 24/28] bpf: Register run LSM hooks

From: Jarkko Sakkinen

Date: Fri Dec 04 2026 - 22:29:22 EST


BPF LSM programs need sleepable and untrusted hook classifications for
the run LSM hooks in order to attach policies to run
allocation, namespace sharing, cloning, signaling, and release.

Register bpf_lsm_runfd_alloc, bpf_lsm_runfd_share,
bpf_lsm_runfd_clone, and bpf_lsm_runfd_kill in
sleepable_lsm_hooks, and bpf_lsm_runfd_alloc and
bpf_lsm_runfd_free in untrusted_lsm_hooks under CONFIG_RUNFD.

Signed-off-by: Jarkko Sakkinen <jarkko@xxxxxxxxxx>
---
kernel/bpf/bpf_lsm.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c
index ae23511fd811..f41cebc1af4a 100644
--- a/kernel/bpf/bpf_lsm.c
+++ b/kernel/bpf/bpf_lsm.c
@@ -16,6 +16,7 @@
#include <linux/btf_ids.h>
#include <linux/ima.h>
#include <linux/bpf-cgroup.h>
+#include <linux/runfd.h>

/* For every LSM hook that allows attachment of BPF programs, declare a nop
* function where a BPF program can be attached. Notably, we qualify each with
@@ -404,6 +405,12 @@ BTF_ID(func, bpf_lsm_task_setscheduler)
BTF_ID(func, bpf_lsm_userns_create)
BTF_ID(func, bpf_lsm_bdev_alloc_security)
BTF_ID(func, bpf_lsm_bdev_setintegrity)
+#ifdef CONFIG_RUNFD
+BTF_ID(func, bpf_lsm_runfd_alloc)
+BTF_ID(func, bpf_lsm_runfd_share)
+BTF_ID(func, bpf_lsm_runfd_clone)
+BTF_ID(func, bpf_lsm_runfd_kill)
+#endif /* CONFIG_RUNFD */
BTF_SET_END(sleepable_lsm_hooks)

BTF_SET_START(untrusted_lsm_hooks)
@@ -422,6 +429,10 @@ BTF_ID(func, bpf_lsm_sk_free_security)
BTF_ID(func, bpf_lsm_task_free)
BTF_ID(func, bpf_lsm_bdev_alloc_security)
BTF_ID(func, bpf_lsm_bdev_free_security)
+#ifdef CONFIG_RUNFD
+BTF_ID(func, bpf_lsm_runfd_alloc)
+BTF_ID(func, bpf_lsm_runfd_free)
+#endif /* CONFIG_RUNFD */
BTF_SET_END(untrusted_lsm_hooks)

bool bpf_lsm_is_sleepable_hook(u32 btf_id)
--
2.47.3