* [PATCH bpf-next] tools/bpf: fix a selftest test_btf failure
@ 2019-02-05 22:28 Yonghong Song
2019-02-06 0:39 ` Andrii Nakryiko
2019-02-06 2:36 ` Alexei Starovoitov
0 siblings, 2 replies; 4+ messages in thread
From: Yonghong Song @ 2019-02-05 22:28 UTC (permalink / raw)
To: Andrii Nakryiko, netdev
Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, Yonghong Song
Commit 9c651127445c ("selftests/btf: add initial BTF dedup tests")
added dedup tests in test_btf.c.
It broke the raw test:
BTF raw test[71] (func proto (Bad arg name_off)):
btf_raw_create:2905:FAIL Error getting string #65535, strs_cnt:1
The test itself encodes invalid func_proto parameter name
offset 0xffffFFFF as a negative test for the kernel.
The above commit changed the meaning of that offset and
resulted in a user space error.
#define NAME_NTH(N) (0xffff0000 | N)
#define IS_NAME_NTH(X) ((X & 0xffff0000) == 0xffff0000)
#define GET_NAME_NTH_IDX(X) (X & 0x0000ffff)
Currently, the kernel permits maximum name offset 0xffff.
Set the test name off as 0x0fffFFFF to trigger the kernel
verification failure.
Cc: Andrii Nakryiko <andriin@fb.com>
Fixes: 9c651127445c ("selftests/btf: add initial BTF dedup tests")
Signed-off-by: Yonghong Song <yhs@fb.com>
---
tools/testing/selftests/bpf/test_btf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c
index 30c3edde7e07..447acc34db94 100644
--- a/tools/testing/selftests/bpf/test_btf.c
+++ b/tools/testing/selftests/bpf/test_btf.c
@@ -1978,7 +1978,7 @@ static struct btf_raw_test raw_tests[] = {
/* void (*)(int a, unsigned int <bad_name_off>) */
BTF_FUNC_PROTO_ENC(0, 2), /* [3] */
BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 1),
- BTF_FUNC_PROTO_ARG_ENC(0xffffffff, 2),
+ BTF_FUNC_PROTO_ARG_ENC(0x0fffffff, 2),
BTF_END_RAW,
},
.str_sec = "\0a",
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] tools/bpf: fix a selftest test_btf failure
2019-02-05 22:28 [PATCH bpf-next] tools/bpf: fix a selftest test_btf failure Yonghong Song
@ 2019-02-06 0:39 ` Andrii Nakryiko
2019-02-06 2:36 ` Alexei Starovoitov
1 sibling, 0 replies; 4+ messages in thread
From: Andrii Nakryiko @ 2019-02-06 0:39 UTC (permalink / raw)
To: Yonghong Song
Cc: Andrii Nakryiko, netdev, Alexei Starovoitov, Daniel Borkmann,
kernel-team
On Tue, Feb 5, 2019 at 2:30 PM Yonghong Song <yhs@fb.com> wrote:
>
> Commit 9c651127445c ("selftests/btf: add initial BTF dedup tests")
> added dedup tests in test_btf.c.
> It broke the raw test:
> BTF raw test[71] (func proto (Bad arg name_off)):
> btf_raw_create:2905:FAIL Error getting string #65535, strs_cnt:1
Argh.. Thanks for fixing this!
>
> The test itself encodes invalid func_proto parameter name
> offset 0xffffFFFF as a negative test for the kernel.
> The above commit changed the meaning of that offset and
> resulted in a user space error.
> #define NAME_NTH(N) (0xffff0000 | N)
> #define IS_NAME_NTH(X) ((X & 0xffff0000) == 0xffff0000)
> #define GET_NAME_NTH_IDX(X) (X & 0x0000ffff)
>
> Currently, the kernel permits maximum name offset 0xffff.
> Set the test name off as 0x0fffFFFF to trigger the kernel
> verification failure.
>
> Cc: Andrii Nakryiko <andriin@fb.com>
> Fixes: 9c651127445c ("selftests/btf: add initial BTF dedup tests")
> Signed-off-by: Yonghong Song <yhs@fb.com>
> ---
> tools/testing/selftests/bpf/test_btf.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c
> index 30c3edde7e07..447acc34db94 100644
> --- a/tools/testing/selftests/bpf/test_btf.c
> +++ b/tools/testing/selftests/bpf/test_btf.c
> @@ -1978,7 +1978,7 @@ static struct btf_raw_test raw_tests[] = {
> /* void (*)(int a, unsigned int <bad_name_off>) */
> BTF_FUNC_PROTO_ENC(0, 2), /* [3] */
> BTF_FUNC_PROTO_ARG_ENC(NAME_TBD, 1),
> - BTF_FUNC_PROTO_ARG_ENC(0xffffffff, 2),
> + BTF_FUNC_PROTO_ARG_ENC(0x0fffffff, 2),
> BTF_END_RAW,
> },
> .str_sec = "\0a",
> --
> 2.17.1
>
Acked-by: Andrii Nakryiko <andriin@fb.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] tools/bpf: fix a selftest test_btf failure
2019-02-05 22:28 [PATCH bpf-next] tools/bpf: fix a selftest test_btf failure Yonghong Song
2019-02-06 0:39 ` Andrii Nakryiko
@ 2019-02-06 2:36 ` Alexei Starovoitov
2019-02-06 4:26 ` Yonghong Song
1 sibling, 1 reply; 4+ messages in thread
From: Alexei Starovoitov @ 2019-02-06 2:36 UTC (permalink / raw)
To: Yonghong Song
Cc: Andrii Nakryiko, netdev, Alexei Starovoitov, Daniel Borkmann,
kernel-team
On Tue, Feb 05, 2019 at 02:28:44PM -0800, Yonghong Song wrote:
> Commit 9c651127445c ("selftests/btf: add initial BTF dedup tests")
> added dedup tests in test_btf.c.
> It broke the raw test:
> BTF raw test[71] (func proto (Bad arg name_off)):
> btf_raw_create:2905:FAIL Error getting string #65535, strs_cnt:1
>
> The test itself encodes invalid func_proto parameter name
> offset 0xffffFFFF as a negative test for the kernel.
> The above commit changed the meaning of that offset and
> resulted in a user space error.
> #define NAME_NTH(N) (0xffff0000 | N)
> #define IS_NAME_NTH(X) ((X & 0xffff0000) == 0xffff0000)
> #define GET_NAME_NTH_IDX(X) (X & 0x0000ffff)
>
> Currently, the kernel permits maximum name offset 0xffff.
> Set the test name off as 0x0fffFFFF to trigger the kernel
> verification failure.
>
> Cc: Andrii Nakryiko <andriin@fb.com>
> Fixes: 9c651127445c ("selftests/btf: add initial BTF dedup tests")
> Signed-off-by: Yonghong Song <yhs@fb.com>
Applied, Thanks
Also I see the following new error in test_btf:
BTF libbpf test[2] (test_btf_nokv.o): libbpf: map:btf_map container_name:____btf_map_btf_map cannot be found in BTF. Missing BPF_ANNOTATE_KV_PAIR?
OK
A bunch of similar errors are in test_progs as well.
I suspect it's related to the last few btf changes.
Andrii, Yonghong, Please investigate.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] tools/bpf: fix a selftest test_btf failure
2019-02-06 2:36 ` Alexei Starovoitov
@ 2019-02-06 4:26 ` Yonghong Song
0 siblings, 0 replies; 4+ messages in thread
From: Yonghong Song @ 2019-02-06 4:26 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: Andrii Nakryiko, netdev@vger.kernel.org, Alexei Starovoitov,
Daniel Borkmann, Kernel Team
On 2/5/19 6:36 PM, Alexei Starovoitov wrote:
> On Tue, Feb 05, 2019 at 02:28:44PM -0800, Yonghong Song wrote:
>> Commit 9c651127445c ("selftests/btf: add initial BTF dedup tests")
>> added dedup tests in test_btf.c.
>> It broke the raw test:
>> BTF raw test[71] (func proto (Bad arg name_off)):
>> btf_raw_create:2905:FAIL Error getting string #65535, strs_cnt:1
>>
>> The test itself encodes invalid func_proto parameter name
>> offset 0xffffFFFF as a negative test for the kernel.
>> The above commit changed the meaning of that offset and
>> resulted in a user space error.
>> #define NAME_NTH(N) (0xffff0000 | N)
>> #define IS_NAME_NTH(X) ((X & 0xffff0000) == 0xffff0000)
>> #define GET_NAME_NTH_IDX(X) (X & 0x0000ffff)
>>
>> Currently, the kernel permits maximum name offset 0xffff.
>> Set the test name off as 0x0fffFFFF to trigger the kernel
>> verification failure.
>>
>> Cc: Andrii Nakryiko <andriin@fb.com>
>> Fixes: 9c651127445c ("selftests/btf: add initial BTF dedup tests")
>> Signed-off-by: Yonghong Song <yhs@fb.com>
>
> Applied, Thanks
>
> Also I see the following new error in test_btf:
> BTF libbpf test[2] (test_btf_nokv.o): libbpf: map:btf_map container_name:____btf_map_btf_map cannot be found in BTF. Missing BPF_ANNOTATE_KV_PAIR?
> OK
>
> A bunch of similar errors are in test_progs as well.
> I suspect it's related to the last few btf changes.
> Andrii, Yonghong, Please investigate.
It is due to one of previous patches to refector btf__get_map_kv_tids(),
accidentally using pr_warning instead of original pr_debug.
Will submit a patch soon.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-02-06 4:26 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-05 22:28 [PATCH bpf-next] tools/bpf: fix a selftest test_btf failure Yonghong Song
2019-02-06 0:39 ` Andrii Nakryiko
2019-02-06 2:36 ` Alexei Starovoitov
2019-02-06 4:26 ` Yonghong Song
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.