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
Hi Zachary,
On Wed, Jun 07, 2023 at 12:53:44PM +0100, Zachary Leaf wrote:
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.
I assume that BUFSIZ is sufficient for bpf_prog01 ? Looking at the other tests, it seems to be somewhat a pattern of defining the log buffer size explicitly, so maybe we could do that once for all of those in a single place, like bpf_common.h ?
--- BR B.
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},
{&attr, .size = sizeof(*attr)}, {&msg, .size = sizeof(MSG)}, {},{&log, .size = BUFSIZE},
-- 2.34.1
linux-morello-ltp mailing list -- linux-morello-ltp@op-lists.linaro.org To unsubscribe send an email to linux-morello-ltp-leave@op-lists.linaro.org
On 08/06/2023 13:53, Beata Michalska wrote:
Hi Zachary,
On Wed, Jun 07, 2023 at 12:53:44PM +0100, Zachary Leaf wrote:
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.
I assume that BUFSIZ is sufficient for bpf_prog01 ? Looking at the other tests, it seems to be somewhat a pattern of defining the log buffer size explicitly, so maybe we could do that once for all of those in a single place, like bpf_common.h ?
It is enough for bpf_prog01 - no failures there. Agree with what you suggest re: bpf_common.h. Will post a v2.
Thanks, Zach
BR B.
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},
{&attr, .size = sizeof(*attr)}, {&msg, .size = sizeof(MSG)}, {},{&log, .size = BUFSIZE},
-- 2.34.1
linux-morello-ltp mailing list -- linux-morello-ltp@op-lists.linaro.org To unsubscribe send an email to linux-morello-ltp-leave@op-lists.linaro.org
linux-morello-ltp@op-lists.linaro.org