KASAN: use-after-free Write in __remove_hrtimer

Status: moderation: reported on 2026/11/16 22:42
Subsystems: kernel
Labels: prio:normal
[Documentation on labels]
Reported-by: syzbot+d95467cb8d8143c8cb16@syzkaller.appspotmail.com
First crash: 4d09h, last: 4d09h
✨ AI-generated root cause summary:

An on-stack struct hrtimer allocated within a task's vmalloc-backed kernel thread stack remained linked in a per-CPU hrtimer_clock_base active timerqueue (timerqueue_linked / rb_root_linked) after the task returned from its syscall and exited. When the thread exited, free_thread_stack() invalidated and freed the stack memory without the timer having been dequeued. During a subsequent timer interrupt, __run_hrtimer() unlinked an expiring timer (node) via timerqueue_linked_del() -> rb_erase_linked(), which attempted to update node->next->prev by writing 8 bytes to offset +0x18 of the next node (at the freed stack address), triggering a use-after-free write.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 9d66f26fefac:

Technical Analysis of Bug Report

1. Crash Site and Exact Operation

The crash occurs in rb_erase_linked() at lib/rbtree.c:457:

bool rb_erase_linked(struct rb_node_linked *node, struct rb_root_linked *root)
{
	if (node->prev)
		node->prev->next = node->next;
	else
		root->rb_leftmost = node->next;

	if (node->next)
		node->next->prev = node->prev;  /* Line 457: Write of size 8 */

	rb_erase(&node->node, &root->rb_root);
	RB_CLEAR_LINKED_NODE(node);

	return !root->rb_leftmost;
}

The call path is: sysvec_apic_timer_interrupt -> hrtimer_interrupt -> __hrtimer_run_queues -> __run_hrtimer -> __remove_hrtimer -> timerqueue_linked_del -> rb_erase_linked.

In __run_hrtimer(), the expiring timer (node) is dequeued from base->active. In rb_erase_linked(), because node->next is non-NULL, the kernel attempts to update node->next->prev = node->prev.

2. Struct Memory Layout and Buggy Address

struct hrtimer embeds struct timerqueue_linked_node node at offset 0, which embeds struct rb_node_linked node at offset 0. The layout of struct rb_node_linked is:

  • struct rb_node node (24 bytes, offsets 0x00..0x17)
  • struct rb_node_linked *prev (8 bytes, offset 0x18)
  • struct rb_node_linked *next (8 bytes, offset 0x20)

The target address written to is 0xffffc90004457d68. This corresponds to: $$\text{Base address of } \texttt{node->next} = 0xffffc90004457d68 - 0x18 = 0xffffc90004457d50$$ Thus, node->next pointed to a struct hrtimer whose start address is 0xffffc90004457d50.

3. Object Lifecycle and Invariant Violation

The memory range 0xffffc90004450000..0xffffc90004458000 was an 8-page (32KB) vmalloc region allocated via kernel_clone -> copy_process -> dup_task_struct -> alloc_thread_stack_node as a thread stack under CONFIG_VMAP_STACK. The address 0xffffc90004457d50 is situated at offset 0x7d50, which is 0x2b0 (688) bytes below the top of the 32KB stack (0xffffc90004458000). This matches a local struct hrtimer (or struct hrtimer_sleeper) allocated on the stack of a top-level syscall handler.

When that task returned from its syscall and exited, free_thread_stack() cached/released the stack and poisoned the vmalloc address range in KASAN shadow with 0xff (KASAN_VMALLOC_INVALID).

However, the timer on that stack was still queued in base->active on the CPU:

  • It was never unlinked via timerqueue_linked_del(), or its links in the doubly-linked list (timerqueue_linked / rb_node_linked) were not properly severed prior to stack deallocation.
  • As a result, when the timer preceding it (node) expired during a subsequent hrtimer_interrupt, rb_erase_linked() attempted to write node->prev into node->next->prev at 0xffffc90004457d68, resulting in a KASAN use-after-free write to the freed vmalloc thread stack.

