INFO: rcu detected stall in nsim_fib_event_work

From: Ubisectech Sirius
Date: Sat Feb 03 2024 - 01:22:05 EST



Hello.
We are Ubisectech Sirius Team, the vulnerability lab of China ValiantSec. Recently, our team has discovered a issue in Linux kernel 6.8.0-rc2-g6764c317b6bb. Attached to the email were a POC file of the issue.

Stack dump:
rcu: INFO: rcu_preempt detected expedited stalls on CPUs/tasks: { 1-...D } 2656 jiffies s: 1433 root: 0x2/.
rcu: blocking rcu_node structures (internal RCU debug):
Sending NMI from CPU 0 to CPUs 1:
NMI backtrace for cpu 1
CPU: 1 PID: 23 Comm: kworker/1:0 Not tainted 6.8.0-rc2-g6764c317b6bb #22
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
Workqueue: events nsim_fib_event_work
RIP: 0010:match_held_lock+0x7b/0xc0 kernel/locking/lockdep.c:5231
Code: 20 5b 81 e2 ff 1f 00 00 48 39 d0 41 0f 94 c4 44 89 e0 41 5c c3 31 f6 e8 63 fe ff ff 48 85 c0 75 ae 45 31 e4 44 89 e0 5b 41 5c <c3> 41 bc 01 00 00 00 5b 44 89 e0 41 5c c3 90 e8 91 2b e8 f9 85 c0
RSP: 0018:ffffc900004b8df8 EFLAGS: 00000046
RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000001
RDX: 0000000000000000 RSI: ffff88807ec2bad8 RDI: ffff888040edafa8
RBP: ffff88807ec2bad8 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffff888040eda4c0
R13: ffff888040edaf80 R14: 00000000ffffffff R15: ffff888040edafa8
FS: 0000000000000000(0000) GS:ffff88807ec00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fbd8f024210 CR3: 000000002035f000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
<NMI>
</NMI>
<IRQ>
__lock_is_held kernel/locking/lockdep.c:5495 [inline]
lock_is_held_type+0xab/0x140 kernel/locking/lockdep.c:5825
lock_is_held include/linux/lockdep.h:231 [inline]
__run_hrtimer kernel/time/hrtimer.c:1654 [inline]
__hrtimer_run_queues+0x955/0xc10 kernel/time/hrtimer.c:1752
hrtimer_interrupt+0x320/0x7b0 kernel/time/hrtimer.c:1814
local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1065 [inline]
__sysvec_apic_timer_interrupt+0x105/0x400 arch/x86/kernel/apic/apic.c:1082
sysvec_apic_timer_interrupt+0x94/0xb0 arch/x86/kernel/apic/apic.c:1076
</IRQ>
<TASK>
asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:649
RIP: 0010:write_comp_data+0x35/0x80 kernel/kcov.c:236
Code: 8b 14 25 40 c2 03 00 65 8b 05 0f 02 7e 7e a9 00 01 ff 00 74 0f f6 c4 01 74 59 8b 82 fc 15 00 00 85 c0 74 4f 8b 82 d8 15 00 00 <83> f8 03 75 44 48 8b 82 e0 15 00 00 8b 92 dc 15 00 00 48 8b 38 48
RSP: 0018:ffffc9000049f790 EFLAGS: 00000246
RAX: 0000000000000000 RBX: ffffc9000049f7b8 RCX: ffffffff8139a294
RDX: ffff888040eda4c0 RSI: 0000000000000000 RDI: 0000000000000005
RBP: 0000000000000001 R08: 0000000000000005 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffffc9000049f800
R13: ffffc9000049f878 R14: ffff888040eda4c0 R15: ffffc9000049f848
unwind_get_return_address arch/x86/kernel/unwind_orc.c:369 [inline]
unwind_get_return_address+0x84/0xe0 arch/x86/kernel/unwind_orc.c:364
arch_stack_walk+0x9f/0x160 arch/x86/kernel/stacktrace.c:26
stack_trace_save+0x90/0xc0 kernel/stacktrace.c:122
kasan_save_stack+0x24/0x40 mm/kasan/common.c:47
kasan_save_track+0x14/0x30 mm/kasan/common.c:68
poison_kmalloc_redzone mm/kasan/common.c:372 [inline]
__kasan_kmalloc+0xa2/0xb0 mm/kasan/common.c:389
kmalloc include/linux/slab.h:590 [inline]
kzalloc include/linux/slab.h:711 [inline]
nsim_fib4_rt_create drivers/net/netdevsim/fib.c:280 [inline]
nsim_fib4_rt_insert drivers/net/netdevsim/fib.c:426 [inline]
nsim_fib4_event drivers/net/netdevsim/fib.c:464 [inline]
nsim_fib_event drivers/net/netdevsim/fib.c:884 [inline]
nsim_fib_event_work+0x731/0x24b0 drivers/net/netdevsim/fib.c:1492
process_one_work+0x878/0x15c0 kernel/workqueue.c:2633
process_scheduled_works kernel/workqueue.c:2706 [inline]
worker_thread+0x855/0x1200 kernel/workqueue.c:2787
kthread+0x2cc/0x3b0 kernel/kthread.c:388
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:147
ret_from_fork_asm+0x11/0x20 arch/x86/entry/entry_64.S:242
</TASK>
INFO: NMI handler (nmi_cpu_backtrace_handler) took too long to run: 1.791 msecs

Thank you for taking the time to read this email and we look forward to working with you further.









Attachment: poc.c
Description: Binary data