syzbot


KASAN: use-after-free Write in __mod_timer (2)

Status: auto-closed as invalid on 2022/01/30 03:03
Reported-by: syzbot+5a1eb28a3e52393e33f9@syzkaller.appspotmail.com
First crash: 1148d, last: 1148d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
android-54 KASAN: use-after-free Write in __mod_timer 1 1364d 1364d 0/2 auto-closed as invalid on 2021/06/27 19:40
android-54 KASAN: use-after-free Write in __mod_timer (3) 2 824d 880d 0/2 auto-obsoleted due to no activity on 2022/12/19 20:01

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in hlist_add_head include/linux/list.h:787 [inline]
BUG: KASAN: use-after-free in enqueue_timer kernel/time/timer.c:541 [inline]
BUG: KASAN: use-after-free in __mod_timer+0xa90/0x1c70 kernel/time/timer.c:1062
Write of size 8 at addr ffff8881ea18b1c8 by task kworker/1:13/2203

CPU: 1 PID: 2203 Comm: kworker/1:13 Tainted: G        W         5.4.125-syzkaller-00030-g1e429b8f9eb9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Workqueue: wg-crypt-wg0 wg_packet_decrypt_worker
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1d8/0x24e lib/dump_stack.c:118
 print_address_description+0x9b/0x650 mm/kasan/report.c:384
 __kasan_report+0x182/0x260 mm/kasan/report.c:516
 kasan_report+0x30/0x60 mm/kasan/common.c:653
 hlist_add_head include/linux/list.h:787 [inline]
 enqueue_timer kernel/time/timer.c:541 [inline]
 __mod_timer+0xa90/0x1c70 kernel/time/timer.c:1062
 mod_peer_timer drivers/net/wireguard/timers.c:37 [inline]
 wg_timers_any_authenticated_packet_traversal+0x129/0x190 drivers/net/wireguard/timers.c:215
 wg_packet_consume_data_done drivers/net/wireguard/receive.c:360 [inline]
 wg_packet_rx_poll+0xc6c/0x1eb0 drivers/net/wireguard/receive.c:480
 napi_poll+0x195/0x670 net/core/dev.c:6335
 net_rx_action+0x41c/0xb90 net/core/dev.c:6403
 __do_softirq+0x23e/0x615 kernel/softirq.c:292
 do_softirq_own_stack+0x2a/0x40 arch/x86/entry/entry_64.S:1083
 </IRQ>
 do_softirq+0x121/0x160 kernel/softirq.c:337
 __local_bh_enable_ip+0x63/0x70 kernel/softirq.c:189
 spin_unlock_bh include/linux/spinlock.h:383 [inline]
 ptr_ring_consume_bh include/linux/ptr_ring.h:366 [inline]
 wg_packet_decrypt_worker+0xc20/0xcc0 drivers/net/wireguard/receive.c:505
 process_one_work+0x679/0x1030 kernel/workqueue.c:2277
 worker_thread+0xa6f/0x1400 kernel/workqueue.c:2423
 kthread+0x30f/0x330 kernel/kthread.c:268
 ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:352

Allocated by task 150:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 __kasan_kmalloc+0x137/0x1e0 mm/kasan/common.c:529
 slab_post_alloc_hook mm/slab.h:584 [inline]
 slab_alloc_node mm/slub.c:2821 [inline]
 slab_alloc mm/slub.c:2829 [inline]
 kmem_cache_alloc+0x115/0x290 mm/slub.c:2834
 getname_flags+0xba/0x640 fs/namei.c:141
 user_path_at_empty+0x28/0x50 fs/namei.c:2683
 user_path_at include/linux/namei.h:49 [inline]
 vfs_statx fs/stat.c:187 [inline]
 vfs_lstat include/linux/fs.h:3361 [inline]
 __do_sys_newlstat fs/stat.c:354 [inline]
 __se_sys_newlstat+0xde/0x860 fs/stat.c:348
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Freed by task 150:
 save_stack mm/kasan/common.c:70 [inline]
 set_track mm/kasan/common.c:78 [inline]
 kasan_set_free_info mm/kasan/common.c:345 [inline]
 __kasan_slab_free+0x18a/0x240 mm/kasan/common.c:487
 slab_free_hook mm/slub.c:1454 [inline]
 slab_free_freelist_hook+0x7b/0x150 mm/slub.c:1492
 slab_free mm/slub.c:3072 [inline]
 kmem_cache_free+0xb8/0x5f0 mm/slub.c:3088
 putname fs/namei.c:262 [inline]
 filename_lookup+0x4bb/0x6a0 fs/namei.c:2432
 user_path_at include/linux/namei.h:49 [inline]
 vfs_statx fs/stat.c:187 [inline]
 vfs_lstat include/linux/fs.h:3361 [inline]
 __do_sys_newlstat fs/stat.c:354 [inline]
 __se_sys_newlstat+0xde/0x860 fs/stat.c:348
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff8881ea18a200
 which belongs to the cache names_cache of size 4096
