]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Use this_cpu_{inc_return|dec} for prog->active
authorHou Tao <houtao1@huawei.com>
Thu, 1 Sep 2022 06:19:36 +0000 (14:19 +0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 1 Sep 2022 19:16:18 +0000 (12:16 -0700)
commit15873d41cc5d9586b16dd455024ea165b931a6b6
tree22c31daa6100b62e1d048af31c9c813cdf072bf0
parent5f8dd653a6cc9af19b64d21a03e134fa78092dbb
bpf: Use this_cpu_{inc_return|dec} for prog->active

Both __this_cpu_inc_return() and __this_cpu_dec() are not preemption
safe and now migrate_disable() doesn't disable preemption, so the update
of prog-active is not atomic and in theory under fully preemptible kernel
recurisve prevention may do not work.

Fixing by using the preemption-safe and IRQ-safe variants.

Fixes: 37008115de95 ("bpf: Add per-program recursion prevention mechanism")
Signed-off-by: Hou Tao <houtao1@huawei.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/r/20220901061938.3789460-3-houtao@huaweicloud.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
kernel/bpf/trampoline.c