Currently log size is set to BUFSIZ which is defined by the libc in stdio.h. In glibc, this is set to the constant 8196. In other libc's this value can vary, e.g. in Musl this is set to 1024 which is not large enough to store the verifier log, resulting in the following test breakage:
[...] bpf_common.c:123: TBROK: Failed verification: ENOSPC (28)
This error is returned from kernel/bpf/verifier.c when the verifier log exceeds the user supplied buffer.
Align bpf_prog02 with other bpf tests and set the buffer size explicitly to 8196 in a #define at the top of the file.
Signed-off-by: Zachary Leaf zachary.leaf@arm.com ---
Note: this fix is not dependent on any Morello kernel bpf syscall changes, so has been split out from those. Can be merged/reviewed independently of those.
Looks to be upstreamable.
Branch at: https://git.morello-project.org/zdleaf/morello-linux-test-project/-/tree/rev...
testcases/kernel/syscalls/bpf/bpf_prog02.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/bpf/bpf_prog02.c b/testcases/kernel/syscalls/bpf/bpf_prog02.c index b40ea0f1d..927263a33 100644 --- a/testcases/kernel/syscalls/bpf/bpf_prog02.c +++ b/testcases/kernel/syscalls/bpf/bpf_prog02.c @@ -24,6 +24,7 @@ #include "bpf_common.h"
#define A64INT (((uint64_t)1) << 60) +#define BUFSIZE 8196
const char MSG[] = "Ahoj!"; static char *msg; @@ -64,7 +65,7 @@ static int load_prog(int fd) BPF_EXIT_INSN(), /* 26: return r0 */ };
- bpf_init_prog_attr(attr, insn, sizeof(insn), log, BUFSIZ); + bpf_init_prog_attr(attr, insn, sizeof(insn), log, BUFSIZE); return bpf_load_prog(attr, log); }
@@ -117,7 +118,7 @@ static struct tst_test test = { .bufs = (struct tst_buffers []) { {&key, .size = sizeof(*key)}, {&val, .size = sizeof(*val)}, - {&log, .size = BUFSIZ}, + {&log, .size = BUFSIZE}, {&attr, .size = sizeof(*attr)}, {&msg, .size = sizeof(MSG)}, {}, -- 2.34.1