]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix net.core.bpf_jit_harden race
authorHou Tao <houtao1@huawei.com>
Wed, 9 Mar 2022 12:33:20 +0000 (20:33 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 16 Mar 2022 22:13:36 +0000 (15:13 -0700)
commit9ccf250aaa2f73c70364c3cab3d81f07b665f750
treec70bd9195500322ed9bbf0e4b783e9038dc3ffee
parent40d26c7f55b17a2a48178851bbb48d4b1e0d7453
bpf: Fix net.core.bpf_jit_harden race

It is the bpf_jit_harden counterpart to commit a511effd1b8d ("bpf: fix
net.core.bpf_jit_enable race"). bpf_jit_harden will be tested twice
for each subprog if there are subprogs in bpf program and constant
blinding may increase the length of program, so when running
"./test_progs -t subprogs" and toggling bpf_jit_harden between 0 and 2,
jit_subprogs may fail because constant blinding increases the length
of subprog instructions during extra passs.

So cache the value of bpf_jit_blinding_enabled() during program
allocation, and use the cached value during constant blinding, subprog
JITing and args tracking of tail call.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20220309123321.2400262-4-houtao1@huawei.com
include/linux/filter.h
kernel/bpf/core.c
kernel/bpf/verifier.c