Skip to content

Commit 87c5441

Browse files
puranjaymohanAlexei Starovoitov
authored andcommitted
bpf: Send signals asynchronously if !preemptible
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: [email protected] Closes: https://lore.kernel.org/all/[email protected]/ Fixes: 1bc7896 ("bpf: Fix deadlock with rq_lock in bpf_send_signal()") Signed-off-by: Puranjay Mohan <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 9fe17b7 commit 87c5441

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

kernel/trace/bpf_trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ static int bpf_send_signal_common(u32 sig, enum pid_type type, struct task_struc
842842
if (unlikely(is_global_init(task)))
843843
return -EPERM;
844844

845-
if (irqs_disabled()) {
845+
if (!preemptible()) {
846846
/* Do an early check on signal validity. Otherwise,
847847
* the error is lost in deferred irq_work.
848848
*/

0 commit comments

Comments
 (0)