]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix byte order test in test_verifier
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 4 Aug 2017 20:24:41 +0000 (22:24 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 4 Aug 2017 23:09:06 +0000 (16:09 -0700)
commit5ec7ad30bd55ba4265c7c5db2194987f1e2fad8d
treea01b0b305e15c0dbc5ccddb4705804a903d2cb31
parent42d3ca7924a0415eff945a76dad28fa414ea033a
bpf: fix byte order test in test_verifier

We really must check with #if __BYTE_ORDER == XYZ instead of
just presence of #ifdef __LITTLE_ENDIAN. I noticed that when
actually running this on big endian machine, the latter test
resolves to true for user space, same for #ifdef __BIG_ENDIAN.

E.g., looking at endian.h from libc, both are also defined
there, so we really must test this against __BYTE_ORDER instead
for proper insns selection. For the kernel, such checks are
fine though e.g. see 79a37e84a6d1 ("Revert "endian: #define
__BYTE_ORDER"") and e70664ef5ddb ("UAPI: fix endianness conditionals
in M32R's asm/stat.h") for some more context, but not for
user space. Lets also make sure to properly include endian.h.
After that, suite passes for me:

./test_verifier: ELF 64-bit MSB executable, [...]

Linux foo 4.13.0-rc3+ #4 SMP Fri Aug 4 06:59:30 EDT 2017 s390x s390x s390x GNU/Linux

Before fix: Summary: 505 PASSED, 11 FAILED
After  fix: Summary: 516 PASSED,  0 FAILED

Fixes: b0bd0542cc62 ("selftests/bpf: Add test cases to test narrower ctx field loads")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong <yhs@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/bpf/test_verifier.c