]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Fix a possible task gone issue with bpf_send_signal[_thread]() helpers
authorYonghong Song <yhs@fb.com>
Wed, 18 Jan 2023 20:48:15 +0000 (12:48 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Feb 2023 10:28:00 +0000 (11:28 +0100)
commitc7ab729fff48f69364ffd9465a8964cae4ad8cda
tree8d96237575cc7065ddbb9f7edd9161090d8fc715
parentd43491e5a01aa084236f890407acccf1a06f6ce5
bpf: Fix a possible task gone issue with bpf_send_signal[_thread]() helpers

[ Upstream commit bdb7fdb0aca8b96cef9995d3a57e251c2289322f ]

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: 6947ab335019 ("bpf: implement bpf_send_signal() helper")
Tested-by: Hao Sun <sunhao.th@gmail.com>
Reported-by: Hao Sun <sunhao.th@gmail.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/r/20230118204815.3331855-1-yhs@fb.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
kernel/trace/bpf_trace.c