]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: selftests: Add helpers to directly use the capget and capset syscall
authorMartin KaFai Lau <kafai@fb.com>
Wed, 16 Mar 2022 17:38:23 +0000 (10:38 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 16 Mar 2022 22:07:49 +0000 (15:07 -0700)
commitaaa227db390b7755b17f0e35df177b84d843e720
tree076f9ee083ab1a78459adec451c33df0373e59df
parentef45c6879bdab136b62149e1af7b927c0482a3e2
bpf: selftests: Add helpers to directly use the capget and capset syscall

After upgrading to the newer libcap (>= 2.60),
the libcap commit aca076443591 ("Make cap_t operations thread safe.")
added a "__u8 mutex;" to the "struct _cap_struct".  It caused a few byte
shift that breaks the assumption made in the "struct libcap" definition
in test_verifier.c.

The bpf selftest usage only needs to enable and disable the effective
caps of the running task.  It is easier to directly syscall the
capget and capset instead.  It can also remove the libcap
library dependency.

The cap_helpers.{c,h} is added.  One __u64 is used for all CAP_*
bits instead of two __u32.

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20220316173823.2036955-1-kafai@fb.com
tools/testing/selftests/bpf/cap_helpers.c [new file with mode: 0644]
tools/testing/selftests/bpf/cap_helpers.h [new file with mode: 0644]