inconsistent lock state in __htab_percpu_map_update_elem

Status: upstream: reported C repro on 2026/11/20 20:09
Reported-by: syzbot+4d6f9355963216a76662@syzkaller.appspotmail.com
First crash: 10d, last: 6m

Sample crash report:
================================
WARNING: inconsistent lock state
syzkaller #0 Not tainted
--------------------------------
inconsistent {INITIAL USE} -> {IN-NMI} usage.
syz.0.17/4371 [HC1[1]:SC0[0]:HE0:SE1] takes:
ffff88807daa1418 (&htab->lockdep_key){....}-{2:2}, at: htab_lock_bucket kernel/bpf/hashtab.c:183 [inline]
ffff88807daa1418 (&htab->lockdep_key){....}-{2:2}, at: __htab_percpu_map_update_elem+0x1e1/0x6a0 kernel/bpf/hashtab.c:1227
{INITIAL USE} state was registered at:
  lock_acquire+0x19f/0x400 kernel/locking/lockdep.c:5751
  __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
  _raw_spin_lock_irqsave+0xb0/0x100 kernel/locking/spinlock.c:162
  htab_lock_bucket kernel/bpf/hashtab.c:183 [inline]
  __htab_percpu_map_update_elem+0x1e1/0x6a0 kernel/bpf/hashtab.c:1227
  bpf_prog_331fc8d6c438af7d+0x3e/0x4cc
  bpf_dispatcher_nop_func include/linux/bpf.h:890 [inline]
  __bpf_prog_run include/linux/filter.h:628 [inline]
  bpf_prog_run include/linux/filter.h:635 [inline]
  bpf_overflow_handler+0x1c2/0x4a0 kernel/events/core.c:10318
  __perf_event_overflow+0x35f/0x550 kernel/events/core.c:9536
  perf_bp_event+0x276/0x320 kernel/events/core.c:10505
  hw_breakpoint_handler arch/x86/kernel/hw_breakpoint.c:555 [inline]
  hw_breakpoint_exceptions_notify+0x14d/0x470 arch/x86/kernel/hw_breakpoint.c:586
  notifier_call_chain kernel/notifier.c:83 [inline]
  atomic_notifier_call_chain+0x15d/0x280 kernel/notifier.c:198
  notify_die+0x141/0x1a0 kernel/notifier.c:529
  notify_debug+0x20/0x30 arch/x86/kernel/traps.c:872
  exc_debug_user arch/x86/kernel/traps.c:998 [inline]
  noist_exc_debug+0x73/0x120 arch/x86/kernel/traps.c:1035
  asm_exc_debug+0x2f/0x40 arch/x86/include/asm/idtentry.h:642
irq event stamp: 15126
hardirqs last  enabled at (15125): [<ffffffff89d50e12>] __raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:160 [inline]
hardirqs last  enabled at (15125): [<ffffffff89d50e12>] _raw_spin_unlock_irqrestore+0x82/0x120 kernel/locking/spinlock.c:194
hardirqs last disabled at (15126): [<ffffffff89cb72ee>] exc_debug_kernel arch/x86/kernel/traps.c:893 [inline]
hardirqs last disabled at (15126): [<ffffffff89cb72ee>] exc_debug+0x6e/0x130 arch/x86/kernel/traps.c:1029
softirqs last  enabled at (14876): [<ffffffff8829f04b>] netlink_insert+0xeab/0x11e0 net/netlink/af_netlink.c:589
softirqs last disabled at (14874): [<ffffffff87e817cb>] spin_lock_bh include/linux/spinlock.h:369 [inline]
softirqs last disabled at (14874): [<ffffffff87e817cb>] release_sock+0x2b/0x1b0 net/core/sock.c:3272

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

       CPU0
       ----
  lock(&htab->lockdep_key);
  <Interrupt>
    lock(&htab->lockdep_key);

 *** DEADLOCK ***

no locks held by syz.0.17/4371.

stack backtrace:
CPU: 0 PID: 4371 Comm: syz.0.17 Not tainted syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/06/2026
Call Trace:
 <#DB>
 dump_stack_lvl+0x188/0x250 lib/dump_stack.c:106
 lock_acquire+0x2c3/0x400 kernel/locking/lockdep.c:5742
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0xb0/0x100 kernel/locking/spinlock.c:162
 htab_lock_bucket kernel/bpf/hashtab.c:183 [inline]
 __htab_percpu_map_update_elem+0x1e1/0x6a0 kernel/bpf/hashtab.c:1227
 bpf_prog_331fc8d6c438af7d+0x3e/0x4cc
 bpf_dispatcher_nop_func include/linux/bpf.h:890 [inline]
 __bpf_prog_run include/linux/filter.h:628 [inline]
 bpf_prog_run include/linux/filter.h:635 [inline]
 bpf_overflow_handler+0x1c2/0x4a0 kernel/events/core.c:10318
 __perf_event_overflow+0x35f/0x550 kernel/events/core.c:9536
 perf_bp_event+0x276/0x320 kernel/events/core.c:10505
 hw_breakpoint_handler arch/x86/kernel/hw_breakpoint.c:555 [inline]
 hw_breakpoint_exceptions_notify+0x14d/0x470 arch/x86/kernel/hw_breakpoint.c:586
 notifier_call_chain kernel/notifier.c:83 [inline]
 atomic_notifier_call_chain+0x15d/0x280 kernel/notifier.c:198
 notify_die+0x141/0x1a0 kernel/notifier.c:529
 notify_debug+0x20/0x30 arch/x86/kernel/traps.c:872
 exc_debug_kernel arch/x86/kernel/traps.c:929 [inline]
 exc_debug+0xcf/0x130 arch/x86/kernel/traps.c:1029
 asm_exc_debug+0x1a/0x40 arch/x86/include/asm/idtentry.h:642