The buggy address is located 4040 bytes inside of
 4096-byte region [ffff8881ea18a200, ffff8881ea18b200)
The buggy address belongs to the page:
page:ffffea0007a86200 refcount:1 mapcount:0 mapping:ffff8881f5cfa780 index:0x0 compound_mapcount: 0
flags: 0x8000000000010200(slab|head)
raw: 8000000000010200 dead000000000100 dead000000000122 ffff8881f5cfa780
raw: 0000000000000000 0000000000070007 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)
 set_page_owner include/linux/page_owner.h:31 [inline]
 post_alloc_hook mm/page_alloc.c:2165 [inline]
 prep_new_page+0x19a/0x380 mm/page_alloc.c:2171
 get_page_from_freelist+0x550/0x8b0 mm/page_alloc.c:3794
 __alloc_pages_nodemask+0x3a2/0x880 mm/page_alloc.c:4855
 alloc_slab_page+0x39/0x3e0 mm/slub.c:342
 allocate_slab mm/slub.c:1675 [inline]
 new_slab+0x97/0x460 mm/slub.c:1741
 new_slab_objects mm/slub.c:2498 [inline]
 ___slab_alloc+0x330/0x4c0 mm/slub.c:2659
 __slab_alloc mm/slub.c:2699 [inline]
 slab_alloc_node mm/slub.c:2784 [inline]
 slab_alloc mm/slub.c:2829 [inline]
 kmem_cache_alloc+0x18b/0x290 mm/slub.c:2834
 getname_flags+0xba/0x640 fs/namei.c:141
 user_path_at_empty+0x28/0x50 fs/namei.c:2683
 user_path_at include/linux/namei.h:49 [inline]
 vfs_statx fs/stat.c:187 [inline]
 vfs_lstat include/linux/fs.h:3361 [inline]
 __do_sys_newlstat fs/stat.c:354 [inline]
 __se_sys_newlstat+0xde/0x860 fs/stat.c:348
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:24 [inline]
 free_pages_prepare mm/page_alloc.c:1176 [inline]
 __free_pages_ok+0xc60/0xd80 mm/page_alloc.c:1438
 free_the_page mm/page_alloc.c:4917 [inline]
 __free_pages+0x8f/0x250 mm/page_alloc.c:4923
 kfree+0x1ee/0x660 mm/slub.c:4058
 device_release+0x70/0x1a0 drivers/base/core.c:1776
 kobject_cleanup+0x1de/0x3c0 lib/kobject.c:708
 tun_set_iff drivers/net/tun.c:2900 [inline]
 __tun_chr_ioctl+0x2b91/0x4d20 drivers/net/tun.c:3143
 do_vfs_ioctl+0x76a/0x1720 fs/ioctl.c:47
 ksys_ioctl fs/ioctl.c:742 [inline]
 __do_sys_ioctl fs/ioctl.c:749 [inline]
 __se_sys_ioctl fs/ioctl.c:747 [inline]
 __x64_sys_ioctl+0xd4/0x110 fs/ioctl.c:747
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Memory state around the buggy address:
 ffff8881ea18b080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8881ea18b100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881ea18b180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff8881ea18b200: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff8881ea18b280: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
BUG: kernel NULL pointer dereference, address: 0000000000000000
#PF: supervisor instruction fetch in kernel mode
#PF: error_code(0x0010) - not-present page
PGD 1e7349067 P4D 1e7349067 PUD 1b7e35067 PMD 0 
Oops: 0010 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 4713 Comm: syz-executor.4 Tainted: G    B   W         5.4.125-syzkaller-00030-g1e429b8f9eb9 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:0x0
Code: Bad RIP value.
RSP: 0018:ffff8881f6f09cd0 EFLAGS: 00010206
RAX: ffffffff81562548 RBX: 0000000000000100 RCX: ffff8881e8c32f40
RDX: 0000000080000100 RSI: 0000000000000000 RDI: ffff8881ea18b1c0
RBP: ffff8881ea18b1e0 R08: ffffffff8156230d R09: 0000000000000003
R10: ffffed103ede1391 R11: 0000000000000004 R12: 00000000ffffcbb0
R13: 1ffff1103ede7ef1 R14: 0000000000000000 R15: ffff8881ea18b1c0
FS:  00007fce001f1700(0000) GS:ffff8881f6f00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 00000001ddcb1000 CR4: 00000000003426e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <IRQ>
 call_timer_fn+0x30/0x330 kernel/time/timer.c:1416
 expire_timers+0x214/0x410 kernel/time/timer.c:1461
 __run_timers+0x603/0x740 kernel/time/timer.c:1785
 run_timer_softirq+0x46/0x80 kernel/time/timer.c:1798
 __do_softirq+0x23e/0x615 kernel/softirq.c:292
 invoke_softirq kernel/softirq.c:373 [inline]
 irq_exit+0x195/0x1c0 kernel/softirq.c:413
 exiting_irq arch/x86/include/asm/apic.h:538 [inline]
 smp_apic_timer_interrupt+0x113/0x420 arch/x86/kernel/apic/apic.c:1150
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:831
 </IRQ>
