Re: Kernel stack read with PTRACE_EVENT_EXIT and io_uring threads

Eric W. Biederman
2021-06-21T16:53:09Z

Al Viro <viro@zeniv.linux.org.uk> writes:

> On Mon, Jun 21, 2021 at 01:54:56PM +0000, Al Viro wrote:
>> On Tue, Jun 15, 2021 at 02:58:12PM -0700, Linus Torvalds wrote:
>>
>> > And I think our horrible "kernel threads return to user space when
>> > done" is absolutely horrifically nasty. Maybe of the clever sort, but
>> > mostly of the historical horror sort.
>>
>> How would you prefer to handle that, then? Separate magical path from
>> kernel_execve() to switch to userland? We used to have something of
>> that sort, and that had been a real horror...
>>
>> As it is, it's "kernel thread is spawned at the point similar to
>> ret_from_fork(), runs the payload (which almost never returns) and
>> then proceeds out to userland, same way fork(2) would've done."
>> That way kernel_execve() doesn't have to do anything magical.
>>
>> Al, digging through the old notes and current call graph...
>
> FWIW, the major assumption back then had been that get_signal(),
> signal_delivered() and all associated machinery (including coredumps)
> runs *only* from SIGPENDING/NOTIFY_SIGNAL handling.
>
> And "has complete registers on stack" is only a part of that;
> there was other fun stuff in the area ;-/ Do we want coredumps for
> those, and if we do, will the de_thread stuff work there?

Do we want coredumps from processes that use io_uring? yes
Exactly what we want from io_uring threads is less clear. We can't
really give much that is meaningful beyond the thread ids of the
io_uring threads.

What problems do are you seeing beyond the missing registers on the
stack for kernel threads?

I don't immediately see the connection between coredumps and de_thread.

The function de_thread arranges for the fatal_signal_pending to be true,
and that should work just fine for io_uring threads. The io_uring
threads process the fatal_signal with get_signal and then proceed to
exit eventually calling do_exit.

Eric