selftests/bpf: fix endianness issues in test_sysctl
authorIlya Leoshkevich <iii@linux.ibm.com>
Fri, 30 Aug 2019 11:07:32 +0000 (13:07 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 3 Sep 2019 19:01:52 +0000 (21:01 +0200)
commit3ec2a0ed3fec4ec8b27d9b71fdcbc1c30d1542d3
treec3b394a6a1d22385770e2db21bd0e5f07f5b0570
parent416c572821841bef2cbb6346fb559901efff4ff3
selftests/bpf: fix endianness issues in test_sysctl

A lot of test_sysctl sub-tests fail due to handling strings as a bunch
of immediate values in a little-endian-specific manner.

Fix by wrapping all immediates in bpf_ntohl and the new bpf_be64_to_cpu.

fixup_sysctl_value() dynamically writes an immediate, and thus should be
endianness-aware.  Implement this by simply memcpy()ing the raw
user-provided value, since testcase endianness and bpf program
endianness match.

Fixes: 1f5fa9ab6e2e ("selftests/bpf: Test BPF_CGROUP_SYSCTL")
Fixes: 9a1027e52535 ("selftests/bpf: Test file_pos field in bpf_sysctl ctx")
Fixes: 6041c67f28d8 ("selftests/bpf: Test bpf_sysctl_get_name helper")
Fixes: 11ff34f74e32 ("selftests/bpf: Test sysctl_get_current_value helper")
Fixes: 786047dd08de ("selftests/bpf: Test bpf_sysctl_{get,set}_new_value helpers")
Fixes: 8549ddc832d6 ("selftests/bpf: Test bpf_strtol and bpf_strtoul helpers")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/test_sysctl.c