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

From: Peter Zijlstra
Date: Fri Jun 19 2020 - 05:54:01 EST


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.