KASAN: use-after-free Read in v4l2_ctrl_grab

34 views
Skip to first unread message

syzbot

unread,
Apr 10, 2019, 10:10:07 PM4/10/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: 4d552acf Linux 4.19.34
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=12184fab200000
kernel config: https://syzkaller.appspot.com/x/.config?x=c95a88291f095edd
dashboard link: https://syzkaller.appspot.com/bug?extid=43f0de2c8739cdfafc97
compiler: gcc (GCC) 9.0.0 20181231 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+43f0de...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in v4l2_ctrl_grab
drivers/media/v4l2-core/v4l2-ctrls.c:2527 [inline]
BUG: KASAN: use-after-free in v4l2_ctrl_grab+0x159/0x160
drivers/media/v4l2-core/v4l2-ctrls.c:2520
Read of size 8 at addr ffff8880a55f1720 by task syz-executor.5/11734

CPU: 0 PID: 11734 Comm: syz-executor.5 Not tainted 4.19.34 #2
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_load8_noabort+0x14/0x20 mm/kasan/report.c:433
v4l2_ctrl_grab drivers/media/v4l2-core/v4l2-ctrls.c:2527 [inline]
v4l2_ctrl_grab+0x159/0x160 drivers/media/v4l2-core/v4l2-ctrls.c:2520
vicodec_stop_streaming+0x158/0x1a0
drivers/media/platform/vicodec/vicodec-core.c:1166
__vb2_queue_cancel+0xb4/0x970
drivers/media/common/videobuf2/videobuf2-core.c:1662
vb2_core_queue_release+0x28/0x80
drivers/media/common/videobuf2/videobuf2-core.c:2051
vb2_queue_release+0x16/0x20
drivers/media/common/videobuf2/videobuf2-v4l2.c:671
v4l2_m2m_ctx_release+0x2d/0x40 drivers/media/v4l2-core/v4l2-mem2mem.c:928
vicodec_release+0xc0/0x120
drivers/media/platform/vicodec/vicodec-core.c:1304
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:0x4120b1
Code: 75 14 b8 03 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 e4 1a 00 00 c3 48
83 ec 08 e8 0a fc ff ff 48 89 04 24 b8 03 00 00 00 0f 05 <48> 8b 3c 24 48
89 c2 e8 53 fc ff ff 48 89 d0 48 83 c4 08 48 3d 01
RSP: 002b:00007fffac386e70 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000004 RCX: 00000000004120b1
RDX: 0000001b2fe20000 RSI: 0000000000740490 RDI: 0000000000000003
RBP: 000000000073c900 R08: 00000000ffc1511e R09: 00000000ffc15122
R10: 00007fffac386f40 R11: 0000000000000293 R12: ffffffffffffffff
R13: 000000000002e11d R14: 00000000000003e8 R15: 000000000073bf0c

Allocated by task 11742:
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
__do_kmalloc_node mm/slab.c:3689 [inline]
__kmalloc_node+0x51/0x80 mm/slab.c:3696
kmalloc_node include/linux/slab.h:557 [inline]
kvmalloc_node+0x68/0x100 mm/util.c:423
kvmalloc include/linux/mm.h:577 [inline]
kvzalloc include/linux/mm.h:585 [inline]
v4l2_ctrl_new.part.0+0x214/0x1460 drivers/media/v4l2-core/v4l2-ctrls.c:2175
v4l2_ctrl_new drivers/media/v4l2-core/v4l2-ctrls.c:2108 [inline]
v4l2_ctrl_new_std+0x22d/0x360 drivers/media/v4l2-core/v4l2-ctrls.c:2293
vicodec_open+0x1a8/0xb30 drivers/media/platform/vicodec/vicodec-core.c:1243
v4l2_open+0x1b8/0x360 drivers/media/v4l2-core/v4l2-dev.c:427
chrdev_open+0x247/0x6b0 fs/char_dev.c:417
do_dentry_open+0x4c6/0x1200 fs/open.c:777
vfs_open+0xa0/0xd0 fs/open.c:886
do_last fs/namei.c:3418 [inline]
path_openat+0x10d7/0x4690 fs/namei.c:3534
do_filp_open+0x1a1/0x280 fs/namei.c:3564
do_sys_open+0x3fe/0x550 fs/open.c:1069
__do_sys_openat fs/open.c:1096 [inline]
__se_sys_openat fs/open.c:1090 [inline]
__x64_sys_openat+0x9d/0x100 fs/open.c:1090
do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 11734:
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
kvfree+0x61/0x70 mm/util.c:452
v4l2_ctrl_handler_free drivers/media/v4l2-core/v4l2-ctrls.c:1929 [inline]
v4l2_ctrl_handler_free+0x4a8/0x7e0
drivers/media/v4l2-core/v4l2-ctrls.c:1909
vicodec_release+0x6b/0x120
drivers/media/platform/vicodec/vicodec-core.c:1302
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

