]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix accessing bpf_sysctl.file_pos on s390
authorIlya Leoshkevich <iii@linux.ibm.com>
Fri, 16 Aug 2019 10:53:00 +0000 (12:53 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 16 Sep 2019 09:44:05 +0000 (11:44 +0200)
commit12cde0391c0c5a361cddf7f04d40a67cd22453c6
treed37c4f163bc37e8bce4150c075db214d7d1af389
parent9e18fae152d1993a498501b739e5efee1b2890d5
bpf: fix accessing bpf_sysctl.file_pos on s390

"ctx:file_pos sysctl:read write ok" fails on s390 with "Read value  !=
nux". This is because verifier rewrites a complete 32-bit
bpf_sysctl.file_pos update to a partial update of the first 32 bits of
64-bit *bpf_sysctl_kern.ppos, which is not correct on big-endian
systems.

Fix by using an offset on big-endian systems.

Ditto for bpf_sysctl.file_pos reads. Currently the test does not detect
a problem there, since it expects to see 0, which it gets with high
probability in error cases, so change it to seek to offset 3 and expect
3 in bpf_sysctl.file_pos.

Fixes: b6ff29d6083b ("bpf: Add file_pos field to bpf_sysctl ctx")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20190816105300.49035-1-iii@linux.ibm.com/
include/linux/filter.h
kernel/bpf/cgroup.c
kernel/bpf/verifier.c
tools/testing/selftests/bpf/test_sysctl.c