syzbot


KASAN: use-after-free Read in __vb2_perform_fileio

Status: fixed on 2019/12/30 15:48
Reported-by: syzbot+bc09078aa44c12d92c3f@syzkaller.appspotmail.com
Fix commit: 467052f6ea5a media: vivid: Fix wrong locking that causes race conditions on streaming stop
First crash: 2048d, last: 1818d
Fix bisection: fixed by (bisect log) :
commit 467052f6ea5a51524992e43f02b543550495c391
Author: Alexander Popov <alex.popov@linux.com>
Date: Sun Nov 3 22:17:19 2019 +0000

  media: vivid: Fix wrong locking that causes race conditions on streaming stop

  
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.14 KASAN: use-after-free Read in __vb2_perform_fileio C 454 627d 2046d 0/1 upstream: reported C repro on 2019/04/16 13:50
upstream KASAN: use-after-free Read in __vb2_perform_fileio C done 786 2024d 2215d 12/28 fixed on 2019/06/14 18:22
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2019/12/30 03:55 3h46m bisect fix linux-4.19.y OK (1) job log
2019/11/30 02:58 30m bisect fix linux-4.19.y OK (0) job log log

Sample crash report:
==================================================================
BUG: KASAN: use-after-free in __vb2_perform_fileio+0x105d/0x1140 drivers/media/common/videobuf2/videobuf2-core.c:2389
Read of size 4 at addr ffff88809403ac1c by task syz-executor684/8348

CPU: 0 PID: 8348 Comm: syz-executor684 Not tainted 4.19.37 #5
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+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:256
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x8c/0x2ba mm/kasan/report.c:396
 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:432
 __vb2_perform_fileio+0x105d/0x1140 drivers/media/common/videobuf2/videobuf2-core.c:2389
 vb2_read+0x3b/0x50 drivers/media/common/videobuf2/videobuf2-core.c:2500
 vb2_fop_read+0x212/0x410 drivers/media/common/videobuf2/videobuf2-v4l2.c:897
 v4l2_read+0x1ce/0x230 drivers/media/v4l2-core/v4l2-dev.c:317
 __vfs_read+0x116/0x800 fs/read_write.c:416
 vfs_read+0x194/0x3d0 fs/read_write.c:452
 ksys_read+0xea/0x1f0 fs/read_write.c:578
 __do_sys_read fs/read_write.c:588 [inline]
 __se_sys_read fs/read_write.c:586 [inline]
 __x64_sys_read+0x73/0xb0 fs/read_write.c:586
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x44a489
Code: e8 0c e8 ff ff 48 83 c4 18 c3 0f 1f 80 00 00 00 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 0f 83 7b cb fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fc2f80aedb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00000000006dbc28 RCX: 000000000044a489
RDX: 0000000000000052 RSI: 0000000020000540 RDI: 0000000000000003
RBP: 00000000006dbc20 R08: 0000000000000000 R09: 0000000000000000
R10: 00007fc2f80af700 R11: 0000000000000246 R12: 00000000006dbc2c
R13: 00007fff1919550f R14: 00007fc2f80af9c0 R15: 0000000000000000

