syzbot


KASAN: null-ptr-deref Write in kthread_stop

Status: fixed on 2019/12/03 19:11
Reported-by: syzbot+59bfbd6d2dceb3f47ced@syzkaller.appspotmail.com
Fix commit: 467052f6ea5a media: vivid: Fix wrong locking that causes race conditions on streaming stop
First crash: 1830d, last: 1725d
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 (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: null-ptr-deref Write in kthread_stop media C 2527 1948d 2006d 11/26 fixed on 2019/01/11 01:22

Sample crash report:
==================================================================
BUG: KASAN: null-ptr-deref in atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline]
BUG: KASAN: null-ptr-deref in kthread_stop+0x78/0x6d0 kernel/kthread.c:545
Write of size 4 at addr 0000000000000020 by task syz-executor483/8037

CPU: 1 PID: 8037 Comm: syz-executor483 Not tainted 4.19.38 #6
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
 kasan_report_error mm/kasan/report.c:352 [inline]
 kasan_report mm/kasan/report.c:412 [inline]
 kasan_report.cold+0x254/0x2fa mm/kasan/report.c:396
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x123/0x190 mm/kasan/kasan.c:267
 kasan_check_write+0x14/0x20 mm/kasan/kasan.c:278
 atomic_inc include/asm-generic/atomic-instrumented.h:109 [inline]
 kthread_stop+0x78/0x6d0 kernel/kthread.c:545
 vivid_stop_generating_vid_cap+0x1e0/0x6e2 drivers/media/platform/vivid/vivid-kthread-cap.c:922
 vid_cap_stop_streaming+0x8a/0xe0 drivers/media/platform/vivid/vivid-vid-cap.c:256
 __vb2_queue_cancel+0xb4/0x970 drivers/media/common/videobuf2/videobuf2-core.c:1662
 vb2_core_streamoff+0x60/0x140 drivers/media/common/videobuf2/videobuf2-core.c:1796
 __vb2_cleanup_fileio+0x78/0x170 drivers/media/common/videobuf2/videobuf2-core.c:2323
 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
 tracehook_notify_resume include/linux/tracehook.h:193 [inline]
 exit_to_usermode_loop+0x273/0x2c0 arch/x86/entry/common.c:166
 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
RIP: 0033:0x44b599
Code: e8 dc e6 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 9b c9 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fcc7b5adce8 EFLAGS: 00000246 ORIG_RAX: 0000000000000124
RAX: 0000000000000004 RBX: 00000000006ddc58 RCX: 000000000044b599
RDX: 0000000000000000 RSI: 0000000000000004 RDI: 0000000000000003
RBP: 00000000006ddc50 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006ddc5c
R13: 00007fff97d6464f R14: 00007fcc7b5ae9c0 R15: 0000000000000000
==================================================================

Crashes (12):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/05/03 20:01 linux-4.19.y a03957ab0fd5 d28f4ce5 .config console log report syz C ci2-linux-4-19
2019/04/22 23:15 linux-4.19.y c98875d930e9 53199d6e .config console log report syz C ci2-linux-4-19
2019/08/05 20:01 linux-4.19.y b3060a1a313f 6affd8e8 .config console log report ci2-linux-4-19
2019/07/21 02:04 linux-4.19.y 3bd837bfe431 1656845f .config console log report ci2-linux-4-19
2019/06/15 01:05 linux-4.19.y 768292d05361 442206d7 .config console log report ci2-linux-4-19
2019/05/21 17:55 linux-4.19.y dafc674bbcb1 13427bd9 .config console log report ci2-linux-4-19
2019/05/13 19:20 linux-4.19.y 9c2556f428cf 7c305b44 .config console log report ci2-linux-4-19
2019/05/13 08:24 linux-4.19.y 9c2556f428cf 16ab1e89 .config console log report ci2-linux-4-19
2019/05/12 19:52 linux-4.19.y 9c2556f428cf 5f302c04 .config console log report ci2-linux-4-19
2019/05/12 19:41 linux-4.19.y 9c2556f428cf 5f302c04 .config console log report ci2-linux-4-19
2019/05/11 22:20 linux-4.19.y 9c2556f428cf 0637a7f0 .config console log report ci2-linux-4-19
2019/04/22 20:52 linux-4.19.y c98875d930e9 53199d6e .config console log report ci2-linux-4-19
* Struck through repros no longer work on HEAD.