Skip to content

security: Propagate caller information in bpf hooks

Blaise Boscaccy bpf linux-kselftest linux-security-module lkml selinux 6 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest2 patches 2 repliesApplied 2/2
  2. v62 patches 6 repliesSuperseded
  3. v52 patches 1 replySuperseded
Earlier versions · 3
VersionPostedPatchesRepliesStatus
v42 patches12 repliesSuperseded
v31 patch1 replySuperseded
v11 patch1 replySuperseded

Patches in v7 All 2 applied

#Subject and filesSizeRepliesApplied
1/2security: Propagate caller information in bpf hooksinclude/linux/lsm_hook_defs.h include/linux/security.h kernel/bpf/syscall.c +9 more+37 -330 repliesApplied
2/2selftests/bpf: Add a kernel flag test for LSM bpf hooktools/testing/selftests/bpf/prog_tests/kernel_flag.c tools/testing/selftests/bpf/progs/test_kernel_flag.c+71 -02 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchSong LiuPaul Moore
1/2A-b A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v7 thread

Cover letter [PATCH v7 bpf-next 0/2] security: Propagate caller information in bpf hooks

Hello,

While trying to implement an eBPF gatekeeper program, we ran into an issue whereas the LSM hooks are missing some relevant data.

Certain subcommands passed to the bpf() syscall can be invoked from either the kernel or userspace. Additionally, some fields in the bpf_attr struct contain pointers, and depending on where the subcommand was invoked, they could point to either user or kernel memory. One example of this is the bpf_prog_load subcommand and its fd_array. This data is made available and used by the verifier but not made available to the LSM subsystem. This patchset simply exposes that information to applicable LSM hooks.

Change list:
- v6 -> v7
- use gettid/pid in lieu of getpid/tgid in test condition
- v5 -> v6
- fix regression caused by is_kernel renaming
- simplify test logic
- v4 -> v5
- merge v4 selftest breakout patch back into a single patch
- change "is_kernel" to "kernel"
- add selftest using new kernel flag
- v3 -> v4
- split out selftest changes into a separate patch
- v2 -> v3
- reorder params so that the new boolean flag is the last param
- fixup function signatures in bpf selftests
- v1 -> v2
- Pass a boolean flag in lieu of bpfptr_t

Revisions:
- v6
https://lore.kernel.org/bpf/[email protected]/
- v5
https://lore.kernel.org/bpf/[email protected]/
- v4
https://lore.kernel.org/bpf/[email protected]/
- v3
https://lore.kernel.org/bpf/[email protected]/
- v2
https://lore.kernel.org/bpf/[email protected]/
- v1
https://lore.kernel.org/bpf/[email protected]/

Blaise Boscaccy (2):
security: Propagate caller information in bpf hooks selftests/bpf: Add a kernel flag test for LSM bpf hook

 include/linux/lsm_hook_defs.h                 |  6 +--
 include/linux/security.h                      | 12 +++---
 kernel/bpf/syscall.c                          | 10 ++---
 security/security.c                           | 15 ++++---
 security/selinux/hooks.c                      |  6 +--
 .../selftests/bpf/prog_tests/kernel_flag.c    | 43 +++++++++++++++++++
 .../selftests/bpf/progs/rcu_read_lock.c       |  3 +-
 .../bpf/progs/test_cgroup1_hierarchy.c        |  4 +-
 .../selftests/bpf/progs/test_kernel_flag.c    | 28 ++++++++++++
 .../bpf/progs/test_kfunc_dynptr_param.c       |  6 +--
 .../selftests/bpf/progs/test_lookup_key.c     |  2 +-
 .../selftests/bpf/progs/test_ptr_untrusted.c  |  2 +-
 .../bpf/progs/test_task_under_cgroup.c        |  2 +-
 .../bpf/progs/test_verify_pkcs7_sig.c         |  2 +-
 14 files changed, 108 insertions(+), 33 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/kernel_flag.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_kernel_flag.c
Signature · 1 line
2.48.1