Allocated by task 8348:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 kasan_kmalloc mm/kasan/kasan.c:553 [inline]
 kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:531
 kmem_cache_alloc_trace+0x152/0x760 mm/slab.c:3625
 kmalloc include/linux/slab.h:515 [inline]
 kzalloc include/linux/slab.h:709 [inline]
 __vb2_init_fileio+0x1cb/0xbe0 drivers/media/common/videobuf2/videobuf2-core.c:2234
 __vb2_perform_fileio+0xbff/0x1140 drivers/media/common/videobuf2/videobuf2-core.c:2368
 vb2_read+0x3b/0x50 drivers/media/common/videobuf2/videobuf2-core.c:2500
 vb2_fop_read+0x212/0x410 drivers/media/common/videobuf2/videobuf2-v4l2.c:897
 v4l2_read+0x1ce/0x230 drivers/media/v4l2-core/v4l2-dev.c:317
 __vfs_read+0x116/0x800 fs/read_write.c:416
 vfs_read+0x194/0x3d0 fs/read_write.c:452
 ksys_read+0xea/0x1f0 fs/read_write.c:578
 __do_sys_read fs/read_write.c:588 [inline]
 __se_sys_read fs/read_write.c:586 [inline]
 __x64_sys_read+0x73/0xb0 fs/read_write.c:586
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 8343:
 save_stack+0x45/0xd0 mm/kasan/kasan.c:448
 set_track mm/kasan/kasan.c:460 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/kasan.c:521
 kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
 __cache_free mm/slab.c:3503 [inline]
 kfree+0xcf/0x230 mm/slab.c:3822
 __vb2_cleanup_fileio+0x100/0x170 drivers/media/common/videobuf2/videobuf2-core.c:2327
 vb2_core_queue_release+0x20/0x80 drivers/media/common/videobuf2/videobuf2-core.c:2050
 vb2_queue_release drivers/media/common/videobuf2/videobuf2-v4l2.c:671 [inline]
 _vb2_fop_release+0x1cf/0x2a0 drivers/media/common/videobuf2/videobuf2-v4l2.c:842
 vb2_fop_release+0x75/0xc0 drivers/media/common/videobuf2/videobuf2-v4l2.c:856
 vivid_fop_release+0x18e/0x430 drivers/media/platform/vivid/vivid-core.c:474
 v4l2_release+0xfb/0x1a0 drivers/media/v4l2-core/v4l2-dev.c:448
 __fput+0x2df/0x8b0 fs/file_table.c:278
 ____fput+0x16/0x20 fs/file_table.c:309
 task_work_run+0x14a/0x1c0 kernel/task_work.c:113
 exit_task_work include/linux/task_work.h:22 [inline]
 do_exit+0x933/0x2fa0 kernel/exit.c:876
 do_group_exit+0x135/0x370 kernel/exit.c:979
 get_signal+0x399/0x1d50 kernel/signal.c:2572
 do_signal+0x95/0x1950 arch/x86/kernel/signal.c:816
 exit_to_usermode_loop+0x244/0x2c0 arch/x86/entry/common.c:162
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x52d/0x610 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809403a900
 which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 796 bytes inside of
 1024-byte region [ffff88809403a900, ffff88809403ad00)
The buggy address belongs to the page:
page:ffffea0002500e80 count:1 mapcount:0 mapping:ffff88812c3f0ac0 index:0x0 compound_mapcount: 0
flags: 0x1fffc0000008100(slab|head)
raw: 01fffc0000008100 ffffea0002511c88 ffffea00025bed08 ffff88812c3f0ac0
raw: 0000000000000000 ffff88809403a000 0000000100000007 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809403ab00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809403ab80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff88809403ac00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff88809403ac80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff88809403ad00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================

Crashes (13):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/04/28 17:10 linux-4.19.y 19bb613acb9a b617407b .config console log report syz C ci2-linux-4-19
2019/04/28 06:04 linux-4.19.y 19bb613acb9a b617407b .config console log report syz C ci2-linux-4-19
2019/04/23 01:17 linux-4.19.y c98875d930e9 53199d6e .config console log report syz C ci2-linux-4-19
2019/04/20 21:55 linux-4.19.y c98875d930e9 b0e8efcb .config console log report syz C ci2-linux-4-19
2019/04/18 01:57 linux-4.19.y 4b0e041c9dad b0e8efcb .config console log report syz C ci2-linux-4-19
2019/04/14 10:27 linux-4.19.y 4d552acf3370 505ab413 .config console log report syz C ci2-linux-4-19
2019/05/03 14:21 linux-4.19.y a03957ab0fd5 1bfa09b9 .config console log report syz ci2-linux-4-19
2019/04/30 16:33 linux-4.19.y 19bb613acb9a 20f16bef .config console log report syz ci2-linux-4-19
2019/04/26 15:17 linux-4.19.y c98875d930e9 b617407b .config console log report syz ci2-linux-4-19
2019/04/23 10:19 linux-4.19.y c98875d930e9 53199d6e .config console log report syz ci2-linux-4-19
2019/04/23 07:43 linux-4.19.y c98875d930e9 53199d6e .config console log report syz ci2-linux-4-19
2019/04/21 05:37 linux-4.19.y c98875d930e9 b0e8efcb .config console log report syz ci2-linux-4-19
2019/05/14 06:22 linux-4.19.y 9c2556f428cf ada3c44c .config console log report ci2-linux-4-19
* Struck through repros no longer work on HEAD.