Re: Kernel stack read with PTRACE_EVENT_EXIT and io_uring threads

From: Linus Torvalds
Date: Mon Jun 21 2021 - 15:22:29 EST


On Mon, Jun 21, 2021 at 11:59 AM Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> There's a large mess around do_exit() - we have a bunch of
> callers all over arch/*; if nothing else, I very much doubt that really
> want to let tracer play with a thread in the middle of die_if_kernel()
> or similar.

Right you are.

I'm really beginning to hate ptrace_{event,notify}() and those
PTRACE_EVENT_xyz things.

I don't even know what uses them, honestly. How very annoying.

I guess it's easy enough (famous last words) to move the
ptrace_event() call out of do_exit() and into the actual
exit/exit_group system calls, and the signal handling path. The paths
that actually have proper pt_regs.

Looks like sys_exit() and do_group_exit() would be the two places to
do it (do_group_exit() would handle the signal case and
sys_group_exit()).

Linus