]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
bpf: check signal validity in nmi for bpf_send_signal() helper
authorYonghong Song <yhs@fb.com>
Sat, 25 May 2019 18:57:53 +0000 (11:57 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 28 May 2019 08:51:33 +0000 (10:51 +0200)
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>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/trace/bpf_trace.c

index 70029eafc71f9677940aa9ff714255dbb51e4cb4..fe73926a07cde2f94fb4a26bdb7a59d1e409af75 100644 (file)
@@ -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;