syzbot


KASAN: use-after-free Read in snd_timer_resolution

Status: fixed on 2020/02/21 03:21
Reported-by: syzbot+ba49a54593a4deae9c1f@syzkaller.appspotmail.com
Fix commit: 43bb0a16b25d ALSA: seq: Fix racy access for queue timer in proc read
First crash: 1765d, last: 1765d
Fix bisection: fixed by (bisect log) :
commit 43bb0a16b25d5030193935b5c292648fa9abc0fc
Author: Takashi Iwai <tiwai@suse.de>
Date: Wed Jan 15 20:37:33 2020 +0000

  ALSA: seq: Fix racy access for queue timer in proc read

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in snd_timer_resolution C done 2 1768d 1768d 1/1 fixed on 2020/02/19 00:41
upstream KASAN: use-after-free Read in snd_timer_resolution sound C 5 1754d 1771d 15/28 fixed on 2020/02/18 14:31

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in snd_timer_resolution+0xd8/0xf0 sound/core/timer.c:457
Read of size 8 at addr ffff88809890b580 by task syz-executor232/7363

CPU: 1 PID: 7363 Comm: syz-executor232 Not tainted 4.14.166-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x142/0x197 lib/dump_stack.c:58
 print_address_description.cold+0x7c/0x1dc mm/kasan/report.c:252
 kasan_report_error mm/kasan/report.c:351 [inline]
 kasan_report mm/kasan/report.c:409 [inline]
 kasan_report.cold+0xa9/0x2af mm/kasan/report.c:393
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:430
 snd_timer_resolution+0xd8/0xf0 sound/core/timer.c:457
 snd_seq_info_timer_read+0x96/0x2be sound/core/seq/seq_timer.c:488
 snd_info_seq_show+0xcb/0x120 sound/core/info.c:378
 seq_read+0x51a/0x1280 fs/seq_file.c:237
 proc_reg_read+0xfa/0x170 fs/proc/inode.c:217
 do_loop_readv_writev fs/read_write.c:695 [inline]
 do_loop_readv_writev fs/read_write.c:682 [inline]
 do_iter_read+0x3e2/0x5b0 fs/read_write.c:919
 vfs_readv+0xd3/0x130 fs/read_write.c:981
 do_preadv+0x15d/0x200 fs/read_write.c:1065
 SYSC_preadv fs/read_write.c:1115 [inline]
 SyS_preadv+0x31/0x40 fs/read_write.c:1110
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x441979
RSP: 002b:00007ffcf23cf7e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441979
RDX: 0000000000000227 RSI: 00000000200017c0 RDI: 0000000000000004
RBP: 000000000000e2a2 R08: 000000000000000f R09: 0000000000402780
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000004026f0
R13: 0000000000402780 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7359:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_kmalloc mm/kasan/kasan.c:551 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
 kmem_cache_alloc_trace+0x152/0x790 mm/slab.c:3618
 kmalloc include/linux/slab.h:488 [inline]
 kzalloc include/linux/slab.h:661 [inline]
 snd_timer_instance_new+0x4f/0x3c0 sound/core/timer.c:111
 snd_timer_open+0x882/0x15e0 sound/core/timer.c:321
 snd_seq_timer_open+0x210/0x520 sound/core/seq/seq_timer.c:287
 queue_use+0x9e/0x200 sound/core/seq/seq_queue.c:514
 snd_seq_queue_alloc+0x2b5/0x490 sound/core/seq/seq_queue.c:199
 snd_seq_ioctl_create_queue+0xad/0x2f0 sound/core/seq/seq_clientmgr.c:1528
 snd_seq_kernel_client_ctl+0xd7/0x120 sound/core/seq/seq_clientmgr.c:2360
 alloc_seq_queue.isra.0+0xcd/0x150 sound/core/seq/oss/seq_oss_init.c:370
 snd_seq_oss_open+0x2d7/0x8d0 sound/core/seq/oss/seq_oss_init.c:228
 odev_open+0x69/0x90 sound/core/seq/oss/seq_oss.c:138
 soundcore_open+0x3f3/0x5a0 sound/sound_core.c:640
 chrdev_open+0x207/0x590 fs/char_dev.c:423
 do_dentry_open+0x73b/0xeb0 fs/open.c:777
 vfs_open+0x105/0x220 fs/open.c:891
 do_last fs/namei.c:3425 [inline]
 path_openat+0x8bd/0x3f70 fs/namei.c:3566
 do_filp_open+0x18e/0x250 fs/namei.c:3600
 do_sys_open+0x2c5/0x430 fs/open.c:1084
 SYSC_openat fs/open.c:1111 [inline]
 SyS_openat+0x30/0x40 fs/open.c:1105
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

Freed by task 7359:
 save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59
 save_stack+0x45/0xd0 mm/kasan/kasan.c:447
 set_track mm/kasan/kasan.c:459 [inline]
 kasan_slab_free+0x75/0xc0 mm/kasan/kasan.c:524
 __cache_free mm/slab.c:3496 [inline]
 kfree+0xcc/0x270 mm/slab.c:3815
 snd_timer_close_locked+0x758/0xb80 sound/core/timer.c:416
 snd_timer_close+0x7b/0xe0 sound/core/timer.c:442
 snd_seq_timer_close+0x91/0xd0 sound/core/seq/seq_timer.c:326
 queue_delete+0x52/0xb0 sound/core/seq/seq_queue.c:147
 snd_seq_queue_delete+0x41/0x60 sound/core/seq/seq_queue.c:219
 snd_seq_ioctl_delete_queue+0x6a/0x90 sound/core/seq/seq_clientmgr.c:1550
 snd_seq_kernel_client_ctl+0xd7/0x120 sound/core/seq/seq_clientmgr.c:2360
 delete_seq_queue.part.0+0xa7/0xf0 sound/core/seq/oss/seq_oss_init.c:389
 delete_seq_queue sound/core/seq/oss/seq_oss_init.c:385 [inline]
 snd_seq_oss_release+0x103/0x140 sound/core/seq/oss/seq_oss_init.c:434
 odev_release+0x54/0x80 sound/core/seq/oss/seq_oss.c:153
 __fput+0x275/0x7a0 fs/file_table.c:210
 ____fput+0x16/0x20 fs/file_table.c:244
 task_work_run+0x114/0x190 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0xa1a/0x2cd0 kernel/exit.c:858
 do_group_exit+0x111/0x330 kernel/exit.c:955
 SYSC_exit_group kernel/exit.c:966 [inline]
 SyS_exit_group+0x1d/0x20 kernel/exit.c:964
 do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
 entry_SYSCALL_64_after_hwframe+0x42/0xb7

The buggy address belongs to the object at ffff88809890b580
 which belongs to the cache kmalloc-256 of size 256
The buggy address is located 0 bytes inside of
 256-byte region [ffff88809890b580, ffff88809890b680)
The buggy address belongs to the page:
page:ffffea00026242c0 count:1 mapcount:0 mapping:ffff88809890b080 index:0x0
flags: 0xfffe0000000100(slab)
raw: 00fffe0000000100 ffff88809890b080 0000000000000000 000000010000000c
raw: ffffea00023c2f20 ffffea0002a3ef60 ffff8880aa8007c0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809890b480: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88809890b500: 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809890b580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff88809890b600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809890b680: fc fc fc fc fc fc fc fc 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
2020/01/21 23:36 linux-4.14.y c1141b3aab36 8eda0b95 .config console log report syz C ci2-linux-4-14
* Struck through repros no longer work on HEAD.