Skip to content

Commit dd40e26

Browse files
yonghong-songEvilAnsh
authored andcommitted
UPSTREAM: 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. Suggested-by: Daniel Borkmann <daniel@iogearbox.net> Change-Id: Ia61521cf20d7011c3606495d1b185866ddd1fc12 Signed-off-by: Yonghong Song <yhs@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Naveen <133593113+elohim-etz@users.noreply.github.com>
1 parent c84e15d commit dd40e26

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

kernel/trace/bpf_trace.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,12 @@ BPF_CALL_1(bpf_send_signal, u32, sig)
650650
return -EPERM;
651651

652652
if (in_nmi()) {
653+
/* Do an early check on signal validity. Otherwise,
654+
* the error is lost in deferred irq_work.
655+
*/
656+
if (unlikely(!valid_signal(sig)))
657+
return -EINVAL;
658+
653659
work = this_cpu_ptr(&send_signal_work);
654660
if (work->irq_work.flags & IRQ_WORK_BUSY)
655661
return -EBUSY;

0 commit comments

Comments
 (0)