mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: extended bpf_send_signal_thread with argument
       [not found] <CACT4Y+a7UBQpAY4vwT8Od0JhwbwcDrbJXZ_ULpPfJZ42Ew-yCQ@mail.gmail.com>
@ 2021-02-01  9:22 ` Peter Zijlstra
  2021-02-01  9:42   ` Dmitry Vyukov
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Zijlstra @ 2021-02-01  9:22 UTC (permalink / raw)
  To: Dmitry Vyukov
  Cc: Steven Rostedt, Ingo Molnar, Alexei Starovoitov, Daniel Borkmann,
	andrii, Martin KaFai Lau, David Miller, kpsingh, John Fastabend,
	netdev, bpf, LKML

On Sun, Jan 31, 2021 at 12:14:02PM +0100, Dmitry Vyukov wrote:
> Hi,
> 
> I would like to send a signal from a bpf program invoked from a
> perf_event. There is:

You can't. Sending signals requires sighand lock, and you're not allowed
to take locks from perf_event context.

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

* Re: extended bpf_send_signal_thread with argument
  2021-02-01  9:22 ` extended bpf_send_signal_thread with argument Peter Zijlstra
@ 2021-02-01  9:42   ` Dmitry Vyukov
  2021-02-01 13:33     ` Peter Zijlstra
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Vyukov @ 2021-02-01  9:42 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Steven Rostedt, Ingo Molnar, Alexei Starovoitov, Daniel Borkmann,
	andrii, Martin KaFai Lau, David Miller, kpsingh, John Fastabend,
	netdev, bpf, LKML

On Mon, Feb 1, 2021 at 10:22 AM Peter Zijlstra <peterz@infradead.org> wrote:
>
> On Sun, Jan 31, 2021 at 12:14:02PM +0100, Dmitry Vyukov wrote:
> > Hi,
> >
> > I would like to send a signal from a bpf program invoked from a
> > perf_event. There is:
>
> You can't. Sending signals requires sighand lock, and you're not allowed
> to take locks from perf_event context.


Then we just found a vulnerability because there is
bpf_send_signal_thread which can be attached to perf and it passes the
verifier :)
https://elixir.bootlin.com/linux/v5.11-rc5/source/kernel/trace/bpf_trace.c#L1145

It can defer sending the signal to the exit of irq context:
https://elixir.bootlin.com/linux/v5.11-rc5/source/kernel/trace/bpf_trace.c#L1108
Perhaps this is what makes it work?

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

* Re: extended bpf_send_signal_thread with argument
  2021-02-01  9:42   ` Dmitry Vyukov
@ 2021-02-01 13:33     ` Peter Zijlstra
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Zijlstra @ 2021-02-01 13:33 UTC (permalink / raw)
  To: Dmitry Vyukov
  Cc: Steven Rostedt, Ingo Molnar, Alexei Starovoitov, Daniel Borkmann,
	andrii, Martin KaFai Lau, David Miller, kpsingh, John Fastabend,
	netdev, bpf, LKML

On Mon, Feb 01, 2021 at 10:42:47AM +0100, Dmitry Vyukov wrote:
> On Mon, Feb 1, 2021 at 10:22 AM Peter Zijlstra <peterz@infradead.org> wrote:
> >
> > On Sun, Jan 31, 2021 at 12:14:02PM +0100, Dmitry Vyukov wrote:
> > > Hi,
> > >
> > > I would like to send a signal from a bpf program invoked from a
> > > perf_event. There is:
> >
> > You can't. Sending signals requires sighand lock, and you're not allowed
> > to take locks from perf_event context.
> 
> 
> Then we just found a vulnerability because there is
> bpf_send_signal_thread which can be attached to perf and it passes the
> verifier :)
> https://elixir.bootlin.com/linux/v5.11-rc5/source/kernel/trace/bpf_trace.c#L1145
> 
> It can defer sending the signal to the exit of irq context:
> https://elixir.bootlin.com/linux/v5.11-rc5/source/kernel/trace/bpf_trace.c#L1108
> Perhaps this is what makes it work?

Yes.

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

end of thread, other threads:[~2021-02-01 13:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CACT4Y+a7UBQpAY4vwT8Od0JhwbwcDrbJXZ_ULpPfJZ42Ew-yCQ@mail.gmail.com>
2021-02-01  9:22 ` extended bpf_send_signal_thread with argument Peter Zijlstra
2021-02-01  9:42   ` Dmitry Vyukov
2021-02-01 13:33     ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®