]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix replace_map_fd_with_map_ptr's ldimm64 second imm field
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 4 Mar 2019 20:08:53 +0000 (21:08 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 7 Mar 2019 16:47:13 +0000 (08:47 -0800)
commit8c7aeb35c3ff0f8c3171c9fc5e9ee653a6511b39
tree912da4b5a7ce4279311206bc1e8ede8619d057b3
parent30cd7cad7a9219a91cd5beeb552ae2237792bd96
bpf: fix replace_map_fd_with_map_ptr's ldimm64 second imm field

Non-zero imm value in the second part of the ldimm64 instruction for
BPF_PSEUDO_MAP_FD is invalid, and thus must be rejected. The map fd
only ever sits in the first instructions' imm field. None of the BPF
loaders known to us are using it, so risk of regression is minimal.
For clarity and consistency, the few insn->{src_reg,imm} occurrences
are rewritten into insn[0].{src_reg,imm}. Add a test case to the BPF
selftest suite as well.

Fixes: 2aadee160a84 ("bpf: handle pseudo BPF_LD_IMM64 insn")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/verifier.c
tools/testing/selftests/bpf/verifier/ld_imm64.c