The buggy address belongs to the object at ffff8880a55f1700
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 32 bytes inside of
256-byte region [ffff8880a55f1700, ffff8880a55f1800)
The buggy address belongs to the page:
page:ffffea0002957c40 count:1 mapcount:0 mapping:ffff88812c3f07c0
index:0xffff8880a55f15c0
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffffea00027eb0c8 ffffea000224af88 ffff88812c3f07c0
raw: ffff8880a55f15c0 ffff8880a55f10c0 000000010000000b 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a55f1600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a55f1680: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ffff8880a55f1700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a55f1780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
kobject: 'loop4' (00000000ffbda51e): fill_kobj_path: path
= '/devices/virtual/block/loop4'
ffff8880a55f1800: fc fc fc fc fc fc fc fc 00 00 00 00 00 00 00 00
==================================================================


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Apr 11, 2019, 1:44:07 AM4/11/19
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following crash on:

HEAD commit: 4d552acf Linux 4.19.34
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=1025f6af200000
kernel config: https://syzkaller.appspot.com/x/.config?x=c95a88291f095edd
dashboard link: https://syzkaller.appspot.com/bug?extid=43f0de2c8739cdfafc97
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=17f173c3200000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16ec945b200000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+43f0de...@syzkaller.appspotmail.com

kauditd_printk_skb: 3 callbacks suppressed
audit: type=1400 audit(1554961152.795:35): avc: denied { map } for
pid=7915 comm="bash" path="/bin/bash" dev="sda1" ino=1457
scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=system_u:object_r:file_t:s0 tclass=file permissive=1
audit: type=1400 audit(1554961159.285:36): avc: denied { map } for
pid=7927 comm="syz-executor672" path="/root/syz-executor672796578"
dev="sda1" ino=16482 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
==================================================================
BUG: KASAN: use-after-free in v4l2_ctrl_grab
drivers/media/v4l2-core/v4l2-ctrls.c:2527 [inline]
BUG: KASAN: use-after-free in v4l2_ctrl_grab+0x159/0x160
drivers/media/v4l2-core/v4l2-ctrls.c:2520
Read of size 8 at addr ffff888092c315a0 by task syz-executor672/7927

CPU: 0 PID: 7927 Comm: syz-executor672 Not tainted 4.19.34 #2
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
__do_sys_exit_group kernel/exit.c:990 [inline]
__se_sys_exit_group kernel/exit.c:988 [inline]
__x64_sys_exit_group+0x44/0x50 kernel/exit.c:988
do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x43ee78
Code: Bad RIP value.
RSP: 002b:00007ffc718a0cb8 EFLAGS: 00000246 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 000000000043ee78
RDX: 0000000000000000 RSI: 000000000000003c RDI: 0000000000000000
RBP: 00000000004be748 R08: 00000000000000e7 R09: ffffffffffffffd0
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000001
R13: 00000000006d0180 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 7927:
Freed by task 7927:
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
kvfree+0x61/0x70 mm/util.c:452
v4l2_ctrl_handler_free drivers/media/v4l2-core/v4l2-ctrls.c:1929 [inline]
v4l2_ctrl_handler_free+0x4a8/0x7e0
drivers/media/v4l2-core/v4l2-ctrls.c:1909
vicodec_release+0x6b/0x120
drivers/media/platform/vicodec/vicodec-core.c:1302
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
__do_sys_exit_group kernel/exit.c:990 [inline]
__se_sys_exit_group kernel/exit.c:988 [inline]
__x64_sys_exit_group+0x44/0x50 kernel/exit.c:988
do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff888092c31580
which belongs to the cache kmalloc-256 of size 256
The buggy address is located 32 bytes inside of
256-byte region [ffff888092c31580, ffff888092c31680)
The buggy address belongs to the page:
page:ffffea00024b0c40 count:1 mapcount:0 mapping:ffff88812c3f07c0
index:0xffff888092c31bc0
flags: 0x1fffc0000000100(slab)
raw: 01fffc0000000100 ffffea0002a67588 ffffea00027c3388 ffff88812c3f07c0
raw: ffff888092c31bc0 ffff888092c31080 000000010000000b 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff888092c31480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888092c31500: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
> ffff888092c31580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888092c31600: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888092c31680: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
==================================================================

Reply all
Reply to author
Forward
0 new messages