RIP: 0010:rw_copy_check_uvector+0x0/0x2f0 fs/read_write.c:768
Code: f1 80 e1 07 80 c1 03 38 c1 0f 8c 3c ff ff ff 4c 89 f7 e8 d3 62 fc ff e9 2f ff ff ff e8 29 1a a5 ff 66 0f 1f 84 00 00 00 00 00 <55> 41 57 41 56 41 55 41 54 53 48 83 ec 28 4d 89 cf 4c 89 04 24 48
RSP: 0018:ffff8881ef727978 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
RAX: dffffc0000000000 RBX: ffff8881ef7279e0 RCX: 0000000000000008
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffff8881ef727a50 R08: ffff8881ef727c60 R09: ffff8881ef7279e0
R10: ffffed103dee4f5b R11: 0000000000000000 R12: 1ffff1103dee4f84
R13: ffff8881ef7279e0 R14: ffff8881ef727d50 R15: 0000000000000008
 import_iovec+0x10d/0x380 lib/iov_iter.c:1649
 copy_msghdr_from_user+0x443/0x720 net/socket.c:2230
 recvmsg_copy_msghdr net/socket.c:2500 [inline]
 ___sys_recvmsg net/socket.c:2567 [inline]
 do_recvmmsg+0x430/0xb40 net/socket.c:2682
 __sys_recvmmsg net/socket.c:2761 [inline]
 __do_sys_recvmmsg net/socket.c:2784 [inline]
 __se_sys_recvmmsg net/socket.c:2777 [inline]
 __x64_sys_recvmmsg+0x195/0x240 net/socket.c:2777
 do_syscall_64+0xcb/0x1e0 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fce0249a8d9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fce001f1188 EFLAGS: 00000246 ORIG_RAX: 000000000000012b
RAX: ffffffffffffffda RBX: 00007fce0259f020 RCX: 00007fce0249a8d9
RDX: 0000000000010106 RSI: 00000000200000c0 RDI: 0000000000000003
RBP: 00007fce024f4cb4 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000002 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffd51a0cdcf R14: 00007fce001f1300 R15: 0000000000022000
Modules linked in:
CR2: 0000000000000000
---[ end trace cacd0e152d6eeadd ]---
RIP: 0010:0x0
Code: Bad RIP value.
RSP: 0018:ffff8881f6f09cd0 EFLAGS: 00010206
RAX: ffffffff81562548 RBX: 0000000000000100 RCX: ffff8881e8c32f40
RDX: 0000000080000100 RSI: 0000000000000000 RDI: ffff8881ea18b1c0
RBP: ffff8881ea18b1e0 R08: ffffffff8156230d R09: 0000000000000003
R10: ffffed103ede1391 R11: 0000000000000004 R12: 00000000ffffcbb0
R13: 1ffff1103ede7ef1 R14: 0000000000000000 R15: ffff8881ea18b1c0
FS:  00007fce001f1700(0000) GS:ffff8881f6f00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 00000001ddcb1000 CR4: 00000000003426e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	f1                   	icebp
   1:	80 e1 07             	and    $0x7,%cl
   4:	80 c1 03             	add    $0x3,%cl
   7:	38 c1                	cmp    %al,%cl
   9:	0f 8c 3c ff ff ff    	jl     0xffffff4b
   f:	4c 89 f7             	mov    %r14,%rdi
  12:	e8 d3 62 fc ff       	callq  0xfffc62ea
  17:	e9 2f ff ff ff       	jmpq   0xffffff4b
  1c:	e8 29 1a a5 ff       	callq  0xffa51a4a
  21:	66 0f 1f 84 00 00 00 	nopw   0x0(%rax,%rax,1)
  28:	00 00
* 2a:	55                   	push   %rbp <-- trapping instruction
  2b:	41 57                	push   %r15
  2d:	41 56                	push   %r14
  2f:	41 55                	push   %r13
  31:	41 54                	push   %r12
  33:	53                   	push   %rbx
  34:	48 83 ec 28          	sub    $0x28,%rsp
  38:	4d 89 cf             	mov    %r9,%r15
  3b:	4c 89 04 24          	mov    %r8,(%rsp)
  3f:	48                   	rex.W

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/10/02 03:02 android12-5.4 1e429b8f9eb9 db0f5787 .config console log report info ci2-android-5-4-kasan KASAN: use-after-free Write in __mod_timer
* Struck through repros no longer work on HEAD.