bpf: check signal validity in nmi for bpf_send_signal() helper
Subsystems (6)
PATCH 1/1 bpf: check signal validity in nmi for bpf_send_signal() helper
Commit 8b401f9ed244 ("bpf: implement bpf_send_signal() helper") introduced bpf_send_signal() helper. If the context is nmi, the sending signal work needs to be deferred to irq_work. If the signal is invalid, the error will appear in irq_work and it won't be propagated to user.
This patch did an early check in the helper itself to notify user invalid signal, as suggested by Daniel.
--- kernel/trace/bpf_trace.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/trace/bpf_trace.c +6 -0
@@ -600,6 +600,12 @@ BPF_CALL_1(bpf_send_signal, u32, sig)return -EPERM ;if (in_nmi ()) { +/* Do an early check on signal validity. Otherwise, +* the error is lost in deferred irq_work. +*/ +if (unlikely (!valid_signal (sig))) +return -EINVAL ; + work =this_cpu_ptr (&send_signal_work);if (work->irq_work.flags &IRQ_WORK_BUSY )return -EBUSY ;
Signature · 1 line
2.17.1
Quoted 10 lines · Yonghong Song
Commit
8b401f9ed244("bpf: implementbpf_send_signal()helper") introducedbpf_send_signal()helper. If the context is nmi, the sending signal work needs to be deferred toirq_work. If the signal is invalid, the error will appear inirq_workand it won't be propagated to user.This patch did an early check in the helper itself to notify user invalid signal, as suggested by Daniel.
Signed-off-by Yonghong Song <[email protected]>
Applied, thanks!