]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Send signals asynchronously if !preemptible
authorPuranjay Mohan <puranjay@kernel.org>
Wed, 15 Jan 2025 10:36:47 +0000 (10:36 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 15 Jan 2025 21:44:08 +0000 (13:44 -0800)
BPF programs can execute in all kinds of contexts and when a program
running in a non-preemptible context uses the bpf_send_signal() kfunc,
it will cause issues because this kfunc can sleep.
Change `irqs_disabled()` to `!preemptible()`.

Reported-by: syzbot+97da3d7e0112d59971de@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/67486b09.050a0220.253251.0084.GAE@google.com/
Fixes: 1bc7896e9ef4 ("bpf: Fix deadlock with rq_lock in bpf_send_signal()")
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Acked-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20250115103647.38487-1-puranjay@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/trace/bpf_trace.c

index fc657c0eeb3e745fc39e7c35ec677213f0549e32..71c1c02ca7a3e221016f171429c92279a8be1c46 100644 (file)
@@ -842,7 +842,7 @@ static int bpf_send_signal_common(u32 sig, enum pid_type type, struct task_struc
        if (unlikely(is_global_init(task)))
                return -EPERM;
 
-       if (irqs_disabled()) {
+       if (!preemptible()) {
                /* Do an early check on signal validity. Otherwise,
                 * the error is lost in deferred irq_work.
                 */