4. Scope and Unverified Details

  • Verified:
    • The crash mechanism in rb_erase_linked(): unlinking the expiring node writes to node->next->prev.
    • node->next points to a struct hrtimer located at 0xffffc90004457d50 on a 32KB vmalloc thread stack.
    • The thread exited and its stack was poisoned/cached in free_thread_stack(), but its stack timer remained linked in base->active.
  • Inconclusive / Unverified:
    • The exact syscall or caller that armed this specific on-stack hrtimer without cancelling it before exit could not be definitively isolated among the candidates (nanosleep, futex, io_uring, or alarmtimer), as syzkaller was executing compat 32-bit syscalls (__do_compat_sys_ia32_clone) and the thread had already exited by the time of the crash.
    • An alternative possibility is a race or state desynchronization in kernel/time/hrtimer.c (e.g. involving hrtimer_try_to_cancel() returning early if timer->is_queued was observed as 0 while still linked, or an edge case in remove_and_enqueue_same_base() / hrtimer_can_update_in_place()).
▶ ▼ ✨ AI Jobs (3)
ID Workflow Result Correct Bug Created Started Finished Revision
f0e24d37 repro-c 💥 KASAN: use-after-free Write in __remove_hrtimer 2026/11/16 00:02 2026/11/16 00:02 2026/11/16 09:52 819ebe34
31f211df repro-c 💥 KASAN: use-after-free Write in __remove_hrtimer 2026/11/15 00:01 2026/11/15 00:01 2026/11/15 08:22 819ebe34
f21bc4aa assessment-security DenialOfService: ✅ Exploitable: ✅ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ✅ NetworkNeedsSetup: ❌ NetworkTrigger: ❌ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ❌ UserNamespace: ❌ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ KASAN: use-after-free Write in __remove_hrtimer 2026/11/12 21:30 2026/11/12 21:30 2026/11/12 22:31 c0087d7f
▶ ▼ Similar bugs (1)
Kernel Title Rank 🛈 Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: stack-out-of-bounds Read in __remove_hrtimer kernel 17 1 1298d 1298d 0/29 auto-obsoleted due to no activity on 2023/07/27 03:12

Sample crash report:
==================================================================
==================================================================
BUG: KASAN: use-after-free in rb_erase_linked+0x175/0x190 lib/rbtree.c:457
Write of size 8 at addr ffffc90004457d68 by task syz-executor/10454

CPU: 0 UID: 0 PID: 10454 Comm: syz-executor Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0x100/0x190 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0x13d/0x4b0 mm/kasan/report.c:482
 kasan_report+0xdf/0x1c0 mm/kasan/report.c:595
 rb_erase_linked+0x175/0x190 lib/rbtree.c:457
 timerqueue_linked_del include/linux/timerqueue.h:66 [inline]
 __remove_hrtimer+0x116/0x650 kernel/time/hrtimer.c:1183
 __run_hrtimer kernel/time/hrtimer.c:2059 [inline]
 __hrtimer_run_queues+0x339/0x9a0 kernel/time/hrtimer.c:2136
 hrtimer_interrupt+0x441/0xaa0 kernel/time/hrtimer.c:2255
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1051 [inline]
 __sysvec_apic_timer_interrupt+0x109/0x470 arch/x86/kernel/apic/apic.c:1068
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1062 [inline]
 sysvec_apic_timer_interrupt+0x9e/0xc0 arch/x86/kernel/apic/apic.c:1062
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:674
RIP: 0010:check_kcov_mode kernel/kcov.c:181 [inline]
RIP: 0010:__sanitizer_cov_trace_pc+0x40/0x70 kernel/kcov.c:223
Code: ac 13 48 63 c8 a9 00 01 00 ff 74 1e f6 c4 01 74 44 a9 00 00 00 0f 75 3d f7 c1 00 00 00 f0 75 35 8b 82 44 17 00 00 85 c0 74 2b <8b> 82 18 17 00 00 83 f8 02 75 20 48 8b 8a 20 17 00 00 8b 92 1c 17
RSP: 0000:ffffc9000d4bf580 EFLAGS: 00000246
RAX: 8000000000000000 RBX: ffff888015731dc4 RCX: 0000000000000000
RDX: ffff888043e34b00 RSI: ffffffff8be91103 RDI: 0000000000000005
RBP: 00000000ffffffff R08: 0000000000000000 R09: 00000000fffffff8
R10: 0000000000000200 R11: 0000000000000001 R12: 00000000fffffff8
R13: ffff888095731dbf R14: ffffc9000d4bf627 R15: dffffc0000000000
 number+0x983/0xc90 lib/vsprintf.c:578
 vsnprintf+0x30e/0x1300 lib/vsprintf.c:2912
 sprintf+0xcc/0x100 lib/vsprintf.c:3115
 proc_self_get_link+0x11b/0x1f0 fs/proc/self.c:25
 pick_link+0xabc/0x13c0 fs/namei.c:2070
 step_into_slowpath+0x9ba/0xf90 fs/namei.c:2133
 step_into fs/namei.c:2158 [inline]
 walk_component fs/namei.c:2294 [inline]
 link_path_walk+0xe4a/0x1bd0 fs/namei.c:2662
 path_openat+0x1a7/0x23f0 fs/namei.c:5012
 do_file_open+0x20e/0x430 fs/namei.c:5045
 do_sys_openat2+0x163/0x1d0 fs/open.c:1443
 do_sys_open fs/open.c:1449 [inline]
 __do_compat_sys_openat fs/open.c:1511 [inline]
 __se_compat_sys_openat fs/open.c:1509 [inline]
 __ia32_compat_sys_openat+0x12d/0x210 fs/open.c:1509
 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline]
 do_int80_emulation+0x16a/0x670 arch/x86/entry/syscall_32.c:170
 asm_int80_emulation+0x1a/0x20 arch/x86/include/asm/idtentry.h:598
