selftests/bpf: Use the last page in test_snprintf_btf on s390
Subsystems (3)
PATCH v4 1/1 selftests/bpf: Use the last page in test_snprintf_btf on s390
test_snprintf_btf fails on s390, because NULL points to a readable struct lowcore there. Fix by using the last page instead.
Error message example:
printing fffffffffffff000 should generate error, got (361)
---
v1: https://lore.kernel.org/bpf/[email protected]/
v1 -> v2: Yonghong suggested to add the pointer value to the error
message.
I've noticed that I've been passing BADPTR as flags, therefore the fix worked only by accident. Put it into p.ptr where it belongs.
v2: https://lore.kernel.org/bpf/[email protected]/
v2 -> v3: Heiko mentioned that using _REGION1_SIZE is not future-proof.
We had a private discussion and came to the conclusion that the the last page is good enough.
v3: https://lore.kernel.org/bpf/[email protected]/
v3 -> v4: Yonghong suggested to print the non-hashed pointer value.
.../testing/selftests/bpf/progs/netif_receive_skb.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
tools/testing/selftests/bpf/progs/netif_receive_skb.c +10 -3
@@ -16,6 +16,13 @@ bool skip = false;#define STRSIZE 2048#define EXPECTED_STRSIZE 256 +#if defined(bpf_target_s390) +/* NULL points to a readable struct lowcore on s390, so take the last page */ +#define BADPTR ((void *)0xFFFFFFFFFFFFF000ULL) +#else +#define BADPTR 0 +#endif +#ifndef ARRAY_SIZE #define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))#endif
@@ -113,11 +120,11 @@ int BPF_PROG(trace_netif_receive_skb, struct sk_buff *skb) }/* Check invalid ptr value */ - p.ptr =0 ; + p.ptr =BADPTR ; __ret =bpf_snprintf_btf (str,STRSIZE , &p,sizeof (p),0 );if (__ret >=0 ) { -bpf_printk ("printing NULL should generate error, got (%d)" , - __ret); +bpf_printk ("printing %llx should generate error, got (%d)" , + (unsigned long long )BADPTR , __ret); ret = -ERANGE ; }
Signature · 1 line
2.29.2
Quoted 23 lines · Ilya Leoshkevich
test_snprintf_btffails on s390, because NULL points to a readable struct lowcore there. Fix by using the last page instead.Error message example:
printing
fffffffffffff000should generate error, got (361)Signed-off-by Ilya Leoshkevich <[email protected]>---
v1: https://lore.kernel.org/bpf/[email protected]/
v1 -> v2: Yonghong suggested to add the pointer value to the error
message.
I've noticed that I've been passing BADPTR as flags, therefore the fix worked only by accident. Put it into p.ptr where it belongs.v2: https://lore.kernel.org/bpf/[email protected]/
v2 -> v3: Heiko mentioned that using_REGION1_SIZEis not future-proof.
We had a private discussion and came to the conclusion that the the last page is good enough.
Quoted 5 lines
v3: https://lore.kernel.org/bpf/[email protected]/
v3 -> v4: Yonghong suggested to print the non-hashed pointer value..../testing/selftests/bpf/progs/netif_receive_skb.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
Just in case, also for v4:
Quoted 8 lines · Ilya Leoshkevich
test_snprintf_btffails on s390, because NULL points to a readable struct lowcore there. Fix by using the last page instead.Error message example:
printing
fffffffffffff000should generate error, got (361)Signed-off-by Ilya Leoshkevich <[email protected]>
This patch was applied to bpf/bpf.git (refs/heads/master):
Hello:
This patch was applied to bpf/bpf.git (refs/heads/master):
Quoted 8 lines · On Sat, 27 Feb 2021 06:17:26 +0100 you wrote:
test_snprintf_btffails on s390, because NULL points to a readable struct lowcore there. Fix by using the last page instead.Error message example:
printing
fffffffffffff000should generate error, got (361)[...]
Here is the summary with links:
- [v4,bpf-next] selftests/bpf: Use the last page in test_snprintf_btf on s390
https://git.kernel.org/bpf/bpf/c/42a382a466a9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html