]> www.infradead.org Git - users/jedix/linux-maple.git/commit
security: Propagate caller information in bpf hooks
authorBlaise Boscaccy <bboscaccy@linux.microsoft.com>
Mon, 10 Mar 2025 22:17:11 +0000 (15:17 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 15 Mar 2025 18:48:58 +0000 (11:48 -0700)
commit082f1db02c8034fee787ea9809775ea861c50430
tree2f7cc9e034ac90a00bad5066301ed472d3801ee9
parenta03d375330de32d859e827b3aad1e57908976708
security: Propagate caller information in bpf hooks

Certain bpf syscall subcommands are available for usage from both
userspace and the kernel. LSM modules or eBPF gatekeeper programs may
need to take a different course of action depending on whether or not
a BPF syscall originated from the kernel or userspace.

Additionally, some of the bpf_attr struct fields contain pointers to
arbitrary memory. Currently the functionality to determine whether or
not a pointer refers to kernel memory or userspace memory is exposed
to the bpf verifier, but that information is missing from various LSM
hooks.

Here we augment the LSM hooks to provide this data, by simply passing
a boolean flag indicating whether or not the call originated in the
kernel, in any hook that contains a bpf_attr struct that corresponds
to a subcommand that may be called from the kernel.

Signed-off-by: Blaise Boscaccy <bboscaccy@linux.microsoft.com>
Acked-by: Song Liu <song@kernel.org>
Acked-by: Paul Moore <paul@paul-moore.com>
Link: https://lore.kernel.org/r/20250310221737.821889-2-bboscaccy@linux.microsoft.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
12 files changed:
include/linux/lsm_hook_defs.h
include/linux/security.h
kernel/bpf/syscall.c
security/security.c
security/selinux/hooks.c
tools/testing/selftests/bpf/progs/rcu_read_lock.c
tools/testing/selftests/bpf/progs/test_cgroup1_hierarchy.c
tools/testing/selftests/bpf/progs/test_kfunc_dynptr_param.c
tools/testing/selftests/bpf/progs/test_lookup_key.c
tools/testing/selftests/bpf/progs/test_ptr_untrusted.c
tools/testing/selftests/bpf/progs/test_task_under_cgroup.c
tools/testing/selftests/bpf/progs/test_verify_pkcs7_sig.c