syzbot


KASAN: use-after-free Read in vgem_fence_attach_ioctl

Status: upstream: reported C repro on 2020/10/11 20:56
Reported-by: syzbot+8f8398b7ec13d13e9c99@syzkaller.appspotmail.com
First crash: 1514d, last: 654d
Similar bugs (1)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-4.19 KASAN: use-after-free Read in vgem_fence_attach_ioctl 1 1492d 1492d 0/1 auto-closed as invalid on 2021/03/02 21:56
Fix bisection attempts (25)
Created Duration User Patch Repo Result
2023/02/19 00:47 35m bisect fix linux-4.14.y OK (0) job log log
2023/01/19 15:57 39m bisect fix linux-4.14.y OK (0) job log log
2022/10/26 13:39 35m bisect fix linux-4.14.y OK (0) job log log
2022/09/17 01:27 30m bisect fix linux-4.14.y OK (0) job log log
2022/08/18 00:53 34m bisect fix linux-4.14.y OK (0) job log log
2022/07/19 00:17 35m bisect fix linux-4.14.y OK (0) job log log
2022/06/18 23:43 34m bisect fix linux-4.14.y OK (0) job log log
2022/05/19 07:44 34m bisect fix linux-4.14.y OK (0) job log log
2022/04/19 07:08 35m bisect fix linux-4.14.y OK (0) job log log
2022/03/19 21:23 35m bisect fix linux-4.14.y OK (0) job log log
2022/02/17 20:46 36m bisect fix linux-4.14.y OK (0) job log log
2022/01/18 19:44 37m bisect fix linux-4.14.y OK (0) job log log
2021/12/19 19:09 34m bisect fix linux-4.14.y OK (0) job log log
2021/11/19 18:33 35m bisect fix linux-4.14.y OK (0) job log log
2021/10/20 17:58 34m bisect fix linux-4.14.y OK (0) job log log
2021/09/20 17:21 30m bisect fix linux-4.14.y OK (0) job log log
2021/08/21 16:49 31m bisect fix linux-4.14.y OK (0) job log log
2021/07/22 15:58 33m bisect fix linux-4.14.y OK (0) job log log
2021/06/22 13:18 36m bisect fix linux-4.14.y OK (0) job log log
2021/05/23 04:12 34m bisect fix linux-4.14.y OK (0) job log log
2021/04/23 02:39 39m bisect fix linux-4.14.y OK (0) job log log
2021/03/23 21:47 35m bisect fix linux-4.14.y OK (0) job log log
2021/02/21 20:38 36m bisect fix linux-4.14.y OK (0) job log log
2021/02/18 09:37 19m bisect fix linux-4.14.y error job log
2021/02/09 00:35 0m bisect fix linux-4.14.y error job log

Sample crash report:
==================================================================
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

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2020/10/11 20:55 linux-4.14.y cbfa1702aaf6 4a77ae0b .config console log report syz C ci2-linux-4-14
* Struck through repros no longer work on HEAD.