]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: reject stores into ctx via st and xadd
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 16 Jan 2018 22:30:10 +0000 (23:30 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 16 Jan 2018 23:04:58 +0000 (15:04 -0800)
commitb41a05062fad3a24aa1f8bcd1edffaeccff3a6c4
treed6440b185e4d4810624fb59163ff419cd1a28ca4
parent9c7b0fc23923004a6d1ffbbf5dccd571d8657c55
bpf: reject stores into ctx via st and xadd

Alexei found that verifier does not reject stores into context
via BPF_ST instead of BPF_STX. And while looking at it, we
also should not allow XADD variant of BPF_STX.

The context rewriter is only assuming either BPF_LDX_MEM- or
BPF_STX_MEM-type operations, thus reject anything other than
that so that assumptions in the rewriter properly hold. Add
test cases as well for BPF selftests.

Fixes: eb37f9b1bed1 ("bpf: allow programs to write to certain skb fields")
Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c
tools/testing/selftests/bpf/test_verifier.c