syzbot


KASAN: use-after-free Read in tcp_retransmit_timer (3)

Status: upstream: reported on 2024/12/03 12:52
Reported-by: syzbot+d64695bbb840637479fa@syzkaller.appspotmail.com
First crash: 18d, last: 18d
Similar bugs (14)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in tcp_retransmit_timer (3) 1 783d 783d 0/1 auto-obsoleted due to no activity on 2023/02/27 17:38
linux-4.14 KASAN: slab-out-of-bounds Read in tcp_retransmit_timer 5 1322d 1397d 0/1 auto-closed as invalid on 2021/09/06 04:07
linux-6.1 KASAN: use-after-free Read in tcp_retransmit_timer 14 266d 284d 0/3 auto-obsoleted due to no activity on 2024/06/08 21:34
linux-5.15 KASAN: use-after-free Read in tcp_retransmit_timer (2) 13 239d 425d 0/3 auto-obsoleted due to no activity on 2024/08/04 05:25
linux-4.19 KASAN: use-after-free Read in tcp_retransmit_timer 2 1821d 1822d 0/1 auto-closed as invalid on 2020/04/25 09:53
upstream KASAN: use-after-free Read in tcp_retransmit_timer (2) net 1 2106d 2106d 0/28 closed as invalid on 2019/04/19 21:45
linux-6.1 KASAN: use-after-free Read in tcp_retransmit_timer (2) 1 176d 176d 0/3 auto-obsoleted due to no activity on 2024/10/06 20:00
upstream KASAN: use-after-free Read in tcp_retransmit_timer (5) net C unreliable 16000 750d 1762d 22/28 fixed on 2023/02/24 13:50
linux-4.19 KASAN: use-after-free Read in tcp_retransmit_timer (2) 6 1251d 1418d 0/1 auto-closed as invalid on 2021/11/16 03:14
upstream KASAN: use-after-free Read in tcp_retransmit_timer (3) net 5 2018d 2038d 0/28 closed as invalid on 2019/07/01 18:06
upstream KASAN: use-after-free Read in tcp_retransmit_timer net 4 2149d 2262d 0/28 closed as invalid on 2019/03/10 18:51
linux-4.19 KASAN: slab-out-of-bounds Read in tcp_retransmit_timer 9 929d 1108d 0/1 auto-obsoleted due to no activity on 2022/10/04 11:51
upstream KASAN: use-after-free Read in tcp_retransmit_timer (4) net 2 1963d 1963d 0/28 closed as invalid on 2019/10/03 04:18
linux-5.15 KASAN: use-after-free Read in tcp_retransmit_timer 76 534d 642d 0/3 auto-obsoleted due to no activity on 2023/09/14 02:10

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in tcp_retransmit_timer+0x73d/0x2800 net/ipv4/tcp_timer.c:546
Read of size 8 at addr ffff88805b691f00 by task kworker/u4:2/34

CPU: 0 PID: 34 Comm: kworker/u4:2 Not tainted 6.1.119-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/13/2024
Workqueue: netns cleanup_net
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1e3/0x2cb lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x15f/0x4f0 mm/kasan/report.c:395
 kasan_report+0x136/0x160 mm/kasan/report.c:495
 tcp_retransmit_timer+0x73d/0x2800 net/ipv4/tcp_timer.c:546
 tcp_write_timer+0x12e/0x280 net/ipv4/tcp_timer.c:676
 call_timer_fn+0x1ad/0x6b0 kernel/time/timer.c:1504
 expire_timers kernel/time/timer.c:1549 [inline]
 __run_timers+0x67c/0x890 kernel/time/timer.c:1820
 run_timer_softirq+0x63/0xf0 kernel/time/timer.c:1833
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:571
 __do_softirq kernel/softirq.c:605 [inline]
 invoke_softirq kernel/softirq.c:445 [inline]
 __irq_exit_rcu+0x157/0x240 kernel/softirq.c:654
 irq_exit_rcu+0x5/0x20 kernel/softirq.c:666
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1118 [inline]
 sysvec_apic_timer_interrupt+0xa0/0xc0 arch/x86/kernel/apic/apic.c:1118
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x16/0x20 arch/x86/include/asm/idtentry.h:691
RIP: 0010:lock_acquire+0x26f/0x5a0 kernel/locking/lockdep.c:5666
Code: 2b 00 74 08 4c 89 f7 e8 af 81 77 00 f6 44 24 61 02 0f 85 84 01 00 00 41 f7 c7 00 02 00 00 74 01 fb 48 c7 44 24 40 0e 36 e0 45 <4b> c7 44 25 00 00 00 00 00 43 c7 44 25 09 00 00 00 00 43 c7 44 25
RSP: 0018:ffffc90000ab7480 EFLAGS: 00000206
RAX: 0000000000000001 RBX: 1ffff92000156e9c RCX: ffffffff816b5e82
RDX: dffffc0000000000 RSI: ffffffff8b0c1340 RDI: ffffffff8b5e6200
RBP: ffffc90000ab75c8 R08: dffffc0000000000 R09: fffffbfff224984e
R10: 0000000000000000 R11: dffffc0000000001 R12: 1ffff92000156e98
R13: dffffc0000000000 R14: ffffc90000ab74e0 R15: 0000000000000246
 __raw_spin_lock include/linux/spinlock_api_smp.h:133 [inline]
 _raw_spin_lock+0x2a/0x40 kernel/locking/spinlock.c:154
 spin_lock include/linux/spinlock.h:351 [inline]
 kernfs_put+0x2c9/0x4a0 fs/kernfs/dir.c:565
 kernfs_remove_by_name_ns+0xdc/0x150 fs/kernfs/dir.c:1667
 kernfs_remove_by_name include/linux/kernfs.h:622 [inline]
 remove_files fs/sysfs/group.c:28 [inline]
 sysfs_remove_group+0xfa/0x2a0 fs/sysfs/group.c:288
 sysfs_remove_groups+0x50/0xa0 fs/sysfs/group.c:312
 device_remove_groups drivers/base/core.c:2751 [inline]
 device_remove_attrs+0x236/0x290 drivers/base/core.c:2971
 device_del+0x6da/0xbd0 drivers/base/core.c:3876
 unregister_netdevice_many+0x12bf/0x17a0 net/core/dev.c:10917
 default_device_exit_batch+0x956/0x9d0 net/core/dev.c:11403
 ops_exit_list net/core/net_namespace.c:177 [inline]
 cleanup_net+0x763/0xb60 net/core/net_namespace.c:604
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
 </TASK>

