Commit 9d87efb3 authored by Puranjay Mohan's avatar Puranjay Mohan Committed by Xiaomeng Zhang
Browse files

bpf: Send signals asynchronously if !preemptible

mainline inclusion
from mainline-v6.14-rc1
commit 87c544108b612512b254c8f79aa5c0a8546e2cc4
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/IBOK8S

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=87c544108b612512b254c8f79aa5c0a8546e2cc4



--------------------------------

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: default avatar <syzbot+97da3d7e0112d59971de@syzkaller.appspotmail.com>
Closes: https://lore.kernel.org/all/67486b09.050a0220.253251.0084.GAE@google.com/


Fixes: 1bc7896e ("bpf: Fix deadlock with rq_lock in bpf_send_signal()")
Signed-off-by: default avatarPuranjay Mohan <puranjay@kernel.org>
Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20250115103647.38487-1-puranjay@kernel.org


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Conflicts:
	kernel/trace/bpf_trace.c
[The conflicts were due to not merge dee19d6147581]
Signed-off-by: default avatarXiaomeng Zhang <zhangxiaomeng13@huawei.com>
parent 498e3591
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1081,7 +1081,7 @@ static int bpf_send_signal_common(u32 sig, enum pid_type type)
	if (unlikely(is_global_init(current)))
		return -EPERM;

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