RIP: 0010:copy_user_enhanced_fast_string+0xe/0x40 arch/x86/lib/copy_user_64.S:206
Code: 89 d1 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 31 c0 0f 01 ca c3 90 90 90 90 90 90 90 0f 01 cb 83 fa 40 0f 82 70 ff ff ff 89 d1 <f3> a4 31 c0 0f 01 ca c3 90 90 90 90 90 90 90 90 90 90 89 d1 83 f8
RSP: 0018:ffffc900031af7f8 EFLAGS: 00050206
RAX: ffffffff83e8bf01 RBX: 0000000000033fe0 RCX: 0000000000033ea0
RDX: 0000000000033fe0 RSI: 0000200000000340 RDI: ffffc900031e1140
RBP: ffffc900031af950 R08: ffffc90003214fdf R09: 1ffff920006429fb
R10: dffffc0000000000 R11: fffff520006429fc R12: ffffc900031e1000
R13: 0000000000033fff R14: 0000200000000200 R15: 0000000000000000
 </#DB>
 <TASK>
 copy_user_generic arch/x86/include/asm/uaccess_64.h:37 [inline]
 raw_copy_from_user arch/x86/include/asm/uaccess_64.h:52 [inline]
 copyin lib/iov_iter.c:168 [inline]
 _copy_from_iter+0x322/0x1160 lib/iov_iter.c:777
 copy_from_iter include/linux/uio.h:167 [inline]
 copy_from_iter_full include/linux/uio.h:173 [inline]
 memcpy_from_msg include/linux/skbuff.h:3840 [inline]
 netlink_sendmsg+0x758/0xbe0 net/netlink/af_netlink.c:1912
 sock_sendmsg_nosec net/socket.c:706 [inline]
 __sock_sendmsg net/socket.c:718 [inline]
 ____sys_sendmsg+0x5be/0x8f0 net/socket.c:2446
 ___sys_sendmsg+0x236/0x2e0 net/socket.c:2500
 __sys_sendmsg net/socket.c:2529 [inline]
 __do_sys_sendmsg net/socket.c:2538 [inline]
 __se_sys_sendmsg+0x1b7/0x2a0 net/socket.c:2536
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x4c/0xa0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x66/0xd0
RIP: 0033:0x7f317524db59
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe8c70ac18 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
RAX: ffffffffffffffda RBX: 00007f31754d9fa0 RCX: 00007f317524db59
RDX: 0000000000000000 RSI: 0000200000000180 RDI: 0000000000000007
RBP: 00007f31752de18b R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000000000 R14: 00007f31754d9fa0 R15: 00007f31754d9fa0
 </TASK>
----------------
Code disassembly (best guess):
   0:	89 d1                	mov    %edx,%ecx
   2:	c1 e9 03             	shr    $0x3,%ecx
   5:	83 e2 07             	and    $0x7,%edx
   8:	f3 48 a5             	rep movsq %ds:(%rsi),%es:(%rdi)
   b:	89 d1                	mov    %edx,%ecx
   d:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi)
   f:	31 c0                	xor    %eax,%eax
  11:	0f 01 ca             	clac
  14:	c3                   	ret
  15:	90                   	nop
  16:	90                   	nop
  17:	90                   	nop
  18:	90                   	nop
  19:	90                   	nop
  1a:	90                   	nop
  1b:	90                   	nop
  1c:	0f 01 cb             	stac
  1f:	83 fa 40             	cmp    $0x40,%edx
  22:	0f 82 70 ff ff ff    	jb     0xffffff98
  28:	89 d1                	mov    %edx,%ecx
* 2a:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi) <-- trapping instruction
  2c:	31 c0                	xor    %eax,%eax
  2e:	0f 01 ca             	clac
  31:	c3                   	ret
  32:	90                   	nop
  33:	90                   	nop
  34:	90                   	nop
  35:	90                   	nop
  36:	90                   	nop
  37:	90                   	nop
  38:	90                   	nop
  39:	90                   	nop
  3a:	90                   	nop
  3b:	90                   	nop
  3c:	89 d1                	mov    %edx,%ecx
  3e:	83                   	.byte 0x83
  3f:	f8                   	clc

Crashes (15):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/30 23:29 linux-5.15.y 4f2df9a01754 ba8e13b2 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/30 18:29 linux-5.15.y 4f2df9a01754 ba8e13b2 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/29 23:22 linux-5.15.y 4f2df9a01754 e1f06033 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/29 06:12 linux-5.15.y 4f2df9a01754 e1f06033 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/28 07:07 linux-5.15.y 4f2df9a01754 e1f06033 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/28 05:57 linux-5.15.y 4f2df9a01754 e1f06033 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/28 01:24 linux-5.15.y 4f2df9a01754 e1f06033 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/26 18:20 linux-5.15.y 4f2df9a01754 1c78e8c0 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/25 10:27 linux-5.15.y 4f2df9a01754 bda6e3c6 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/25 08:56 linux-5.15.y 4f2df9a01754 bda6e3c6 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/24 23:49 linux-5.15.y 4f2df9a01754 50451a16 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/24 23:00 linux-5.15.y 4f2df9a01754 50451a16 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/22 11:14 linux-5.15.y 29c6cdaac04a b2c69459 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/21 06:38 linux-5.15.y 29c6cdaac04a b2c69459 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
2026/11/20 20:08 linux-5.15.y 29c6cdaac04a 625aa117 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci2-linux-5-15-kasan-perf inconsistent lock state in __htab_percpu_map_update_elem
* Struck through repros no longer work on HEAD.