RIP: 0023:0xf710032b
Code: 57 56 53 8b 44 24 14 f6 00 08 75 23 8b 44 24 18 8b 5c 24 1c 8b 4c 24 20 8b 54 24 24 8b 74 24 28 8b 7c 24 2c 8b 6c 24 30 cd 80 <5b> 5e 5f 5d c3 5b 5e 5f 5d e9 f7 a1 ff ff 66 90 66 90 66 90 90 53
RSP: 002b:00000000ff7ffe4c EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00000000ffffff9c RCX: 00000000f71c4fcb
RDX: 0000000000080001 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000286 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>

The buggy address belongs to a 8-page vmalloc region starting at 0xffffc90004450000 allocated at kernel_clone+0x176/0x9d0 kernel/fork.c:2798
The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x57077
flags: 0x4fff00000000000(node=1|zone=1|lastcpupid=0x7ff)
raw: 04fff00000000000 0000000000000000 ffffea00015c1dc8 0000000000000000
raw: 0000000000000000 0000000000000000 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0x29c2(GFP_NOWAIT|__GFP_HIGHMEM|__GFP_IO|__GFP_FS|__GFP_ZERO), pid 5787, tgid 5787 (syz-executor), ts 47729272710
 set_page_owner include/linux/page_owner.h:33 [inline]
 post_alloc_hook+0xfd/0x120 mm/page_alloc.c:1860
 prep_new_page mm/page_alloc.c:1868 [inline]
 get_page_from_freelist+0xdae/0x2c80 mm/page_alloc.c:3950
 __alloc_frozen_pages_noprof+0x2ad/0x31e0 mm/page_alloc.c:5492
 alloc_pages_mpol+0x201/0x560 mm/mempolicy.c:2513
 alloc_pages_noprof+0x1a/0x160 mm/mempolicy.c:2604
 vm_area_alloc_pages mm/vmalloc.c:3726 [inline]
 __vmalloc_area_node mm/vmalloc.c:3948 [inline]
 __vmalloc_node_range_noprof+0x899/0x1440 mm/vmalloc.c:4152
 __vmalloc_node_noprof+0xad/0xf0 mm/vmalloc.c:4213
 alloc_thread_stack_node kernel/fork.c:359 [inline]
 dup_task_struct kernel/fork.c:931 [inline]
 copy_process+0x80b/0x88e0 kernel/fork.c:2150
 kernel_clone+0x176/0x9d0 kernel/fork.c:2798
 __do_compat_sys_ia32_clone+0xd4/0x120 arch/x86/kernel/sys_ia32.c:255
 do_syscall_32_irqs_on arch/x86/entry/syscall_32.c:79 [inline]
 __do_fast_syscall_32+0x14d/0x8e0 arch/x86/entry/syscall_32.c:286
 do_fast_syscall_32+0x32/0x70 arch/x86/entry/syscall_32.c:311
 entry_SYSENTER_compat_after_hwframe+0x84/0x8e
