]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
bpf: lsm: Add selftests for BPF_PROG_TYPE_LSM
authorKP Singh <kpsingh@google.com>
Sun, 29 Mar 2020 00:43:55 +0000 (01:43 +0100)
committerDaniel Borkmann <daniel@iogearbox.net>
Sun, 29 Mar 2020 23:35:11 +0000 (01:35 +0200)
commit03e54f100d5756f8403fffd60aed8e883ea864c0
tree2f0420f59340c4135cdbad9893de20dd66f24666
parent1e092a0318292637cde832868016f37e942eed24
bpf: lsm: Add selftests for BPF_PROG_TYPE_LSM

* Load/attach a BPF program that hooks to file_mprotect (int)
  and bprm_committed_creds (void).
* Perform an action that triggers the hook.
* Verify if the audit event was received using the shared global
  variables for the process executed.
* Verify if the mprotect returns a -EPERM.

Signed-off-by: KP Singh <kpsingh@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Brendan Jackman <jackmanb@google.com>
Reviewed-by: Florent Revest <revest@google.com>
Reviewed-by: Thomas Garnier <thgarnie@google.com>
Reviewed-by: James Morris <jamorris@linux.microsoft.com>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200329004356.27286-8-kpsingh@chromium.org
tools/testing/selftests/bpf/config
tools/testing/selftests/bpf/prog_tests/test_lsm.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/lsm.c [new file with mode: 0644]