KASAN: use-after-free Read in vgem_fence_attach_ioctl

7 views
Skip to first unread message

syzbot

unread,
Oct 11, 2020, 4:56:18 PM10/11/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: cbfa1702 Linux 4.14.198
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=172a4a10500000
kernel config: https://syzkaller.appspot.com/x/.config?x=3990958d85b55e59
dashboard link: https://syzkaller.appspot.com/bug?extid=8f8398b7ec13d13e9c99
compiler: gcc (GCC) 10.1.0-syz 20200507
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14271384500000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=13635e58500000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+8f8398...@syzkaller.appspotmail.com

==================================================================
BUG: KASAN: use-after-free in __read_once_size include/linux/compiler.h:183 [inline]
BUG: KASAN: use-after-free in atomic64_read arch/x86/include/asm/atomic64_64.h:22 [inline]
BUG: KASAN: use-after-free in atomic_long_read include/asm-generic/atomic-long.h:45 [inline]
BUG: KASAN: use-after-free in __mutex_trylock_or_owner kernel/locking/mutex.c:84 [inline]
BUG: KASAN: use-after-free in __mutex_trylock kernel/locking/mutex.c:125 [inline]
BUG: KASAN: use-after-free in __mutex_lock_common kernel/locking/mutex.c:758 [inline]
BUG: KASAN: use-after-free in __ww_mutex_lock.constprop.0+0x229d/0x29e0 kernel/locking/mutex.c:901
Read of size 8 at addr ffff8880a7c06f40 by task syz-executor456/19845

CPU: 0 PID: 19845 Comm: syz-executor456 Not tainted 4.14.198-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+0x1b2/0x283 lib/dump_stack.c:58
print_address_description.cold+0x54/0x1d3 mm/kasan/report.c:252
kasan_report_error.cold+0x8a/0x194 mm/kasan/report.c:351
kasan_report mm/kasan/report.c:409 [inline]
__asan_report_load8_noabort+0x68/0x70 mm/kasan/report.c:430
__read_once_size include/linux/compiler.h:183 [inline]
atomic64_read arch/x86/include/asm/atomic64_64.h:22 [inline]
atomic_long_read include/asm-generic/atomic-long.h:45 [inline]
__mutex_trylock_or_owner kernel/locking/mutex.c:84 [inline]
__mutex_trylock kernel/locking/mutex.c:125 [inline]
__mutex_lock_common kernel/locking/mutex.c:758 [inline]
__ww_mutex_lock.constprop.0+0x229d/0x29e0 kernel/locking/mutex.c:901
reservation_object_lock include/linux/reservation.h:166 [inline]
vgem_fence_attach_ioctl+0x35f/0x6e0 drivers/gpu/drm/vgem/vgem_fence.c:193
drm_ioctl_kernel+0x14c/0x200 drivers/gpu/drm/drm_ioctl.c:736
drm_ioctl+0x419/0x870 drivers/gpu/drm/drm_ioctl.c:836
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:500 [inline]
do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
SYSC_ioctl fs/ioctl.c:701 [inline]
SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x44a519
RSP: 002b:00007f70215badb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000006dbc28 RCX: 000000000044a519
RDX: 0000000020000140 RSI: 00000000c10c5541 RDI: 0000000000000004
RBP: 00000000006dbc20 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dbc2c
R13: 00007fffb6c0ad8f R14: 00007f70215bb9c0 R15: 20c49ba5e353f7cf

Allocated by task 19845:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc+0xeb/0x160 mm/kasan/kasan.c:551
__do_kmalloc mm/slab.c:3720 [inline]
__kmalloc+0x15a/0x400 mm/slab.c:3729
kmalloc include/linux/slab.h:493 [inline]
kzalloc include/linux/slab.h:661 [inline]
dma_buf_export+0x20b/0xa20 drivers/dma-buf/dma-buf.c:417
drm_gem_dmabuf_export+0x17/0x70 drivers/gpu/drm/drm_prime.c:317
drm_gem_prime_export+0x16c/0x1d0 drivers/gpu/drm/drm_prime.c:462
attach_dmabuf drivers/gpu/drm/vgem/vgem_fence.c:124 [inline]
vgem_fence_attach_ioctl+0x4e0/0x6e0 drivers/gpu/drm/vgem/vgem_fence.c:173
drm_ioctl_kernel+0x14c/0x200 drivers/gpu/drm/drm_ioctl.c:736
drm_ioctl+0x419/0x870 drivers/gpu/drm/drm_ioctl.c:836
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:500 [inline]
do_vfs_ioctl+0x75a/0xff0 fs/ioctl.c:684
SYSC_ioctl fs/ioctl.c:701 [inline]
SyS_ioctl+0x7f/0xb0 fs/ioctl.c:692
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

Freed by task 19846:
save_stack mm/kasan/kasan.c:447 [inline]
set_track mm/kasan/kasan.c:459 [inline]
kasan_slab_free+0xc3/0x1a0 mm/kasan/kasan.c:524
__cache_free mm/slab.c:3496 [inline]
kfree+0xc9/0x250 mm/slab.c:3815
dma_buf_release+0x2f7/0x5c0 drivers/dma-buf/dma-buf.c:80
__fput+0x25f/0x7a0 fs/file_table.c:210
task_work_run+0x11f/0x190 kernel/task_work.c:113
tracehook_notify_resume include/linux/tracehook.h:191 [inline]
exit_to_usermode_loop+0x1ad/0x200 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+0x4a3/0x640 arch/x86/entry/common.c:297
entry_SYSCALL_64_after_hwframe+0x46/0xbb

The buggy address belongs to the object at ffff8880a7c06dc0
which belongs to the cache kmalloc-1024 of size 1024
The buggy address is located 384 bytes inside of
1024-byte region [ffff8880a7c06dc0, ffff8880a7c071c0)
The buggy address belongs to the page:
page:ffffea00029f0180 count:1 mapcount:0 mapping:ffff8880a7c06040 index:0x0 compound_mapcount: 0
flags: 0xfffe0000008100(slab|head)
raw: 00fffe0000008100 ffff8880a7c06040 0000000000000000 0000000100000007
raw: ffffea00029e08a0 ffffea00029fd9a0 ffff88812fe50ac0 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
ffff8880a7c06e00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a7c06e80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880a7c06f00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880a7c06f80: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880a7c07000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
random: crng init done
random: 7 urandom warning(s) missed due to ratelimiting


---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages