syzbot


inconsistent lock state in ima_process_queued_keys

Status: closed as invalid on 2020/03/07 20:52
Subsystems: integrity lsm
[Documentation on labels]
Reported-by: syzbot+a4a503d7f37292ae1664@syzkaller.appspotmail.com
Fix commit: IMA: inconsistent lock state in ima_process_queued_keys
First crash: 1776d, last: 1753d
Discussions (2)
Title Replies (including bot) Last reply
inconsistent lock state in ima_process_queued_keys 6 (8) 2020/01/18 05:22
[PATCH] IMA: inconsistent lock state in ima_process_queued_keys 2 (2) 2020/01/16 13:10

Sample crash report:
================================
WARNING: inconsistent lock state
5.5.0-rc6-next-20200116-syzkaller #0 Not tainted
--------------------------------
inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage.
swapper/0/0 [HC0[0]:SC1[1]:HE1:SE0] takes:
ffffffff8a03ce58 (ima_keys_lock){+.?.}, at: spin_lock include/linux/spinlock.h:338 [inline]
ffffffff8a03ce58 (ima_keys_lock){+.?.}, at: ima_process_queued_keys+0x4f/0x320 security/integrity/ima/ima_asymmetric_keys.c:144
{SOFTIRQ-ON-W} state was registered at:
  lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4484
  __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
  _raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:151
  spin_lock include/linux/spinlock.h:338 [inline]
  ima_queue_key security/integrity/ima/ima_asymmetric_keys.c:111 [inline]
  ima_post_key_create_or_update+0x234/0x470 security/integrity/ima/ima_asymmetric_keys.c:194
  key_create_or_update+0x6b8/0xcb0 security/keys/key.c:944
  load_system_certificate_list+0x1ba/0x25e certs/system_keyring.c:161
  do_one_initcall+0x120/0x820 init/main.c:1109
  do_initcall_level init/main.c:1182 [inline]
  do_initcalls init/main.c:1198 [inline]
  do_basic_setup init/main.c:1218 [inline]
  kernel_init_freeable+0x522/0x5d0 init/main.c:1402
  kernel_init+0x12/0x1bf init/main.c:1309
  ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
irq event stamp: 820890
hardirqs last  enabled at (820890): [<ffffffff87ee0813>] __raw_spin_unlock_irq include/linux/spinlock_api_smp.h:168 [inline]
hardirqs last  enabled at (820890): [<ffffffff87ee0813>] _raw_spin_unlock_irq+0x23/0x80 kernel/locking/spinlock.c:199
hardirqs last disabled at (820889): [<ffffffff87ee09fa>] __raw_spin_lock_irq include/linux/spinlock_api_smp.h:126 [inline]
hardirqs last disabled at (820889): [<ffffffff87ee09fa>] _raw_spin_lock_irq+0x3a/0x80 kernel/locking/spinlock.c:167
softirqs last  enabled at (820412): [<ffffffff8147765c>] _local_bh_enable+0x1c/0x30 kernel/softirq.c:162
softirqs last disabled at (820413): [<ffffffff8147a05b>] invoke_softirq kernel/softirq.c:373 [inline]
softirqs last disabled at (820413): [<ffffffff8147a05b>] irq_exit+0x19b/0x1e0 kernel/softirq.c:413

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(ima_keys_lock);
  <Interrupt>
    lock(ima_keys_lock);

 *** DEADLOCK ***

1 lock held by swapper/0/0:
 #0: ffffc90000007d50 ((&ima_key_queue_timer)){+.-.}, at: lockdep_copy_map include/linux/lockdep.h:172 [inline]
 #0: ffffc90000007d50 ((&ima_key_queue_timer)){+.-.}, at: call_timer_fn+0xe0/0x780 kernel/time/timer.c:1394

stack backtrace:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.5.0-rc6-next-20200116-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+0x197/0x210 lib/dump_stack.c:118
 print_usage_bug.cold+0x327/0x378 kernel/locking/lockdep.c:3100
 valid_state kernel/locking/lockdep.c:3111 [inline]
 mark_lock_irq kernel/locking/lockdep.c:3308 [inline]
 mark_lock+0xbb4/0x1220 kernel/locking/lockdep.c:3665
 mark_usage kernel/locking/lockdep.c:3565 [inline]
 __lock_acquire+0x1e8e/0x4a00 kernel/locking/lockdep.c:3908
 lock_acquire+0x190/0x410 kernel/locking/lockdep.c:4484
 __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
 _raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:151
 spin_lock include/linux/spinlock.h:338 [inline]
 ima_process_queued_keys+0x4f/0x320 security/integrity/ima/ima_asymmetric_keys.c:144
 ima_timer_handler+0x15/0x20 security/integrity/ima/ima_asymmetric_keys.c:46
 call_timer_fn+0x1ac/0x780 kernel/time/timer.c:1404
 expire_timers kernel/time/timer.c:1449 [inline]
 __run_timers kernel/time/timer.c:1773 [inline]
 __run_timers kernel/time/timer.c:1740 [inline]
 run_timer_softirq+0x6c3/0x1790 kernel/time/timer.c:1786
 __do_softirq+0x262/0x98c kernel/softirq.c:292
 invoke_softirq kernel/softirq.c:373 [inline]
 irq_exit+0x19b/0x1e0 kernel/softirq.c:413
 exiting_irq arch/x86/include/asm/apic.h:536 [inline]
 smp_apic_timer_interrupt+0x1a3/0x610 arch/x86/kernel/apic/apic.c:1137
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:829
 </IRQ>
