KASAN: use-after-free Read in snd_seq_timer_interrupt

Status: upstream: reported C repro on 2021/06/23 11:22
First crash: 828d, last: 738d
Fix bisection: failed (error log, bisect log)
Similar bugs (3)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in snd_seq_timer_interrupt (2) alsa C inconclusive 2 846d 844d 22/25 fixed on 2021/11/10 00:50
upstream KASAN: use-after-free Read in snd_seq_timer_interrupt alsa 1 1801d 1801d 13/25 fixed on 2019/06/14 18:22
linux-4.14 KASAN: use-after-free Read in snd_seq_timer_interrupt C error 2 788d 1285d 0/1 upstream: reported C repro on 2020/03/23 11:55
Fix bisection attempts (4)
Created Duration User Patch Repo Result
2021/10/21 17:08 11m bisect fix linux-4.19.y error job log (0)
2021/09/21 16:42 25m bisect fix linux-4.19.y job log (0) log
2021/08/22 11:46 33m bisect fix linux-4.19.y job log (0) log
2021/07/23 11:21 24m bisect fix linux-4.19.y job log (0) log

Sample crash report:
BUG: KASAN: use-after-free in snd_seq_timer_interrupt+0x316/0x380 sound/core/seq/seq_timer.c:145
Read of size 8 at addr ffff8880a237fcd8 by task syz-executor842/8550

CPU: 0 PID: 8550 Comm: syz-executor842 Not tainted 4.19.195-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x1fc/0x2ef lib/dump_stack.c:118
 print_address_description.cold+0x54/0x219 mm/kasan/report.c:256
 kasan_report_error.cold+0x8a/0x1b9 mm/kasan/report.c:354
 kasan_report mm/kasan/report.c:412 [inline]
 __asan_report_load8_noabort+0x88/0x90 mm/kasan/report.c:433
 snd_seq_timer_interrupt+0x316/0x380 sound/core/seq/seq_timer.c:145
 snd_timer_interrupt.part.0+0x94f/0xf40 sound/core/timer.c:877
 snd_timer_interrupt sound/core/timer.c:1116 [inline]
 snd_timer_s_function+0x14b/0x1e0 sound/core/timer.c:1116
 call_timer_fn+0x177/0x700 kernel/time/timer.c:1338
 expire_timers+0x243/0x4e0 kernel/time/timer.c:1375
 __run_timers kernel/time/timer.c:1696 [inline]
 run_timer_softirq+0x21c/0x670 kernel/time/timer.c:1709
 __do_softirq+0x265/0x980 kernel/softirq.c:292
 invoke_softirq kernel/softirq.c:372 [inline]
 irq_exit+0x215/0x260 kernel/softirq.c:412
 exiting_irq arch/x86/include/asm/apic.h:536 [inline]
 smp_apic_timer_interrupt+0x136/0x550 arch/x86/kernel/apic/apic.c:1098
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:894
RIP: 0010:lock_is_held_type+0x187/0x210 kernel/locking/lockdep.c:3951
Code: 00 00 00 00 48 c1 e8 03 80 3c 10 00 75 63 48 83 3d 75 ce a6 08 00 74 2c 48 89 df 57 9d 0f 1f 44 00 00 48 83 c4 08 44 89 e0 5b <5d> 41 5c c3 48 83 c4 08 41 bc 01 00 00 00 5b 44 89 e0 5d 41 5c c3
RSP: 0000:ffff888093c37b60 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff13
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000001
RDX: dffffc0000000000 RSI: 00000000ffffffff RDI: 0000000000000286
RBP: ffff8880ac3c4240 R08: ffffffffffffffe8 R09: 0000000000000000
R10: 0000000000000004 R11: 0000000047376564 R12: 0000000000000000
R13: 0000000000000000 R14: 0000000000000000 R15: ffff888093c37d48
 lock_is_held include/linux/lockdep.h:344 [inline]
 ___might_sleep+0x227/0x2b0 kernel/sched/core.c:6157
 process_huge_page mm/memory.c:4761 [inline]
 clear_huge_page+0x98/0x460 mm/memory.c:4822
 __do_huge_pmd_anonymous_page mm/huge_memory.c:580 [inline]
 do_huge_pmd_anonymous_page+0xbb5/0x1e60 mm/huge_memory.c:737
 create_huge_pmd mm/memory.c:4025 [inline]
 __handle_mm_fault+0x289c/0x41c0 mm/memory.c:4229
 handle_mm_fault+0x436/0xb10 mm/memory.c:4295
 __do_page_fault+0x68e/0xd60 arch/x86/mm/fault.c:1412
 page_fault+0x1e/0x30 arch/x86/entry/entry_64.S:1205
