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)
commitc89e843a11f1075d27684f6b42256213e4592383
tree22c31daa6100b62e1d048af31c9c813cdf072bf0
parent197827a05e13808c60f52632e9887eede63f1c16
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: ca06f55b9002 ("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