mbox series

[RFC,bpf-next,0/2] bpf: Add a new kfunc bpf_current_capable

Message ID 20230814143341.3767-1-laoar.shao@gmail.com (mailing list archive)
Headers show
Series bpf: Add a new kfunc bpf_current_capable | expand

Message

Yafang Shao Aug. 14, 2023, 2:33 p.m. UTC
Add a new kfunc bpf_current_capable to check whether the current task
has a specific capability. In our use case, we will use it in a lsm bpf
program to verify if the user operation is permitted based on our
security policy.

Yafang Shao (2):
  bpf: Add bpf_current_capable kfunc
  selftests/bpf: Add selftest for bpf_current_capable

 kernel/bpf/helpers.c                               |  6 ++
 .../selftests/bpf/prog_tests/bpf_current_cap.c     | 80 ++++++++++++++++++++++
 .../selftests/bpf/progs/test_bpf_current_cap.c     | 37 ++++++++++
 3 files changed, 123 insertions(+)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_current_cap.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_bpf_current_cap.c