Re: extended bpf_send_signal_thread with argument

3 messages, 2 authors, 2021-02-01 · open the first message on its own page

Re: extended bpf_send_signal_thread with argument

From: Peter Zijlstra <peterz@infradead.org>
Date: 2021-02-01 09:23:55

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.

Re: extended bpf_send_signal_thread with argument

From: Dmitry Vyukov <dvyukov@google.com>
Date: 2021-02-01 09:43:44

On Mon, Feb 1, 2021 at 10:22 AM Peter Zijlstra [off-list ref] wrote:
On Sun, Jan 31, 2021 at 12:14:02PM +0100, Dmitry Vyukov wrote:
quoted
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?

Re: extended bpf_send_signal_thread with argument

From: Peter Zijlstra <peterz@infradead.org>
Date: 2021-02-01 13:35:14

On Mon, Feb 01, 2021 at 10:42:47AM +0100, Dmitry Vyukov wrote:
On Mon, Feb 1, 2021 at 10:22 AM Peter Zijlstra [off-list ref] wrote:
quoted
On Sun, Jan 31, 2021 at 12:14:02PM +0100, Dmitry Vyukov wrote:
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help