• Ilya Leoshkevich's avatar
    selftests/bpf: fix endianness issues in test_sysctl · 3ec2a0ed
    Ilya Leoshkevich authored
    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: 1f5fa9ab ("selftests/bpf: Test BPF_CGROUP_SYSCTL")
    Fixes: 9a1027e5 ("selftests/bpf: Test file_pos field in bpf_sysctl ctx")
    Fixes: 6041c67f ("selftests/bpf: Test bpf_sysctl_get_name helper")
    Fixes: 11ff34f7 ("selftests/bpf: Test sysctl_get_current_value helper")
    Fixes: 786047dd ("selftests/bpf: Test bpf_sysctl_{get,set}_new_value helpers")
    Fixes: 8549ddc8 ("selftests/bpf: Test bpf_strtol and bpf_strtoul helpers")
    Signed-off-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
    Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
    3ec2a0ed
test_sysctl.c 39.3 KB