selftests/bpf: Use _REGION1_SIZE in test_snprintf_btf on s390
Subsystems (3)
PATCH 1/1 selftests/bpf: Use _REGION1_SIZE in test_snprintf_btf on s390
test_snprintf_btf fails on s390, because NULL points to a readable struct lowcore there. Fix by using _REGION1_SIZE instead.
Signed-off-by Ilya Leoshkevich <[email protected]>
--- tools/testing/selftests/bpf/progs/netif_receive_skb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/progs/netif_receive_skb.c +9 -2
@@ -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 _REGION1_SIZE */ +#define BADPTR ((void *)(1ULL << 53)) +#else +#define BADPTR 0 +#endif +#ifndef ARRAY_SIZE #define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))#endif
@@ -114,9 +121,9 @@ int BPF_PROG(trace_netif_receive_skb, struct sk_buff *skb)/* Check invalid ptr value */ p.ptr =0 ; - __ret =bpf_snprintf_btf (str,STRSIZE , &p,sizeof (p),0 ); + __ret =bpf_snprintf_btf (str,STRSIZE , &p,sizeof (p),BADPTR );if (__ret >=0 ) { -bpf_printk ("printing NULL should generate error, got (%d)" , +bpf_printk ("printing BADPTR should generate error, got (%d)" , __ret); ret = -ERANGE ; }
Signature · 1 line
2.29.2
Quoted 4 lines · Ilya Leoshkevich
test_snprintf_btffails on s390, because NULL points to a readable struct lowcore there. Fix by using_REGION1_SIZEinstead.Signed-off-by Ilya Leoshkevich <[email protected]>
Ack with a minor nit below.
Acked-by Yonghong Song <[email protected]>
Quoted 23 lines
--- tools/testing/selftests/bpf/progs/netif_receive_skb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)tools/testing/selftests/bpf/progs/netif_receive_skb.c +7
-0@@ -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 _REGION1_SIZE */ +#define BADPTR ((void *)(1ULL << 53)) +#else +#define BADPTR 0 +#endif +#ifndef ARRAY_SIZE #define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))#endif
tools/testing/selftests/bpf/progs/netif_receive_skb.c int BPF_PROG(trace_netif_receive_skb, struct sk_buff *skb) · line 127
Quoted 9 lines
tools/testing/selftests/bpf/progs/netif_receive_skb.c +2
-2@@ -114,9 +121,9 @@ int BPF_PROG(trace_netif_receive_skb, struct sk_buff *skb)/* Check invalid ptr value */ p.ptr =0 ; - __ret =bpf_snprintf_btf (str,STRSIZE , &p,sizeof (p),0 ); + __ret =bpf_snprintf_btf (str,STRSIZE , &p,sizeof (p),BADPTR );if (__ret >=0 ) { -bpf_printk ("printing NULL should generate error, got (%d)" , +bpf_printk ("printing BADPTR should generate error, got (%d)" , __ret);
The previous error message NULL implies address 0. The new error message did not print out the badptr address. Do you want to print them out so in case of errors, you don't need to search source code?
Quoted 3 lines
tools/testing/selftests/bpf/progs/netif_receive_skb.c +0
-0ret = -ERANGE ; }