aboutsummaryrefslogtreecommitdiffstats
path: root/samples
diff options
context:
space:
mode:
authorYauheni Kaliuta <yauheni.kaliuta@redhat.com>2021-02-28 12:30:17 +0200
committerDaniel Borkmann <daniel@iogearbox.net>2021-03-02 11:50:00 +0100
commit6185266c5a853bb0f2a459e3ff594546f277609b (patch)
tree63238b9cc640711ba0817b214ef7bf9ca62ba637 /samples
parentselftests/bpf: Use the last page in test_snprintf_btf on s390 (diff)
downloadlinux-dev-6185266c5a853bb0f2a459e3ff594546f277609b.tar.xz
linux-dev-6185266c5a853bb0f2a459e3ff594546f277609b.zip
selftests/bpf: Mask bpf_csum_diff() return value to 16 bits in test_verifier
The verifier test labelled "valid read map access into a read-only array 2" calls the bpf_csum_diff() helper and checks its return value. However, architecture implementations of csum_partial() (which is what the helper uses) differ in whether they fold the return value to 16 bit or not. For example, x86 version has ... if (unlikely(odd)) { result = from32to16(result); result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); } ... while generic lib/checksum.c does: result = from32to16(result); if (odd) result = ((result >> 8) & 0xff) | ((result & 0xff) << 8); This makes the helper return different values on different architectures, breaking the test on non-x86. To fix this, add an additional instruction to always mask the return value to 16 bits, and update the expected return value accordingly. Fixes: fb2abb73e575 ("bpf, selftest: test {rd, wr}only flags and direct value access") Signed-off-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20210228103017.320240-1-yauheni.kaliuta@redhat.com
Diffstat (limited to 'samples')
0 files changed, 0 insertions, 0 deletions