lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 22 Oct 2021 19:01:35 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Mark Rutland <mark.rutland@....com>
Cc:     Kees Cook <keescook@...omium.org>, x86@...nel.org,
        linux-kernel@...r.kernel.org, juri.lelli@...hat.com,
        vincent.guittot@...aro.org, dietmar.eggemann@....com,
        rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de,
        bristot@...hat.com, akpm@...ux-foundation.org,
        zhengqi.arch@...edance.com, linux@...linux.org.uk,
        catalin.marinas@....com, will@...nel.org, mpe@...erman.id.au,
        paul.walmsley@...ive.com, palmer@...belt.com, hca@...ux.ibm.com,
        gor@...ux.ibm.com, borntraeger@...ibm.com,
        linux-arch@...r.kernel.org, ardb@...nel.org
Subject: Re: [PATCH 2/7] stacktrace,sched: Make stack_trace_save_tsk() more
 robust

On Fri, Oct 22, 2021 at 05:54:31PM +0100, Mark Rutland wrote:

> > Pardon my thin understanding of the scheduler, but I assume this change
> > doesn't mean stack_trace_save_tsk() stops working for "current", right?
> > In trying to answer this for myself, I couldn't convince myself what value
> > current->__state have here. Is it one of TASK_(UN)INTERRUPTIBLE ?
> 
> Regardless of that, current->on_rq will be non-zero, so you're right that this
> causes stack_trace_save_tsk() to not work for current, e.g.
> 
> | # cat /proc/self/stack 
> | # wc  /proc/self/stack 
> |         0         0         0 /proc/self/stack
> 
> TBH, I think that (taking a step back from this issue in particular)
> stack_trace_save_tsk() *shouldn't* work for current, and callers *should* be
> forced to explicitly handle current separately from blocked tasks.

That..

> 
> So we could fix this in the stacktrace code with:
> 
> | diff --git a/kernel/stacktrace.c b/kernel/stacktrace.c
> | index a1cdbf8c3ef8..327af9ff2c55 100644
> | --- a/kernel/stacktrace.c
> | +++ b/kernel/stacktrace.c
> | @@ -149,7 +149,10 @@ unsigned int stack_trace_save_tsk(struct task_struct *tsk, unsigned long *store,
> |                 .skip   = skipnr + (current == tsk),
> |         };
> |  
> | -       task_try_func(tsk, try_arch_stack_walk_tsk, &c);
> | +       if (tsk == current)
> | +               try_arch_stack_walk_tsk(tsk, &c);
> | +       else
> | +               task_try_func(tsk, try_arch_stack_walk_tsk, &c);
> |  
> |         return c.len;
> |  }
> 
> ... and we could rename task_try_func() to blocked_task_try_func(), and
> later push the distinction into higher-level callers.

I think I favour this fix if we have to. But that's for next week :-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