RE: [PATCH] proc: Disable /proc/$pid/wchan

From: David Laight
Date: Mon Sep 27 2021 - 05:26:35 EST


From: Mark Rutland
> Sent: 24 September 2021 14:54
>
> On Thu, Sep 23, 2021 at 06:16:16PM -0700, Kees Cook wrote:
> > On Thu, Sep 23, 2021 at 05:22:30PM -0700, Vito Caputo wrote:
> > > Instead of unwinding stacks maybe the kernel should be sticking an
> > > entrypoint address in the current task struct for get_wchan() to
> > > access, whenever userspace enters the kernel?
> >
> > wchan is supposed to show where the kernel is at the instant the
> > get_wchan() happens. (i.e. recording it at syscall entry would just
> > always show syscall entry.)
>
> It's supposed to show where a blocked task is blocked; the "wait
> channel".
>
> I'd wanted to remove get_wchan since it requires cross-task stack
> walking, which is generally painful.
>
> We could instead have the scheduler entrypoints snapshot their caller
> into a field in task_struct. If there are sufficiently few callers, that
> could be an inline wrapper that passes a __func__ string. Otherwise, we
> still need to symbolize.

It ought to be something stashed in the 'wait_queue_head'.
Perhaps defaulting to the address/name of the function that
initialised it.

That would be much nearer the original (pre Linux) semantics.

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)