Allocated by task 4252:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 __kasan_slab_alloc+0x65/0x70 mm/kasan/common.c:328
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook+0x52/0x3a0 mm/slab.h:737
 slab_alloc_node mm/slub.c:3398 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x10c/0x2d0 mm/slub.c:3422
 kmem_cache_zalloc include/linux/slab.h:683 [inline]
 net_alloc net/core/net_namespace.c:413 [inline]
 copy_net_ns+0x140/0x5d0 net/core/net_namespace.c:468
 create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226
 ksys_unshare+0x531/0xa40 kernel/fork.c:3201
 __do_sys_unshare kernel/fork.c:3272 [inline]
 __se_sys_unshare kernel/fork.c:3270 [inline]
 __x64_sys_unshare+0x34/0x40 kernel/fork.c:3270
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Freed by task 34:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4b/0x70 mm/kasan/common.c:52
 kasan_save_free_info+0x27/0x40 mm/kasan/generic.c:516
 ____kasan_slab_free+0xd6/0x120 mm/kasan/common.c:236
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 kmem_cache_free+0x292/0x510 mm/slub.c:3683
 net_free net/core/net_namespace.c:442 [inline]
 cleanup_net+0xab5/0xb60 net/core/net_namespace.c:625
 process_one_work+0x8a9/0x11d0 kernel/workqueue.c:2292
 worker_thread+0xa47/0x1200 kernel/workqueue.c:2439
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 insert_work+0x54/0x3d0 kernel/workqueue.c:1361
 __queue_work+0xb4b/0xf90 kernel/workqueue.c:1520
 call_timer_fn+0x1ad/0x6b0 kernel/time/timer.c:1504
 expire_timers kernel/time/timer.c:1544 [inline]
 __run_timers+0x6a8/0x890 kernel/time/timer.c:1820
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:571
 run_ksoftirqd+0xc6/0x120 kernel/softirq.c:938
 smpboot_thread_fn+0x52c/0xa30 kernel/smpboot.c:164
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

Second to last potentially related work creation:
 kasan_save_stack+0x3b/0x60 mm/kasan/common.c:45
 __kasan_record_aux_stack+0xb0/0xc0 mm/kasan/generic.c:486
 insert_work+0x54/0x3d0 kernel/workqueue.c:1361
 __queue_work+0xb4b/0xf90 kernel/workqueue.c:1520
 call_timer_fn+0x1ad/0x6b0 kernel/time/timer.c:1504
 expire_timers kernel/time/timer.c:1544 [inline]
 __run_timers+0x6a8/0x890 kernel/time/timer.c:1820
 handle_softirqs+0x2ee/0xa40 kernel/softirq.c:571
 run_ksoftirqd+0xc6/0x120 kernel/softirq.c:938
 smpboot_thread_fn+0x52c/0xa30 kernel/smpboot.c:164
 kthread+0x28d/0x320 kernel/kthread.c:376
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295

The buggy address belongs to the object at ffff88805b691c40
 which belongs to the cache net_namespace of size 6976
The buggy address is located 704 bytes inside of
 6976-byte region [ffff88805b691c40, ffff88805b693780)