page last free pid 5776 tgid 5776 ts 45120340963 stack trace:
 reset_page_owner include/linux/page_owner.h:26 [inline]
 __free_pages_prepare mm/page_alloc.c:1402 [inline]
 __free_frozen_pages+0x7b1/0x10f0 mm/page_alloc.c:2958
 __folio_put+0x3b4/0x5f0 mm/folio.c:106
 folio_put include/linux/mm.h:2305 [inline]
 put_page include/linux/mm.h:2374 [inline]
 netmem_dec_ref include/net/netmem.h:444 [inline]
 skb_netmem_unref include/linux/skbuff_ref.h:64 [inline]
 skb_release_data+0x60c/0x860 net/core/skbuff.c:1117
 skb_release_all net/core/skbuff.c:1188 [inline]
 napi_consume_skb+0x1a6/0x320 net/core/skbuff.c:1540
 __skb_defer_free_flush net/core/dev.c:7086 [inline]
 __skb_defer_free_flush net/core/dev.c:7074 [inline]
 skb_defer_free_flush+0x16b/0x290 net/core/dev.c:7108
 net_rx_action+0x3ca/0xf20 net/core/dev.c:8186
 handle_softirqs+0x216/0xa20 kernel/softirq.c:669
 do_softirq kernel/softirq.c:569 [inline]
 do_softirq+0xaf/0xf0 kernel/softirq.c:556
 __local_bh_enable_ip+0xff/0x120 kernel/softirq.c:473
 local_bh_enable include/linux/bottom_half.h:33 [inline]
 rcu_read_unlock_bh include/linux/rcupdate.h:923 [inline]
 __dev_queue_xmit+0xa43/0x48d0 net/core/dev.c:5123
 dev_queue_xmit include/linux/netdevice.h:3485 [inline]
 neigh_hh_output include/net/neighbour.h:538 [inline]
 neigh_output include/net/neighbour.h:552 [inline]
 ip_finish_output2+0xfa4/0x2740 net/ipv4/ip_output.c:236
 __ip_finish_output.part.0+0x43b/0x6f0 net/ipv4/ip_output.c:314
 __ip_finish_output net/ipv4/ip_output.c:302 [inline]
 ip_finish_output net/ipv4/ip_output.c:324 [inline]
 NF_HOOK_COND include/linux/netfilter.h:314 [inline]
 ip_output+0x392/0xc00 net/ipv4/ip_output.c:437
 dst_output include/net/dst.h:471 [inline]
 ip_local_out+0x193/0x1f0 net/ipv4/ip_output.c:131
 __ip_queue_xmit+0x876/0x1f50 net/ipv4/ip_output.c:533
 __tcp_transmit_skb+0x34d9/0x4f00 net/ipv4/tcp_output.c:1772

Memory state around the buggy address:
 ffffc90004457c00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffffc90004457c80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
>ffffc90004457d00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
                                                          ^
 ffffc90004457d80: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
 ffffc90004457e00: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
==================================================================
----------------
Code disassembly (best guess):
   0:	ac                   	lods   %ds:(%rsi),%al
   1:	13 48 63             	adc    0x63(%rax),%ecx
   4:	c8 a9 00 01          	enter  $0xa9,$0x1
   8:	00 ff                	add    %bh,%bh
   a:	74 1e                	je     0x2a
   c:	f6 c4 01             	test   $0x1,%ah
   f:	74 44                	je     0x55
  11:	a9 00 00 00 0f       	test   $0xf000000,%eax
  16:	75 3d                	jne    0x55
  18:	f7 c1 00 00 00 f0    	test   $0xf0000000,%ecx
  1e:	75 35                	jne    0x55
  20:	8b 82 44 17 00 00    	mov    0x1744(%rdx),%eax
  26:	85 c0                	test   %eax,%eax
  28:	74 2b                	je     0x55
* 2a:	8b 82 18 17 00 00    	mov    0x1718(%rdx),%eax <-- trapping instruction
  30:	83 f8 02             	cmp    $0x2,%eax
  33:	75 20                	jne    0x55
  35:	48 8b 8a 20 17 00 00 	mov    0x1720(%rdx),%rcx
  3c:	8b                   	.byte 0x8b
  3d:	92                   	xchg   %eax,%edx
  3e:	1c 17                	sbb    $0x17,%al

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/12 14:14 upstream 9d66f26fefac 5c462c66 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: use-after-free Write in __remove_hrtimer
2026/11/12 14:14 upstream 9d66f26fefac 5c462c66 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu-upstream-386 KASAN: use-after-free Read in __remove_hrtimer
* Struck through repros no longer work on HEAD.