RIP: 0010:native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:61
Code: a8 3a c6 f9 eb 8a cc cc cc cc cc cc e9 07 00 00 00 0f 00 2d 14 92 5a 00 f4 c3 66 90 e9 07 00 00 00 0f 00 2d 04 92 5a 00 fb f4 <c3> cc 55 48 89 e5 41 57 41 56 41 55 41 54 53 e8 de 0b 75 f9 e8 89
RSP: 0018:ffffffff89a07cd0 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff13
RAX: 1ffffffff1367752 RBX: ffffffff89a7a780 RCX: 0000000000000000
RDX: dffffc0000000000 RSI: 0000000000000006 RDI: ffffffff89a7b01c
RBP: ffffffff89a07d00 R08: ffffffff89a7a780 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: dffffc0000000000
R13: ffffffff8aa52e40 R14: 0000000000000000 R15: 0000000000000000
 arch_cpu_idle+0xa/0x10 arch/x86/kernel/process.c:686
 default_idle_call+0x84/0xb0 kernel/sched/idle.c:94
 cpuidle_idle_call kernel/sched/idle.c:154 [inline]
 do_idle+0x3c8/0x6e0 kernel/sched/idle.c:269
 cpu_startup_entry+0x1b/0x20 kernel/sched/idle.c:361
 rest_init+0x23b/0x371 init/main.c:616
 arch_call_rest_init+0xe/0x1b
 start_kernel+0xd24/0xd63 init/main.c:955
 x86_64_start_reservations+0x29/0x2b arch/x86/kernel/head64.c:490
 x86_64_start_kernel+0x77/0x7b arch/x86/kernel/head64.c:471
 secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:242

Crashes (32987):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/02/05 11:28 linux-next 2747d5fdab78 93e5e335 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/02/04 19:59 linux-next 2747d5fdab78 93e5e335 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/02/03 02:49 linux-next 2747d5fdab78 93e5e335 .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/31 10:52 linux-next 2747d5fdab78 5ed23f9a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/31 09:54 linux-next 2747d5fdab78 5ed23f9a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/31 05:25 linux-next 2747d5fdab78 5ed23f9a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/30 23:09 linux-next 2747d5fdab78 5ed23f9a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/30 17:35 linux-next 2747d5fdab78 5ed23f9a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/30 04:47 linux-next 2747d5fdab78 5ed23f9a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/30 04:06 linux-next 2747d5fdab78 5ed23f9a .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/28 15:48 linux-next 2747d5fdab78 56cd6c9b .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/27 07:58 linux-next 2747d5fdab78 dd56146d .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/01/26 14:52 linux-next 2747d5fdab78 f4e7270e .config console log report C ci-upstream-linux-next-kasan-gce-root
2020/01/18 03:13 linux-next 2747d5fdab78 3de7aabb .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2020/02/05 06:32 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/05 04:56 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/04 21:17 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/04 13:32 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/04 09:37 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/04 08:14 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/04 03:31 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/04 01:55 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/03 22:38 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/03 16:26 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/03 07:37 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/03 06:25 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/03 04:50 linux-next 2747d5fdab78 93e5e335 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/02 09:39 linux-next 2747d5fdab78 2274ad39 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/02 07:45 linux-next 2747d5fdab78 2274ad39 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/31 13:30 linux-next 2747d5fdab78 5ed23f9a .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/30 20:47 linux-next 2747d5fdab78 5ed23f9a .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/30 19:36 linux-next 2747d5fdab78 5ed23f9a .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/30 07:51 linux-next 2747d5fdab78 5ed23f9a .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/29 10:40 linux-next 2747d5fdab78 c8e81ce4 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/28 12:51 linux-next 2747d5fdab78 56cd6c9b .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/27 13:51 linux-next 2747d5fdab78 dd56146d .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/27 13:10 linux-next 2747d5fdab78 dd56146d .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/27 12:12 linux-next 2747d5fdab78 dd56146d .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/27 10:33 linux-next 2747d5fdab78 dd56146d .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/27 06:26 linux-next 2747d5fdab78 dd56146d .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/01/25 23:17 linux-next 2747d5fdab78 2e95ab33 .config console log report syz ci-upstream-linux-next-kasan-gce-root
2020/02/06 04:21 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 03:56 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 03:32 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 03:06 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 02:50 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 02:35 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 02:20 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 02:04 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 01:49 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 01:32 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 01:16 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 00:58 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 00:42 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 00:24 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/06 00:10 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 23:51 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 23:35 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 23:20 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 23:05 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 22:50 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 22:34 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 22:19 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 22:03 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 21:44 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 21:28 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 21:11 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 20:55 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 20:37 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 20:22 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 20:07 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 19:53 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 19:37 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 19:23 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 19:08 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 18:52 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 18:37 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 18:22 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 18:07 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 17:52 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 17:36 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/02/05 17:21 linux-next 2747d5fdab78 662cf49a .config console log report ci-upstream-linux-next-kasan-gce-root
2020/01/14 13:45 linux-next 1b851f985f51 32881205 .config console log report ci-upstream-linux-next-kasan-gce-root
2020/01/14 07:04 linux-next 1b851f985f51 32881205 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.