The buggy address belongs to the physical page:
page:ffffea00016da400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5b690
head:ffffea00016da400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0xfff00000010200(slab|head|node=0|zone=1|lastcpupid=0x7ff)
raw: 00fff00000010200 0000000000000000 dead000000000122 ffff888140009500
raw: 0000000000000000 0000000080040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 3, migratetype Unmovable, gfp_mask 0xd20c0(__GFP_IO|__GFP_FS|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 4251, tgid 4251 (syz-executor), ts 59032329131, free_ts 59031287513
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook+0x18d/0x1b0 mm/page_alloc.c:2517
 prep_new_page mm/page_alloc.c:2524 [inline]
 get_page_from_freelist+0x3731/0x38d0 mm/page_alloc.c:4313
 __alloc_pages+0x28d/0x770 mm/page_alloc.c:5590
 alloc_slab_page+0x6a/0x150 mm/slub.c:1794
 allocate_slab mm/slub.c:1939 [inline]
 new_slab+0x84/0x2d0 mm/slub.c:1992
 ___slab_alloc+0xc20/0x1270 mm/slub.c:3180
 __slab_alloc mm/slub.c:3279 [inline]
 slab_alloc_node mm/slub.c:3364 [inline]
 slab_alloc mm/slub.c:3406 [inline]
 __kmem_cache_alloc_lru mm/slub.c:3413 [inline]
 kmem_cache_alloc+0x1a5/0x2d0 mm/slub.c:3422
 kmem_cache_zalloc include/linux/slab.h:683 [inline]
 net_alloc net/core/net_namespace.c:413 [inline]
 copy_net_ns+0x140/0x5d0 net/core/net_namespace.c:468
 create_new_namespaces+0x425/0x7a0 kernel/nsproxy.c:110
 unshare_nsproxy_namespaces+0x11e/0x170 kernel/nsproxy.c:226
 ksys_unshare+0x531/0xa40 kernel/fork.c:3201
 __do_sys_unshare kernel/fork.c:3272 [inline]
 __se_sys_unshare kernel/fork.c:3270 [inline]
 __x64_sys_unshare+0x34/0x40 kernel/fork.c:3270
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1444 [inline]
 free_pcp_prepare mm/page_alloc.c:1494 [inline]
 free_unref_page_prepare+0xf63/0x1120 mm/page_alloc.c:3369
 free_unref_page+0x33/0x3e0 mm/page_alloc.c:3464
 free_large_kmalloc+0xfb/0x190 mm/slab_common.c:913
 skb_free_head net/core/skbuff.c:762 [inline]
 skb_release_data+0x5de/0x7a0 net/core/skbuff.c:791
 skb_release_all net/core/skbuff.c:856 [inline]
 __kfree_skb net/core/skbuff.c:870 [inline]
 consume_skb+0xa3/0x140 net/core/skbuff.c:1035
 netlink_recvmsg+0x61a/0x1180 net/netlink/af_netlink.c:1937
 ____sys_recvmsg+0x285/0x530
 ___sys_recvmsg net/socket.c:2780 [inline]
 __sys_recvmsg+0x2e9/0x3d0 net/socket.c:2810
 do_syscall_x64 arch/x86/entry/common.c:51 [inline]
 do_syscall_64+0x3b/0xb0 arch/x86/entry/common.c:81
 entry_SYSCALL_64_after_hwframe+0x68/0xd2

Memory state around the buggy address:
 ffff88805b691e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805b691e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88805b691f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88805b691f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88805b692000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
----------------
Code disassembly (best guess):
   0:	2b 00                	sub    (%rax),%eax
   2:	74 08                	je     0xc
   4:	4c 89 f7             	mov    %r14,%rdi
   7:	e8 af 81 77 00       	call   0x7781bb
   c:	f6 44 24 61 02       	testb  $0x2,0x61(%rsp)
  11:	0f 85 84 01 00 00    	jne    0x19b
  17:	41 f7 c7 00 02 00 00 	test   $0x200,%r15d
  1e:	74 01                	je     0x21
  20:	fb                   	sti
  21:	48 c7 44 24 40 0e 36 	movq   $0x45e0360e,0x40(%rsp)
  28:	e0 45
* 2a:	4b c7 44 25 00 00 00 	movq   $0x0,0x0(%r13,%r12,1) <-- trapping instruction
  31:	00 00
  33:	43 c7 44 25 09 00 00 	movl   $0x0,0x9(%r13,%r12,1)
  3a:	00 00
  3c:	43                   	rex.XB
  3d:	c7                   	.byte 0xc7
  3e:	44                   	rex.R
  3f:	25                   	.byte 0x25

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/12/03 12:52 linux-6.1.y e4d90d63d385 578925bc .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan KASAN: use-after-free Read in tcp_retransmit_timer
* Struck through repros no longer work on HEAD.