“c7eea6f7adca4501d2c2db7f0f7c9dc88efac95e”上不存在“fs/xfs/xfs_icache.c”
提交 d3b5c638 编写于 作者: Y Yonghong Song 提交者: zhaoxiaoqiang11

bpf: Fix a possible task gone issue with bpf_send_signal[_thread]() helpers

stable inclusion
from stable-v5.10.168
commit 1b1f56cc0eaa104a8e0b8207a45dbe71687b5015
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7URR4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1b1f56cc0eaa104a8e0b8207a45dbe71687b5015

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

[ Upstream commit bdb7fdb0 ]

In current bpf_send_signal() and bpf_send_signal_thread() helper
implementation, irq_work is used to handle nmi context. Hao Sun
reported in [1] that the current task at the entry of the helper
might be gone during irq_work callback processing. To fix the issue,
a reference is acquired for the current task before enqueuing into
the irq_work so that the queued task is still available during
irq_work callback processing.

  [1] https://lore.kernel.org/bpf/20230109074425.12556-1-sunhao.th@gmail.com/

Fixes: 8b401f9e ("bpf: implement bpf_send_signal() helper")
Tested-by: NHao Sun <sunhao.th@gmail.com>
Reported-by: NHao Sun <sunhao.th@gmail.com>
Signed-off-by: NYonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20230118204815.3331855-1-yhs@fb.comSigned-off-by: NAlexei Starovoitov <ast@kernel.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: Nzhaoxiaoqiang11 <zhaoxiaoqiang11@jd.com>
上级 cb892b45
...@@ -1055,6 +1055,7 @@ static void do_bpf_send_signal(struct irq_work *entry) ...@@ -1055,6 +1055,7 @@ static void do_bpf_send_signal(struct irq_work *entry)
work = container_of(entry, struct send_signal_irq_work, irq_work); work = container_of(entry, struct send_signal_irq_work, irq_work);
group_send_sig_info(work->sig, SEND_SIG_PRIV, work->task, work->type); group_send_sig_info(work->sig, SEND_SIG_PRIV, work->task, work->type);
put_task_struct(work->task);
} }
static int bpf_send_signal_common(u32 sig, enum pid_type type) static int bpf_send_signal_common(u32 sig, enum pid_type type)
...@@ -1091,7 +1092,7 @@ static int bpf_send_signal_common(u32 sig, enum pid_type type) ...@@ -1091,7 +1092,7 @@ static int bpf_send_signal_common(u32 sig, enum pid_type type)
* to the irq_work. The current task may change when queued * to the irq_work. The current task may change when queued
* irq works get executed. * irq works get executed.
*/ */
work->task = current; work->task = get_task_struct(current);
work->sig = sig; work->sig = sig;
work->type = type; work->type = type;
irq_work_queue(&work->irq_work); irq_work_queue(&work->irq_work);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册