bpf: fix bpf_send_signal()/bpf_send_signal_thread() helper in NMI mode
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest2 patches 2 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bpf: fix bpf_send_signal()/bpf_send_signal_thread() helper in NMI modekernel/ | +36 | 2 replies | |
| 2/2 | bpf: avoid irq_work for bpf_send_signal() if CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHGkernel/ | +35 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH bpf 0/2] bpf: fix bpf_send_signal()/bpf_send_signal_thread() helper in NMI mode
Commit 8b401f9ed244 ("bpf: implement bpf_send_signal() helper") introduced bpf_send_signal() helper and Commit 8482941f0906 ("bpf: Add bpf_send_signal_thread() helper") added bpf_send_signal_thread() helper. Both helpers try to send a signel to current process or thread.
When the bpf prog, hence the helper, is called in nmi mode, the actual sending of signal is delayed to an irq_work. But this is still not always safe as nmi could happen in scheduler with scheduler lock is taken, later on the routine to send signal may tries to acquire the same spinlock and caused a deadlock. See patch #1 for more detailed description of the problem and how to use task_work to solve the problem.
Patch #2 is an optimization. task_work can be set up directly in nmi mode if CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG is true. Indeed, CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG is true for most modern architectures.
Patch #1 is for bpf tree. Patch #2 is intended for bpf-next tree.
Yonghong Song (2):
bpf: fix bpf_send_signal()/bpf_send_signal_thread() helper in NMI mode
bpf: avoid irq_work for bpf_send_signal() if
CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG
kernel/trace/bpf_trace.c | 82 ++++++++++++++++++++++++++++++++-------- 1 file changed, 67 insertions(+), 15 deletions(-)
Signature · 1 line
2.17.1