Re: INFO: trying to register non-static key in is_dynamic_key

From: Dmitry Vyukov
Date: Fri Jun 19 2020 - 06:03:36 EST


On Fri, Jun 19, 2020 at 11:53 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Thu, Jun 18, 2020 at 02:17:15PM -0700, syzbot wrote:
>
> > INFO: trying to register non-static key.
> > the code is fine but needs lockdep annotation.
> > turning off the locking correctness validator.
> > CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.7.0-syzkaller #0
> > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> > Call Trace:
> > <IRQ>
> > __dump_stack lib/dump_stack.c:77 [inline]
> > dump_stack+0xf6/0x16e lib/dump_stack.c:118
> > assign_lock_key kernel/locking/lockdep.c:894 [inline]
> > register_lock_class+0x1442/0x17e0 kernel/locking/lockdep.c:1206
> > arch_stack_walk+0x81/0xf0 arch/x86/kernel/stacktrace.c:25
> > lock_downgrade+0x720/0x720 kernel/locking/lockdep.c:4624
> > is_dynamic_key+0x1b0/0x1b0 kernel/locking/lockdep.c:1176
> > trace_hardirqs_off+0x50/0x1f0 kernel/trace/trace_preemptirq.c:83
> > __lock_acquire+0x101/0x6270 kernel/locking/lockdep.c:4259
> > save_stack+0x32/0x40 mm/kasan/common.c:50
>
> So I'm thinking this is in fact:
>
> spin_lock_irqsave(&depot_lock, flags);
>
> from lib/stackdepot.c:stack_depot_save(), which has gone missing from
> the stack due to tail-call optimizations.
>
> Now depot_lock is declared thusly:
>
> static DEFINE_SPINLOCK(depot_lock);
>
> and I'm trying to figure out how lockdep manages to conclude that isn't
> static storage.... most odd.

Note there also was something wrong with the unwinder:
https://syzkaller.appspot.com/x/log.txt?x=13f305a9100000
(or with something else in the kernel), so potentially it did not
happen save_stack.

In fact, Andrey just reverted this parsing of questionable frames in syzkaller:
https://github.com/google/syzkaller/commit/4d2d1ebee3b65c404576d1c8573a0ec48b03b883
(was done because of what turned out to be ORC unwinder bug, which was fixed).

So potentially we just need to close this is invalid now.