On Fri, Sep 24, 2021 at 07:26:22AM -0700, Kees Cook wrote: > On Fri, Sep 24, 2021 at 02:54:24PM +0100, Mark Rutland wrote: > > 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. > > Right -- this is the "fragile" part I'm worried about. > > > 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. > > Hmm. Does PREEMPT break this? Within the core scheduler functions interrupts should be disabled, and as long as we only update task_struct there we shouldn't have a race. > Can we actually use __builtin_return_address(0) in __schedule? We'd need to do this in a few entry points above __schedule, since the currently get_wchan walks until !in_sched_functions(). It should be possible, though we might need to make sure those the nexus points aren't inlined. Thanks, Mark.