RIP: 0033:0x401854
Code: 48 8d 35 0a 18 08 00 e8 5a 0c 00 00 b8 c0 01 00 20 48 8d 35 36 18 08 00 31 d2 48 89 c7 b9 1d 00 00 00 41 b8 c0 01 00 20 31 c0 <f3> a4 41 b9 80 02 00 20 83 ce ff b9 63 00 00 00 c6 07 00 bf 37 00
RSP: 002b:00007ffd5fe5dda0 EFLAGS: 00010246
RAX: 0000000000000000 RBX: 00000000000f4240 RCX: 000000000000001d
RDX: 0000000000000000 RSI: 0000000000483078 RDI: 00000000200001c0
RBP: 0000000000000000 R08: 00000000200001c0 R09: 00007ffd5fe5d810
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000008cfc
R13: 00007ffd5fe5ddac R14: 00007ffd5fe5ddc0 R15: 00007ffd5fe5ddb0

Allocated by task 8540:
 kmem_cache_alloc_trace+0x12f/0x380 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 queue_new sound/core/seq/seq_queue.c:113 [inline]
 snd_seq_queue_alloc+0x51/0x500 sound/core/seq/seq_queue.c:185
 snd_seq_ioctl_create_queue+0xab/0x320 sound/core/seq/seq_clientmgr.c:1531
 snd_seq_ioctl+0x203/0x400 sound/core/seq/seq_clientmgr.c:2140
 vfs_ioctl fs/ioctl.c:46 [inline]
 file_ioctl fs/ioctl.c:501 [inline]
 do_vfs_ioctl+0xcdb/0x12e0 fs/ioctl.c:688
 ksys_ioctl+0x9b/0xc0 fs/ioctl.c:705
 __do_sys_ioctl fs/ioctl.c:712 [inline]
 __se_sys_ioctl fs/ioctl.c:710 [inline]
 __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:710
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293

Freed by task 8540:
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcc/0x210 mm/slab.c:3822
 snd_seq_queue_client_leave+0x31/0x160 sound/core/seq/seq_queue.c:592
 seq_free_client1.part.0+0xf0/0x270 sound/core/seq/seq_clientmgr.c:263
 seq_free_client1 sound/core/seq/seq_clientmgr.c:256 [inline]
 seq_free_client+0x7b/0xf0 sound/core/seq/seq_clientmgr.c:285
 snd_seq_release+0x4d/0xe0 sound/core/seq/seq_clientmgr.c:366
 __fput+0x2ce/0x890 fs/file_table.c:278
 task_work_run+0x148/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xbf3/0x2be0 kernel/exit.c:870
 do_group_exit+0x125/0x310 kernel/exit.c:967
 __do_sys_exit_group kernel/exit.c:978 [inline]
 __se_sys_exit_group kernel/exit.c:976 [inline]
 __x64_sys_exit_group+0x3a/0x50 kernel/exit.c:976
 do_syscall_64+0xf9/0x620 arch/x86/entry/common.c:293

The buggy address belongs to the object at ffff8880a237fc80
 which belongs to the cache kmalloc-512 of size 512
The buggy address is located 88 bytes inside of
 512-byte region [ffff8880a237fc80, ffff8880a237fe80)
The buggy address belongs to the page:
page:ffffea000288dfc0 count:1 mapcount:0 mapping:ffff88813bff0940 index:0xffff8880a237f000
flags: 0xfff00000000100(slab)
raw: 00fff00000000100 ffffea0002a733c8 ffffea00028c8988 ffff88813bff0940
raw: ffff8880a237f000 ffff8880a237f000 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8880a237fb80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a237fc00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff8880a237fc80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a237fd00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff8880a237fd80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2021/06/23 11:21 linux-4.19.y eb575cd5d7f6 aba2b2fb .config console log report syz C ci2-linux-4-19 KASAN: use-after-free Read in snd_seq_timer_interrupt
* Struck through repros no longer work on HEAD.