bisecting fixing commit since ddef1e8e3f6eb26034833b7255e3fa584d54a230 building syzkaller on af5c522d02400b35a930d6fbdf286f9ce2afc8ba testing commit ddef1e8e3f6eb26034833b7255e3fa584d54a230 with gcc (GCC) 8.1.0 kernel signature: 72946e7f9a783d04f2917b410f70c1eca4e69249966922282b2b4fd8502c878f all runs: crashed: INFO: task hung in vivid_stop_generating_vid_cap testing current HEAD 98db2bf27b9ed2d5ed0b6c9c8a4bfcb127a19796 testing commit 98db2bf27b9ed2d5ed0b6c9c8a4bfcb127a19796 with gcc (GCC) 8.1.0 kernel signature: 54545298b656951b33bb3d0474a490a070767f96cfb5aa883821d029c49968cd all runs: crashed: KASAN: use-after-free Read in __vb2_perform_fileio revisions tested: 2, total time: 27m45.060195525s (build: 16m26.452828989s, test: 10m13.2355142s) the crash still happens on HEAD commit msg: Linux 4.14.171 crash: KASAN: use-after-free Read in __vb2_perform_fileio vivid-000: kernel_thread() failed vivid-000: kernel_thread() failed vivid-000: kernel_thread() failed vivid-000: kernel_thread() failed ================================================================== BUG: KASAN: use-after-free in __vb2_perform_fileio+0x10fd/0x12b0 drivers/media/v4l2-core/videobuf2-core.c:2379 Read of size 4 at addr ffff8880811d509c by task syz-executor.2/7185 CPU: 0 PID: 7185 Comm: syz-executor.2 Not tainted 4.14.171-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+0xf7/0x13b lib/dump_stack.c:58 print_address_description.cold.7+0x9/0x1c9 mm/kasan/report.c:252 kasan_report_error mm/kasan/report.c:351 [inline] kasan_report.cold.8+0x11a/0x2d3 mm/kasan/report.c:409 __asan_report_load4_noabort+0x14/0x20 mm/kasan/report.c:429 __vb2_perform_fileio+0x10fd/0x12b0 drivers/media/v4l2-core/videobuf2-core.c:2379 vb2_read+0xf/0x20 drivers/media/v4l2-core/videobuf2-core.c:2490 vb2_fop_read+0x1b6/0x390 drivers/media/v4l2-core/videobuf2-v4l2.c:895 v4l2_read+0x133/0x240 drivers/media/v4l2-core/v4l2-dev.c:309 __vfs_read+0xdb/0x840 fs/read_write.c:411 vfs_read+0xf5/0x300 fs/read_write.c:447 SYSC_read fs/read_write.c:574 [inline] SyS_read+0x100/0x250 fs/read_write.c:567 do_syscall_64+0x1c7/0x5b0 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x42/0xb7 RIP: 0033:0x45a219 RSP: 002b:00007f48dc103c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045a219 RDX: 000000000000008a RSI: 0000000020000100 RDI: 0000000000000005 RBP: 000000000075bf20 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 00007f48dc1046d4 R13: 00000000004c7bb4 R14: 00000000004ddc18 R15: 00000000ffffffff Allocated by task 7181: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 [inline] kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:551 kmem_cache_alloc_trace+0x152/0x7a0 mm/slab.c:3618 kmalloc include/linux/slab.h:488 [inline] kzalloc include/linux/slab.h:661 [inline] __vb2_init_fileio+0x160/0xaf0 drivers/media/v4l2-core/videobuf2-core.c:2224 __vb2_perform_fileio+0xa9f/0x12b0 drivers/media/v4l2-core/videobuf2-core.c:2358 vb2_read+0xf/0x20 drivers/media/v4l2-core/videobuf2-core.c:2490 vb2_fop_read+0x1b6/0x390 drivers/media/v4l2-core/videobuf2-v4l2.c:895 v4l2_read+0x133/0x240 drivers/media/v4l2-core/v4l2-dev.c:309 __vfs_read+0xdb/0x840 fs/read_write.c:411 vfs_read+0xf5/0x300 fs/read_write.c:447 SYSC_read fs/read_write.c:574 [inline] SyS_read+0x100/0x250 fs/read_write.c:567 do_syscall_64+0x1c7/0x5b0 arch/x86/entry/common.c:292 entry_SYSCALL_64_after_hwframe+0x42/0xb7 Freed by task 7172: save_stack_trace+0x16/0x20 arch/x86/kernel/stacktrace.c:59 save_stack+0x43/0xd0 mm/kasan/kasan.c:447 set_track mm/kasan/kasan.c:459 [inline] kasan_slab_free+0x71/0xc0 mm/kasan/kasan.c:524 __cache_free mm/slab.c:3496 [inline] kfree+0xcc/0x270 mm/slab.c:3815 __vb2_cleanup_fileio+0xee/0x140 drivers/media/v4l2-core/videobuf2-core.c:2317 vb2_core_queue_release+0xf/0x70 drivers/media/v4l2-core/videobuf2-core.c:2040 vb2_queue_release drivers/media/v4l2-core/videobuf2-v4l2.c:669 [inline] _vb2_fop_release+0x1ac/0x280 drivers/media/v4l2-core/videobuf2-v4l2.c:840 vb2_fop_release+0x66/0xd0 drivers/media/v4l2-core/videobuf2-v4l2.c:854 vivid_fop_release+0x15f/0x3a0 drivers/media/platform/vivid/vivid-core.c:486 v4l2_release+0xeb/0x1a0 drivers/media/v4l2-core/v4l2-dev.c:446 __fput+0x232/0x750 fs/file_table.c:210 ____fput+0x9/0x10 fs/file_table.c:244 task_work_run+0xe5/0x170 kernel/task_work.c:113 tracehook_notify_resume include/linux/tracehook.h:191 [inline] exit_to_usermode_loop+0x16a/0x1b0 arch/x86/entry/common.c:164 prepare_exit_to_usermode arch/x86/entry/common.c:199 [inline] syscall_return_slowpath arch/x86/entry/common.c:270 [inline] do_syscall_64+0x416/0x5b0 arch/x86/entry/common.c:297 entry_SYSCALL_64_after_hwframe+0x42/0xb7 The buggy address belongs to the object at ffff8880811d4d80 which belongs to the cache kmalloc-1024 of size 1024 The buggy address is located 796 bytes inside of 1024-byte region [ffff8880811d4d80, ffff8880811d5180) The buggy address belongs to the page: page:ffffea0002047500 count:1 mapcount:0 mapping:ffff8880811d4000 index:0x0 compound_mapcount: 0 flags: 0x1fffc0000008100(slab|head) raw: 01fffc0000008100 ffff8880811d4000 0000000000000000 0000000100000007 raw: ffffea00025c2ca0 ffffea00025b0220 ffff8880aa800ac0 0000000000000000 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff8880811d4f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880811d5000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb >ffff8880811d5080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ^ ffff8880811d5100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb ffff8880811d5180: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ==================================================================