bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next] bpf: check signal validity in nmi for bpf_send_signal() helper
@ 2019-05-25 18:57 Yonghong Song
  2019-05-28  9:24 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Song @ 2019-05-25 18:57 UTC (permalink / raw)
  To: bpf, netdev
  Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, Yonghong Song

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.

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 kernel/trace/bpf_trace.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 70029eafc71f..fe73926a07cd 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf-next] bpf: check signal validity in nmi for bpf_send_signal() helper
  2019-05-25 18:57 [PATCH bpf-next] bpf: check signal validity in nmi for bpf_send_signal() helper Yonghong Song
@ 2019-05-28  9:24 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2019-05-28  9:24 UTC (permalink / raw)
  To: Yonghong Song, bpf, netdev; +Cc: Alexei Starovoitov, kernel-team

On 05/25/2019 08:57 PM, Yonghong Song wrote:
> 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.
> 
> Signed-off-by: Yonghong Song <yhs@fb.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-28  9:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-25 18:57 [PATCH bpf-next] bpf: check signal validity in nmi for bpf_send_signal() helper Yonghong Song
2019-05-28  9:24 ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).