Skip to content

Commit f46d4b9

Browse files
puranjaymohanopsiff
authored andcommitted
bpf: Send signals asynchronously if !preemptible
[ Upstream commit 87c5441 ] 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: 1bc7896 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit 561474803113531dcefeec1fa52a4d3bcf380f92)
1 parent 988ef7c commit f46d4b9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

kernel/trace/bpf_trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ static int bpf_send_signal_common(u32 sig, enum pid_type type)
853853
if (unlikely(is_global_init(current)))
854854
return -EPERM;
855855

856-
if (irqs_disabled()) {
856+
if (!preemptible()) {
857857
/* Do an early check on signal validity. Otherwise,
858858
* the error is lost in deferred irq_work.
859859
*/

0 commit comments

Comments
 (0)