bpf: Move out synchronize_rcu_tasks_trace from mutex CS
authorPu Lehui <pulehui@huawei.com>
Sat, 4 Jan 2025 01:39:46 +0000 (01:39 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 8 Jan 2025 17:38:41 +0000 (09:38 -0800)
commitca3c4f646a9fc7d23b30c70e6663eaa38ac746af
treeb17d99a7aa753ecc31f50627e48dcfbc09206de4
parentb8b1e30016260aba338a65fdcc2bfd50933c6f0a
bpf: Move out synchronize_rcu_tasks_trace from mutex CS

Commit ef1b808e3b7c ("bpf: Fix UAF via mismatching bpf_prog/attachment
RCU flavors") resolved a possible UAF issue in uprobes that attach
non-sleepable bpf prog by explicitly waiting for a tasks-trace-RCU grace
period. But, in the current implementation, synchronize_rcu_tasks_trace
is included within the mutex critical section, which increases the
length of the critical section and may affect performance. So let's move
out synchronize_rcu_tasks_trace from mutex CS.

Signed-off-by: Pu Lehui <pulehui@huawei.com>
Reviewed-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20250104013946.1111785-1-pulehui@huaweicloud.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/trace/bpf_trace.c