* KASAN: use-after-free Read in drm_gem_object_release
@ 2018-10-25 19:18 syzbot
2018-10-29 11:51 ` Dmitry Vyukov
0 siblings, 1 reply; 17+ messages in thread
From: syzbot @ 2018-10-25 19:18 UTC (permalink / raw)
To: linux-kernel, syzkaller-bugs
Hello,
syzbot found the following crash on:
HEAD commit: bd6bf7c10484 Merge tag 'pci-v4.20-changes' of git://git.ke..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1448a683400000
kernel config: https://syzkaller.appspot.com/x/.config?x=2dd8629d56664133
dashboard link: https://syzkaller.appspot.com/bug?extid=e73f2fb5ed5a5df36d33
compiler: gcc (GCC) 8.0.1 20180413 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11331de5400000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1334e64d400000
IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+e73f2fb5ed5a5df36d33@syzkaller.appspotmail.com
drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
==================================================================
BUG: KASAN: use-after-free in drm_gem_object_release+0xf1/0x110
drivers/gpu/drm/drm_gem.c:813
Read of size 8 at addr ffff8801d83d3410 by task syz-executor977/6742
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
__do_sys_ioctl fs/ioctl.c:709 [inline]
__se_sys_ioctl fs/ioctl.c:707 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x445989
Code: e8 4c e8 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 6b c8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffcf076f4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffcf076f500 RCX: 0000000000445989
RDX: 0000000020000000 RSI: ffffffffffffffb2 RDI: 0000000000000003
RBP: 0000000000000004 R08: 0000000000000001 R09: 0000000000000100
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: ffffffffffffffff R14: 0000000000000000 R15: 0000000000000000
CPU: 0 PID: 6742 Comm: syz-executor977 Not tainted 4.19.0+ #80
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+0x244/0x39d lib/dump_stack.c:113
print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
kasan_report_error mm/kasan/report.c:354 [inline]
kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
__asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
drm_gem_object_release+0xf1/0x110 drivers/gpu/drm/drm_gem.c:813
__vgem_gem_destroy drivers/gpu/drm/vgem/vgem_drv.c:175 [inline]
vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:199 [inline]
vgem_gem_dumb_create+0x1f8/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
__do_sys_ioctl fs/ioctl.c:709 [inline]
__se_sys_ioctl fs/ioctl.c:707 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x445989
Code: e8 4c e8 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 6b c8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffcf076f4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffcf076f500 RCX: 0000000000445989
RDX: 0000000020000000 RSI: ffffffffffffffb2 RDI: 0000000000000003
RBP: 0000000000000004 R08: 0000000000000001 R09: 0000000000000100
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: ffffffffffffffff R14: 0000000000000000 R15: 0000000000000000
Allocated by task 6742:
save_stack+0x43/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
kmalloc include/linux/slab.h:513 [inline]
kzalloc include/linux/slab.h:707 [inline]
__vgem_gem_create+0x4c/0x100 drivers/gpu/drm/vgem/vgem_drv.c:158
vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:187 [inline]
vgem_gem_dumb_create+0xce/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
__do_sys_ioctl fs/ioctl.c:709 [inline]
__se_sys_ioctl fs/ioctl.c:707 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Freed by task 6742:
save_stack+0x43/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:3498 [inline]
kfree+0xcf/0x230 mm/slab.c:3813
vgem_gem_free_object+0xb6/0xe0 drivers/gpu/drm/vgem/vgem_drv.c:61
drm_gem_object_free+0xf1/0x2b0 drivers/gpu/drm/drm_gem.c:839
kref_put include/linux/kref.h:70 [inline]
drm_gem_object_put_unlocked+0x14c/0x180 drivers/gpu/drm/drm_gem.c:895
vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:192 [inline]
vgem_gem_dumb_create+0x120/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
__do_sys_ioctl fs/ioctl.c:709 [inline]
__se_sys_ioctl fs/ioctl.c:707 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff8801d83d3300
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 272 bytes inside of
512-byte region [ffff8801d83d3300, ffff8801d83d3500)
The buggy address belongs to the page:
page:ffffea000760f4c0 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea0007473948 ffffea0007471dc8 ffff8801da800940
raw: 0000000000000000 ffff8801d83d3080 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8801d83d3300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d83d3380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8801d83d3400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801d83d3480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d83d3500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
==================================================================
==================================================================
CPU: 0 PID: 6778 Comm: syz-executor977 Tainted: G B 4.19.0+
#80
BUG: KASAN: double-free or invalid-free in __vgem_gem_destroy
drivers/gpu/drm/vgem/vgem_drv.c:176 [inline]
BUG: KASAN: double-free or invalid-free in vgem_gem_create
drivers/gpu/drm/vgem/vgem_drv.c:199 [inline]
BUG: KASAN: double-free or invalid-free in vgem_gem_dumb_create+0x203/0x260
drivers/gpu/drm/vgem/vgem_drv.c:214
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+0x244/0x39d lib/dump_stack.c:113
fail_dump lib/fault-inject.c:51 [inline]
should_fail.cold.4+0xa/0x17 lib/fault-inject.c:149
__should_failslab+0x124/0x180 mm/failslab.c:32
should_failslab+0x9/0x14 mm/slab_common.c:1557
slab_pre_alloc_hook mm/slab.h:423 [inline]
slab_alloc mm/slab.c:3378 [inline]
kmem_cache_alloc_trace+0x2d7/0x750 mm/slab.c:3618
kmalloc include/linux/slab.h:513 [inline]
drm_vma_node_allow+0x5f/0x290 drivers/gpu/drm/drm_vma_manager.c:277
drm_gem_handle_create_tail+0x233/0x440 drivers/gpu/drm/drm_gem.c:409
drm_gem_handle_create+0x52/0x60 drivers/gpu/drm/drm_gem.c:452
vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:191 [inline]
vgem_gem_dumb_create+0x115/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
__do_sys_ioctl fs/ioctl.c:709 [inline]
__se_sys_ioctl fs/ioctl.c:707 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x445989
Code: e8 4c e8 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 6b c8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffcf076f4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffcf076f500 RCX: 0000000000445989
RDX: 0000000020000000 RSI: ffffffffffffffb2 RDI: 0000000000000003
RBP: 0000000000000004 R08: 0000000000000001 R09: 0000000000000100
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: ffffffffffffffff R14: 0000000000000000 R15: 0000000000000000
CPU: 1 PID: 6767 Comm: syz-executor977 Tainted: G B 4.19.0+
#80
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+0x244/0x39d lib/dump_stack.c:113
print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
kasan_report_invalid_free+0x64/0xa0 mm/kasan/report.c:336
__kasan_slab_free+0x13a/0x150 mm/kasan/kasan.c:501
kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
__cache_free mm/slab.c:3498 [inline]
kfree+0xcf/0x230 mm/slab.c:3813
__vgem_gem_destroy drivers/gpu/drm/vgem/vgem_drv.c:176 [inline]
vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:199 [inline]
vgem_gem_dumb_create+0x203/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
__do_sys_ioctl fs/ioctl.c:709 [inline]
__se_sys_ioctl fs/ioctl.c:707 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x445989
Code: e8 4c e8 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 6b c8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffcf076f4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007ffcf076f500 RCX: 0000000000445989
RDX: 0000000020000000 RSI: ffffffffffffffb2 RDI: 0000000000000003
RBP: 0000000000000004 R08: 0000000000000001 R09: 0000000000000100
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: ffffffffffffffff R14: 0000000000000000 R15: 0000000000000000
Allocated by task 6767:
save_stack+0x43/0xd0 mm/kasan/kasan.c:448
set_track mm/kasan/kasan.c:460 [inline]
kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
kmalloc include/linux/slab.h:513 [inline]
kzalloc include/linux/slab.h:707 [inline]
__vgem_gem_create+0x4c/0x100 drivers/gpu/drm/vgem/vgem_drv.c:158
vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:187 [inline]
vgem_gem_dumb_create+0xce/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
__do_sys_ioctl fs/ioctl.c:709 [inline]
__se_sys_ioctl fs/ioctl.c:707 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Freed by task 6767:
save_stack+0x43/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:3498 [inline]
kfree+0xcf/0x230 mm/slab.c:3813
vgem_gem_free_object+0xb6/0xe0 drivers/gpu/drm/vgem/vgem_drv.c:61
drm_gem_object_free+0xf1/0x2b0 drivers/gpu/drm/drm_gem.c:839
kref_put include/linux/kref.h:70 [inline]
drm_gem_object_put_unlocked+0x14c/0x180 drivers/gpu/drm/drm_gem.c:895
vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:192 [inline]
vgem_gem_dumb_create+0x120/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
vfs_ioctl fs/ioctl.c:46 [inline]
file_ioctl fs/ioctl.c:501 [inline]
do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
__do_sys_ioctl fs/ioctl.c:709 [inline]
__se_sys_ioctl fs/ioctl.c:707 [inline]
__x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff8801d4974080
which belongs to the cache kmalloc-512 of size 512
The buggy address is located 0 bytes inside of
512-byte region [ffff8801d4974080, ffff8801d4974280)
The buggy address belongs to the page:
page:ffffea0007525d00 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
flags: 0x2fffc0000000100(slab)
raw: 02fffc0000000100 ffffea0007558e48 ffffea00071d0508 ffff8801da800940
raw: 0000000000000000 ffff8801d4974080 0000000100000006 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8801d4973f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
ffff8801d4974000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8801d4974080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8801d4974100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8801d4974180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
==================================================================
---
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 syzkaller@googlegroups.com.
syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2018-10-25 19:18 KASAN: use-after-free Read in drm_gem_object_release syzbot
@ 2018-10-29 11:51 ` Dmitry Vyukov
2019-02-26 20:47 ` [PATCH] drm/vgem: fix use-after-free when drm_gem_handle_create() fails Eric Biggers
0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Vyukov @ 2018-10-29 11:51 UTC (permalink / raw)
To: syzbot, Gustavo Padovan, maarten.lankhorst, sean, David Airlie, DRI
Cc: LKML, syzkaller-bugs
On Thu, Oct 25, 2018 at 9:18 PM, syzbot
<syzbot+e73f2fb5ed5a5df36d33@syzkaller.appspotmail.com> wrote:
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: bd6bf7c10484 Merge tag 'pci-v4.20-changes' of git://git.ke..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=1448a683400000
> kernel config: https://syzkaller.appspot.com/x/.config?x=2dd8629d56664133
> dashboard link: https://syzkaller.appspot.com/bug?extid=e73f2fb5ed5a5df36d33
> compiler: gcc (GCC) 8.0.1 20180413 (experimental)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11331de5400000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1334e64d400000
+drm maintainers
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+e73f2fb5ed5a5df36d33@syzkaller.appspotmail.com
>
> drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
> drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
> drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
> drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
> ==================================================================
> BUG: KASAN: use-after-free in drm_gem_object_release+0xf1/0x110
> drivers/gpu/drm/drm_gem.c:813
> Read of size 8 at addr ffff8801d83d3410 by task syz-executor977/6742
>
> vfs_ioctl fs/ioctl.c:46 [inline]
> file_ioctl fs/ioctl.c:501 [inline]
> do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> __do_sys_ioctl fs/ioctl.c:709 [inline]
> __se_sys_ioctl fs/ioctl.c:707 [inline]
> __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x445989
> Code: e8 4c e8 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 6b c8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:00007ffcf076f4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 00007ffcf076f500 RCX: 0000000000445989
> RDX: 0000000020000000 RSI: ffffffffffffffb2 RDI: 0000000000000003
> RBP: 0000000000000004 R08: 0000000000000001 R09: 0000000000000100
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> R13: ffffffffffffffff R14: 0000000000000000 R15: 0000000000000000
> CPU: 0 PID: 6742 Comm: syz-executor977 Not tainted 4.19.0+ #80
> 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+0x244/0x39d lib/dump_stack.c:113
> print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
> kasan_report_error mm/kasan/report.c:354 [inline]
> kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
> __asan_report_load8_noabort+0x14/0x20 mm/kasan/report.c:433
> drm_gem_object_release+0xf1/0x110 drivers/gpu/drm/drm_gem.c:813
> __vgem_gem_destroy drivers/gpu/drm/vgem/vgem_drv.c:175 [inline]
> vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:199 [inline]
> vgem_gem_dumb_create+0x1f8/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
> drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
> drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
> drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
> drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
> vfs_ioctl fs/ioctl.c:46 [inline]
> file_ioctl fs/ioctl.c:501 [inline]
> do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> __do_sys_ioctl fs/ioctl.c:709 [inline]
> __se_sys_ioctl fs/ioctl.c:707 [inline]
> __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x445989
> Code: e8 4c e8 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 6b c8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:00007ffcf076f4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 00007ffcf076f500 RCX: 0000000000445989
> RDX: 0000000020000000 RSI: ffffffffffffffb2 RDI: 0000000000000003
> RBP: 0000000000000004 R08: 0000000000000001 R09: 0000000000000100
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> R13: ffffffffffffffff R14: 0000000000000000 R15: 0000000000000000
>
> Allocated by task 6742:
> save_stack+0x43/0xd0 mm/kasan/kasan.c:448
> set_track mm/kasan/kasan.c:460 [inline]
> kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
> kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
> kmalloc include/linux/slab.h:513 [inline]
> kzalloc include/linux/slab.h:707 [inline]
> __vgem_gem_create+0x4c/0x100 drivers/gpu/drm/vgem/vgem_drv.c:158
> vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:187 [inline]
> vgem_gem_dumb_create+0xce/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
> drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
> drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
> drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
> drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
> vfs_ioctl fs/ioctl.c:46 [inline]
> file_ioctl fs/ioctl.c:501 [inline]
> do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> __do_sys_ioctl fs/ioctl.c:709 [inline]
> __se_sys_ioctl fs/ioctl.c:707 [inline]
> __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> Freed by task 6742:
> save_stack+0x43/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:3498 [inline]
> kfree+0xcf/0x230 mm/slab.c:3813
> vgem_gem_free_object+0xb6/0xe0 drivers/gpu/drm/vgem/vgem_drv.c:61
> drm_gem_object_free+0xf1/0x2b0 drivers/gpu/drm/drm_gem.c:839
> kref_put include/linux/kref.h:70 [inline]
> drm_gem_object_put_unlocked+0x14c/0x180 drivers/gpu/drm/drm_gem.c:895
> vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:192 [inline]
> vgem_gem_dumb_create+0x120/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
> drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
> drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
> drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
> drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
> vfs_ioctl fs/ioctl.c:46 [inline]
> file_ioctl fs/ioctl.c:501 [inline]
> do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> __do_sys_ioctl fs/ioctl.c:709 [inline]
> __se_sys_ioctl fs/ioctl.c:707 [inline]
> __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> The buggy address belongs to the object at ffff8801d83d3300
> which belongs to the cache kmalloc-512 of size 512
> The buggy address is located 272 bytes inside of
> 512-byte region [ffff8801d83d3300, ffff8801d83d3500)
> The buggy address belongs to the page:
> page:ffffea000760f4c0 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
> flags: 0x2fffc0000000100(slab)
> raw: 02fffc0000000100 ffffea0007473948 ffffea0007471dc8 ffff8801da800940
> raw: 0000000000000000 ffff8801d83d3080 0000000100000006 0000000000000000
> page dumped because: kasan: bad access detected
>
> Memory state around the buggy address:
> ffff8801d83d3300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8801d83d3380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>>
>> ffff8801d83d3400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>
> ^
> ffff8801d83d3480: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8801d83d3500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ==================================================================
> ==================================================================
> CPU: 0 PID: 6778 Comm: syz-executor977 Tainted: G B 4.19.0+
> #80
> BUG: KASAN: double-free or invalid-free in __vgem_gem_destroy
> drivers/gpu/drm/vgem/vgem_drv.c:176 [inline]
> BUG: KASAN: double-free or invalid-free in vgem_gem_create
> drivers/gpu/drm/vgem/vgem_drv.c:199 [inline]
> BUG: KASAN: double-free or invalid-free in vgem_gem_dumb_create+0x203/0x260
> drivers/gpu/drm/vgem/vgem_drv.c:214
> 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+0x244/0x39d lib/dump_stack.c:113
> fail_dump lib/fault-inject.c:51 [inline]
> should_fail.cold.4+0xa/0x17 lib/fault-inject.c:149
> __should_failslab+0x124/0x180 mm/failslab.c:32
> should_failslab+0x9/0x14 mm/slab_common.c:1557
> slab_pre_alloc_hook mm/slab.h:423 [inline]
> slab_alloc mm/slab.c:3378 [inline]
> kmem_cache_alloc_trace+0x2d7/0x750 mm/slab.c:3618
> kmalloc include/linux/slab.h:513 [inline]
> drm_vma_node_allow+0x5f/0x290 drivers/gpu/drm/drm_vma_manager.c:277
> drm_gem_handle_create_tail+0x233/0x440 drivers/gpu/drm/drm_gem.c:409
> drm_gem_handle_create+0x52/0x60 drivers/gpu/drm/drm_gem.c:452
> vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:191 [inline]
> vgem_gem_dumb_create+0x115/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
> drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
> drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
> drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
> drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
> vfs_ioctl fs/ioctl.c:46 [inline]
> file_ioctl fs/ioctl.c:501 [inline]
> do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> __do_sys_ioctl fs/ioctl.c:709 [inline]
> __se_sys_ioctl fs/ioctl.c:707 [inline]
> __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x445989
> Code: e8 4c e8 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 6b c8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:00007ffcf076f4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 00007ffcf076f500 RCX: 0000000000445989
> RDX: 0000000020000000 RSI: ffffffffffffffb2 RDI: 0000000000000003
> RBP: 0000000000000004 R08: 0000000000000001 R09: 0000000000000100
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> R13: ffffffffffffffff R14: 0000000000000000 R15: 0000000000000000
> CPU: 1 PID: 6767 Comm: syz-executor977 Tainted: G B 4.19.0+
> #80
> 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+0x244/0x39d lib/dump_stack.c:113
> print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
> kasan_report_invalid_free+0x64/0xa0 mm/kasan/report.c:336
> __kasan_slab_free+0x13a/0x150 mm/kasan/kasan.c:501
> kasan_slab_free+0xe/0x10 mm/kasan/kasan.c:528
> __cache_free mm/slab.c:3498 [inline]
> kfree+0xcf/0x230 mm/slab.c:3813
> __vgem_gem_destroy drivers/gpu/drm/vgem/vgem_drv.c:176 [inline]
> vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:199 [inline]
> vgem_gem_dumb_create+0x203/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
> drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
> drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
> drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
> drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
> vfs_ioctl fs/ioctl.c:46 [inline]
> file_ioctl fs/ioctl.c:501 [inline]
> do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> __do_sys_ioctl fs/ioctl.c:709 [inline]
> __se_sys_ioctl fs/ioctl.c:707 [inline]
> __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
> RIP: 0033:0x445989
> Code: e8 4c e8 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 6b c8 fb ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:00007ffcf076f4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 00007ffcf076f500 RCX: 0000000000445989
> RDX: 0000000020000000 RSI: ffffffffffffffb2 RDI: 0000000000000003
> RBP: 0000000000000004 R08: 0000000000000001 R09: 0000000000000100
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
> R13: ffffffffffffffff R14: 0000000000000000 R15: 0000000000000000
>
> Allocated by task 6767:
> save_stack+0x43/0xd0 mm/kasan/kasan.c:448
> set_track mm/kasan/kasan.c:460 [inline]
> kasan_kmalloc+0xc7/0xe0 mm/kasan/kasan.c:553
> kmem_cache_alloc_trace+0x152/0x750 mm/slab.c:3620
> kmalloc include/linux/slab.h:513 [inline]
> kzalloc include/linux/slab.h:707 [inline]
> __vgem_gem_create+0x4c/0x100 drivers/gpu/drm/vgem/vgem_drv.c:158
> vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:187 [inline]
> vgem_gem_dumb_create+0xce/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
> drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
> drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
> drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
> drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
> vfs_ioctl fs/ioctl.c:46 [inline]
> file_ioctl fs/ioctl.c:501 [inline]
> do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> __do_sys_ioctl fs/ioctl.c:709 [inline]
> __se_sys_ioctl fs/ioctl.c:707 [inline]
> __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> Freed by task 6767:
> save_stack+0x43/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:3498 [inline]
> kfree+0xcf/0x230 mm/slab.c:3813
> vgem_gem_free_object+0xb6/0xe0 drivers/gpu/drm/vgem/vgem_drv.c:61
> drm_gem_object_free+0xf1/0x2b0 drivers/gpu/drm/drm_gem.c:839
> kref_put include/linux/kref.h:70 [inline]
> drm_gem_object_put_unlocked+0x14c/0x180 drivers/gpu/drm/drm_gem.c:895
> vgem_gem_create drivers/gpu/drm/vgem/vgem_drv.c:192 [inline]
> vgem_gem_dumb_create+0x120/0x260 drivers/gpu/drm/vgem/vgem_drv.c:214
> drm_mode_create_dumb+0x28d/0x310 drivers/gpu/drm/drm_dumb_buffers.c:92
> drm_mode_create_dumb_ioctl+0x25/0x30 drivers/gpu/drm/drm_dumb_buffers.c:98
> drm_ioctl_kernel+0x245/0x2f0 drivers/gpu/drm/drm_ioctl.c:751
> drm_ioctl+0x57a/0xb20 drivers/gpu/drm/drm_ioctl.c:847
> vfs_ioctl fs/ioctl.c:46 [inline]
> file_ioctl fs/ioctl.c:501 [inline]
> do_vfs_ioctl+0x1de/0x1720 fs/ioctl.c:685
> ksys_ioctl+0xa9/0xd0 fs/ioctl.c:702
> __do_sys_ioctl fs/ioctl.c:709 [inline]
> __se_sys_ioctl fs/ioctl.c:707 [inline]
> __x64_sys_ioctl+0x73/0xb0 fs/ioctl.c:707
> do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
> entry_SYSCALL_64_after_hwframe+0x49/0xbe
>
> The buggy address belongs to the object at ffff8801d4974080
> which belongs to the cache kmalloc-512 of size 512
> The buggy address is located 0 bytes inside of
> 512-byte region [ffff8801d4974080, ffff8801d4974280)
> The buggy address belongs to the page:
> page:ffffea0007525d00 count:1 mapcount:0 mapping:ffff8801da800940 index:0x0
> flags: 0x2fffc0000000100(slab)
> raw: 02fffc0000000100 ffffea0007558e48 ffffea00071d0508 ffff8801da800940
> raw: 0000000000000000 ffff8801d4974080 0000000100000006 0000000000000000
> page dumped because: kasan: bad access detected
>
> Memory state around the buggy address:
> ffff8801d4973f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
> ffff8801d4974000: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>>
>> ffff8801d4974080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>
> ^
> ffff8801d4974100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff8801d4974180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ==================================================================
> ==================================================================
>
>
> ---
> 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 syzkaller@googlegroups.com.
>
> syzbot will keep track of this bug report. See:
> https://goo.gl/tpsmEJ#bug-status-tracking for how to communicate with
> syzbot.
> syzbot can test patches for this bug, for details see:
> https://goo.gl/tpsmEJ#testing-patches
>
> --
> You received this message because you are subscribed to the Google Groups
> "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/syzkaller-bugs/00000000000053fea105791276d8%40google.com.
> For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH] drm/vgem: fix use-after-free when drm_gem_handle_create() fails
2018-10-29 11:51 ` Dmitry Vyukov
@ 2019-02-26 20:47 ` Eric Biggers
2019-02-26 21:01 ` Chris Wilson
0 siblings, 1 reply; 17+ messages in thread
From: Eric Biggers @ 2019-02-26 20:47 UTC (permalink / raw)
To: dri-devel, David Airlie, Daniel Vetter
Cc: Chris Wilson, syzkaller-bugs, linux-kernel
From: Eric Biggers <ebiggers@google.com>
If drm_gem_handle_create() fails in vgem_gem_create(), then the
drm_vgem_gem_object is freed twice: once when the reference is dropped
by drm_gem_object_put_unlocked(), and again by __vgem_gem_destroy().
This was hit by syzkaller using fault injection.
Fix it by skipping the second free.
Reported-by: syzbot+e73f2fb5ed5a5df36d33@syzkaller.appspotmail.com
Fixes: 5ba6c9ff961a ("drm/vgem: Fix mmaping")
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
drivers/gpu/drm/vgem/vgem_drv.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
index 5930facd6d2d8..70646d9da1596 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.c
+++ b/drivers/gpu/drm/vgem/vgem_drv.c
@@ -189,15 +189,13 @@ static struct drm_gem_object *vgem_gem_create(struct drm_device *dev,
return ERR_CAST(obj);
ret = drm_gem_handle_create(file, &obj->base, handle);
+
drm_gem_object_put_unlocked(&obj->base);
+
if (ret)
- goto err;
+ return ERR_PTR(ret);
return &obj->base;
-
-err:
- __vgem_gem_destroy(obj);
- return ERR_PTR(ret);
}
static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
--
2.21.0.rc2.261.ga7da99ff1b-goog
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/vgem: fix use-after-free when drm_gem_handle_create() fails
2019-02-26 20:47 ` [PATCH] drm/vgem: fix use-after-free when drm_gem_handle_create() fails Eric Biggers
@ 2019-02-26 21:01 ` Chris Wilson
2019-02-26 21:30 ` Eric Biggers
0 siblings, 1 reply; 17+ messages in thread
From: Chris Wilson @ 2019-02-26 21:01 UTC (permalink / raw)
To: Daniel Vetter, David Airlie, Eric Biggers, dri-devel
Cc: syzkaller-bugs, linux-kernel
Quoting Eric Biggers (2019-02-26 20:47:26)
> From: Eric Biggers <ebiggers@google.com>
>
> If drm_gem_handle_create() fails in vgem_gem_create(), then the
> drm_vgem_gem_object is freed twice: once when the reference is dropped
> by drm_gem_object_put_unlocked(), and again by __vgem_gem_destroy().
>
> This was hit by syzkaller using fault injection.
>
> Fix it by skipping the second free.
>
> Reported-by: syzbot+e73f2fb5ed5a5df36d33@syzkaller.appspotmail.com
> Fixes: 5ba6c9ff961a ("drm/vgem: Fix mmaping")
That's the wrong fixes line, it's
Fixes: af33a9190d02 ("drm/vgem: Enable dmabuf import interfaces")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Sadly I reviewed it so I'm still culpable, but the fix is correct as the
put purposely frees it on error.
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> drivers/gpu/drm/vgem/vgem_drv.c | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
> index 5930facd6d2d8..70646d9da1596 100644
> --- a/drivers/gpu/drm/vgem/vgem_drv.c
> +++ b/drivers/gpu/drm/vgem/vgem_drv.c
> @@ -189,15 +189,13 @@ static struct drm_gem_object *vgem_gem_create(struct drm_device *dev,
> return ERR_CAST(obj);
>
> ret = drm_gem_handle_create(file, &obj->base, handle);
> +
> drm_gem_object_put_unlocked(&obj->base);
> +
The pattern in the other GEM drivers is not to have these extra
newlines.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> if (ret)
> - goto err;
> + return ERR_PTR(ret);
>
> return &obj->base;
> -
> -err:
> - __vgem_gem_destroy(obj);
> - return ERR_PTR(ret);
> }
>
> static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
> --
> 2.21.0.rc2.261.ga7da99ff1b-goog
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/vgem: fix use-after-free when drm_gem_handle_create() fails
2019-02-26 21:01 ` Chris Wilson
@ 2019-02-26 21:30 ` Eric Biggers
2019-02-26 21:44 ` [PATCH v2] " Eric Biggers
2019-02-26 22:08 ` [PATCH] drm/vkms: " Eric Biggers
0 siblings, 2 replies; 17+ messages in thread
From: Eric Biggers @ 2019-02-26 21:30 UTC (permalink / raw)
To: Chris Wilson
Cc: Daniel Vetter, David Airlie, dri-devel, syzkaller-bugs, linux-kernel
On Tue, Feb 26, 2019 at 09:01:29PM +0000, Chris Wilson wrote:
> Quoting Eric Biggers (2019-02-26 20:47:26)
> > From: Eric Biggers <ebiggers@google.com>
> >
> > If drm_gem_handle_create() fails in vgem_gem_create(), then the
> > drm_vgem_gem_object is freed twice: once when the reference is dropped
> > by drm_gem_object_put_unlocked(), and again by __vgem_gem_destroy().
> >
> > This was hit by syzkaller using fault injection.
> >
> > Fix it by skipping the second free.
> >
> > Reported-by: syzbot+e73f2fb5ed5a5df36d33@syzkaller.appspotmail.com
> > Fixes: 5ba6c9ff961a ("drm/vgem: Fix mmaping")
>
> That's the wrong fixes line, it's
> Fixes: af33a9190d02 ("drm/vgem: Enable dmabuf import interfaces")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Laura Abbott <labbott@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>
> Sadly I reviewed it so I'm still culpable, but the fix is correct as the
> put purposely frees it on error.
>
You're right; I misread the code at that commit.
I'll resend with the correct tags.
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
>
> > ---
> > drivers/gpu/drm/vgem/vgem_drv.c | 8 +++-----
> > 1 file changed, 3 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
> > index 5930facd6d2d8..70646d9da1596 100644
> > --- a/drivers/gpu/drm/vgem/vgem_drv.c
> > +++ b/drivers/gpu/drm/vgem/vgem_drv.c
> > @@ -189,15 +189,13 @@ static struct drm_gem_object *vgem_gem_create(struct drm_device *dev,
> > return ERR_CAST(obj);
> >
> > ret = drm_gem_handle_create(file, &obj->base, handle);
> > +
> > drm_gem_object_put_unlocked(&obj->base);
> > +
>
> The pattern in the other GEM drivers is not to have these extra
> newlines.
>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
>
> > if (ret)
> > - goto err;
> > + return ERR_PTR(ret);
> >
> > return &obj->base;
> > -
> > -err:
> > - __vgem_gem_destroy(obj);
> > - return ERR_PTR(ret);
> > }
> >
> > static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
> > --
> > 2.21.0.rc2.261.ga7da99ff1b-goog
> >
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH v2] drm/vgem: fix use-after-free when drm_gem_handle_create() fails
2019-02-26 21:30 ` Eric Biggers
@ 2019-02-26 21:44 ` Eric Biggers
2019-02-27 23:52 ` Laura Abbott
2019-03-04 23:24 ` Rodrigo Siqueira
2019-02-26 22:08 ` [PATCH] drm/vkms: " Eric Biggers
1 sibling, 2 replies; 17+ messages in thread
From: Eric Biggers @ 2019-02-26 21:44 UTC (permalink / raw)
To: dri-devel
Cc: Chris Wilson, syzkaller-bugs, linux-kernel,
syzbot+e73f2fb5ed5a5df36d33, Laura Abbott, Daniel Vetter, stable
From: Eric Biggers <ebiggers@google.com>
If drm_gem_handle_create() fails in vgem_gem_create(), then the
drm_vgem_gem_object is freed twice: once when the reference is dropped
by drm_gem_object_put_unlocked(), and again by __vgem_gem_destroy().
This was hit by syzkaller using fault injection.
Fix it by skipping the second free.
Reported-by: syzbot+e73f2fb5ed5a5df36d33@syzkaller.appspotmail.com
Fixes: af33a9190d02 ("drm/vgem: Enable dmabuf import interfaces")
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
drivers/gpu/drm/vgem/vgem_drv.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
index 5930facd6d2d8..11a8f99ba18c5 100644
--- a/drivers/gpu/drm/vgem/vgem_drv.c
+++ b/drivers/gpu/drm/vgem/vgem_drv.c
@@ -191,13 +191,9 @@ static struct drm_gem_object *vgem_gem_create(struct drm_device *dev,
ret = drm_gem_handle_create(file, &obj->base, handle);
drm_gem_object_put_unlocked(&obj->base);
if (ret)
- goto err;
+ return ERR_PTR(ret);
return &obj->base;
-
-err:
- __vgem_gem_destroy(obj);
- return ERR_PTR(ret);
}
static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
--
2.21.0.rc2.261.ga7da99ff1b-goog
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH] drm/vkms: fix use-after-free when drm_gem_handle_create() fails
2019-02-26 21:30 ` Eric Biggers
2019-02-26 21:44 ` [PATCH v2] " Eric Biggers
@ 2019-02-26 22:08 ` Eric Biggers
2019-02-26 22:14 ` Chris Wilson
2019-02-27 23:12 ` Rodrigo Siqueira
1 sibling, 2 replies; 17+ messages in thread
From: Eric Biggers @ 2019-02-26 22:08 UTC (permalink / raw)
To: dri-devel
Cc: syzkaller-bugs, linux-kernel, Rodrigo Siqueira, Haneen Mohammed,
Daniel Vetter, Chris Wilson, stable
From: Eric Biggers <ebiggers@google.com>
If drm_gem_handle_create() fails in vkms_gem_create(), then the
vkms_gem_object is freed twice: once when the reference is dropped by
drm_gem_object_put_unlocked(), and again by the extra calls to
drm_gem_object_release() and kfree().
Fix it by skipping the second release and free.
This bug was originally found in the vgem driver by syzkaller using
fault injection, but I noticed it's also present in the vkms driver.
Fixes: 559e50fd34d1 ("drm/vkms: Add dumb operations")
Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
---
drivers/gpu/drm/vkms/vkms_gem.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c
index 138b0bb325cf9..69048e73377dc 100644
--- a/drivers/gpu/drm/vkms/vkms_gem.c
+++ b/drivers/gpu/drm/vkms/vkms_gem.c
@@ -111,11 +111,8 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
ret = drm_gem_handle_create(file, &obj->gem, handle);
drm_gem_object_put_unlocked(&obj->gem);
- if (ret) {
- drm_gem_object_release(&obj->gem);
- kfree(obj);
+ if (ret)
return ERR_PTR(ret);
- }
return &obj->gem;
}
--
2.21.0.rc2.261.ga7da99ff1b-goog
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/vkms: fix use-after-free when drm_gem_handle_create() fails
2019-02-26 22:08 ` [PATCH] drm/vkms: " Eric Biggers
@ 2019-02-26 22:14 ` Chris Wilson
2019-02-27 23:12 ` Rodrigo Siqueira
1 sibling, 0 replies; 17+ messages in thread
From: Chris Wilson @ 2019-02-26 22:14 UTC (permalink / raw)
To: Eric Biggers, dri-devel
Cc: syzkaller-bugs, linux-kernel, Rodrigo Siqueira, Haneen Mohammed,
Daniel Vetter, stable
Quoting Eric Biggers (2019-02-26 22:08:58)
> From: Eric Biggers <ebiggers@google.com>
>
> If drm_gem_handle_create() fails in vkms_gem_create(), then the
> vkms_gem_object is freed twice: once when the reference is dropped by
> drm_gem_object_put_unlocked(), and again by the extra calls to
> drm_gem_object_release() and kfree().
>
> Fix it by skipping the second release and free.
>
> This bug was originally found in the vgem driver by syzkaller using
> fault injection, but I noticed it's also present in the vkms driver.
>
> Fixes: 559e50fd34d1 ("drm/vkms: Add dumb operations")
> Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/vkms: fix use-after-free when drm_gem_handle_create() fails
2019-02-26 22:08 ` [PATCH] drm/vkms: " Eric Biggers
2019-02-26 22:14 ` Chris Wilson
@ 2019-02-27 23:12 ` Rodrigo Siqueira
2019-02-28 6:41 ` Dmitry Vyukov
1 sibling, 1 reply; 17+ messages in thread
From: Rodrigo Siqueira @ 2019-02-27 23:12 UTC (permalink / raw)
To: Eric Biggers
Cc: dri-devel, syzkaller-bugs, linux-kernel, Haneen Mohammed,
Daniel Vetter, Chris Wilson, stable
[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]
On 02/26, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> If drm_gem_handle_create() fails in vkms_gem_create(), then the
> vkms_gem_object is freed twice: once when the reference is dropped by
> drm_gem_object_put_unlocked(), and again by the extra calls to
> drm_gem_object_release() and kfree().
>
> Fix it by skipping the second release and free.
>
> This bug was originally found in the vgem driver by syzkaller using
> fault injection, but I noticed it's also present in the vkms driver.
>
> Fixes: 559e50fd34d1 ("drm/vkms: Add dumb operations")
> Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> drivers/gpu/drm/vkms/vkms_gem.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c
> index 138b0bb325cf9..69048e73377dc 100644
> --- a/drivers/gpu/drm/vkms/vkms_gem.c
> +++ b/drivers/gpu/drm/vkms/vkms_gem.c
> @@ -111,11 +111,8 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
>
> ret = drm_gem_handle_create(file, &obj->gem, handle);
> drm_gem_object_put_unlocked(&obj->gem);
> - if (ret) {
> - drm_gem_object_release(&obj->gem);
> - kfree(obj);
> + if (ret)
> return ERR_PTR(ret);
> - }
>
> return &obj->gem;
> }
> --
> 2.21.0.rc2.261.ga7da99ff1b-goog
>
Hi,
Thanks for your patch! :)
The patch looks good for me. I also tested it under the IGT tests on my
local VM and everything was fine.
Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
--
Rodrigo Siqueira
https://siqueira.tech
Graduate Student
Department of Computer Science
University of São Paulo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2] drm/vgem: fix use-after-free when drm_gem_handle_create() fails
2019-02-26 21:44 ` [PATCH v2] " Eric Biggers
@ 2019-02-27 23:52 ` Laura Abbott
2019-03-04 23:24 ` Rodrigo Siqueira
1 sibling, 0 replies; 17+ messages in thread
From: Laura Abbott @ 2019-02-27 23:52 UTC (permalink / raw)
To: Eric Biggers, dri-devel
Cc: Chris Wilson, syzkaller-bugs, linux-kernel,
syzbot+e73f2fb5ed5a5df36d33, Daniel Vetter, stable
On 2/26/19 1:44 PM, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> If drm_gem_handle_create() fails in vgem_gem_create(), then the
> drm_vgem_gem_object is freed twice: once when the reference is dropped
> by drm_gem_object_put_unlocked(), and again by __vgem_gem_destroy().
>
> This was hit by syzkaller using fault injection.
>
> Fix it by skipping the second free.
>
> Reported-by: syzbot+e73f2fb5ed5a5df36d33@syzkaller.appspotmail.com
> Fixes: af33a9190d02 ("drm/vgem: Enable dmabuf import interfaces")
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Laura Abbott <labbott@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> drivers/gpu/drm/vgem/vgem_drv.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
> index 5930facd6d2d8..11a8f99ba18c5 100644
> --- a/drivers/gpu/drm/vgem/vgem_drv.c
> +++ b/drivers/gpu/drm/vgem/vgem_drv.c
> @@ -191,13 +191,9 @@ static struct drm_gem_object *vgem_gem_create(struct drm_device *dev,
> ret = drm_gem_handle_create(file, &obj->base, handle);
> drm_gem_object_put_unlocked(&obj->base);
> if (ret)
> - goto err;
> + return ERR_PTR(ret);
>
> return &obj->base;
> -
> -err:
> - __vgem_gem_destroy(obj);
> - return ERR_PTR(ret);
> }
>
> static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
>
Acked-by: Laura Abbott <labbott@redhat.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/vkms: fix use-after-free when drm_gem_handle_create() fails
2019-02-27 23:12 ` Rodrigo Siqueira
@ 2019-02-28 6:41 ` Dmitry Vyukov
2019-03-04 23:23 ` Rodrigo Siqueira
0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Vyukov @ 2019-02-28 6:41 UTC (permalink / raw)
To: Rodrigo Siqueira
Cc: Eric Biggers, DRI, syzkaller-bugs, LKML, Haneen Mohammed,
Daniel Vetter, Chris Wilson, stable
On Thu, Feb 28, 2019 at 12:12 AM Rodrigo Siqueira
<rodrigosiqueiramelo@gmail.com> wrote:
>
> On 02/26, Eric Biggers wrote:
> > From: Eric Biggers <ebiggers@google.com>
> >
> > If drm_gem_handle_create() fails in vkms_gem_create(), then the
> > vkms_gem_object is freed twice: once when the reference is dropped by
> > drm_gem_object_put_unlocked(), and again by the extra calls to
> > drm_gem_object_release() and kfree().
> >
> > Fix it by skipping the second release and free.
> >
> > This bug was originally found in the vgem driver by syzkaller using
> > fault injection, but I noticed it's also present in the vkms driver.
> >
> > Fixes: 559e50fd34d1 ("drm/vkms: Add dumb operations")
> > Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> > Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > ---
> > drivers/gpu/drm/vkms/vkms_gem.c | 5 +----
> > 1 file changed, 1 insertion(+), 4 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c
> > index 138b0bb325cf9..69048e73377dc 100644
> > --- a/drivers/gpu/drm/vkms/vkms_gem.c
> > +++ b/drivers/gpu/drm/vkms/vkms_gem.c
> > @@ -111,11 +111,8 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
> >
> > ret = drm_gem_handle_create(file, &obj->gem, handle);
> > drm_gem_object_put_unlocked(&obj->gem);
> > - if (ret) {
> > - drm_gem_object_release(&obj->gem);
> > - kfree(obj);
> > + if (ret)
> > return ERR_PTR(ret);
> > - }
> >
> > return &obj->gem;
> > }
> > --
> > 2.21.0.rc2.261.ga7da99ff1b-goog
> >
>
> Hi,
>
> Thanks for your patch! :)
>
> The patch looks good for me. I also tested it under the IGT tests on my
> local VM and everything was fine.
Hi Rodrigo,
What are IGT tests? How can I run them?
>
> Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
>
> --
> Rodrigo Siqueira
> https://siqueira.tech
> Graduate Student
> Department of Computer Science
> University of São Paulo
>
> --
> You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/20190227231202.tycdbcqtk5ylwp4k%40smtp.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/vkms: fix use-after-free when drm_gem_handle_create() fails
2019-02-28 6:41 ` Dmitry Vyukov
@ 2019-03-04 23:23 ` Rodrigo Siqueira
2019-03-05 14:25 ` Dmitry Vyukov
0 siblings, 1 reply; 17+ messages in thread
From: Rodrigo Siqueira @ 2019-03-04 23:23 UTC (permalink / raw)
To: Dmitry Vyukov
Cc: Eric Biggers, DRI, syzkaller-bugs, LKML, Haneen Mohammed,
Daniel Vetter, Chris Wilson, stable
[-- Attachment #1: Type: text/plain, Size: 3470 bytes --]
On 02/28, Dmitry Vyukov wrote:
> On Thu, Feb 28, 2019 at 12:12 AM Rodrigo Siqueira
> <rodrigosiqueiramelo@gmail.com> wrote:
> >
> > On 02/26, Eric Biggers wrote:
> > > From: Eric Biggers <ebiggers@google.com>
> > >
> > > If drm_gem_handle_create() fails in vkms_gem_create(), then the
> > > vkms_gem_object is freed twice: once when the reference is dropped by
> > > drm_gem_object_put_unlocked(), and again by the extra calls to
> > > drm_gem_object_release() and kfree().
> > >
> > > Fix it by skipping the second release and free.
> > >
> > > This bug was originally found in the vgem driver by syzkaller using
> > > fault injection, but I noticed it's also present in the vkms driver.
> > >
> > > Fixes: 559e50fd34d1 ("drm/vkms: Add dumb operations")
> > > Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> > > Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
> > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > Cc: stable@vger.kernel.org
> > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > > ---
> > > drivers/gpu/drm/vkms/vkms_gem.c | 5 +----
> > > 1 file changed, 1 insertion(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c
> > > index 138b0bb325cf9..69048e73377dc 100644
> > > --- a/drivers/gpu/drm/vkms/vkms_gem.c
> > > +++ b/drivers/gpu/drm/vkms/vkms_gem.c
> > > @@ -111,11 +111,8 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
> > >
> > > ret = drm_gem_handle_create(file, &obj->gem, handle);
> > > drm_gem_object_put_unlocked(&obj->gem);
> > > - if (ret) {
> > > - drm_gem_object_release(&obj->gem);
> > > - kfree(obj);
> > > + if (ret)
> > > return ERR_PTR(ret);
> > > - }
> > >
> > > return &obj->gem;
> > > }
> > > --
> > > 2.21.0.rc2.261.ga7da99ff1b-goog
> > >
> >
> > Hi,
> >
> > Thanks for your patch! :)
> >
> > The patch looks good for me. I also tested it under the IGT tests on my
> > local VM and everything was fine.
Hi,
Patch applied to drm-misc-fixes.
> Hi Rodrigo,
>
> What are IGT tests? How can I run them?
Hi Dmitry,
IGT is a test suite focused on DRM drivers.
You can clone the project using the link below:
https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
In the README, you will find the software dependencies. After you
install all the required package, just use:
mkdir build && meson build && cd build && ninja
Finally, if you want to test VKMS, I recommend you to do it inside a VM.
Best Regards
Rodrigo Siqueira
> >
> > Reviewed-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> >
> > --
> > Rodrigo Siqueira
> > https://siqueira.tech
> > Graduate Student
> > Department of Computer Science
> > University of São Paulo
> >
> > --
> > You received this message because you are subscribed to the Google Groups "syzkaller-bugs" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to syzkaller-bugs+unsubscribe@googlegroups.com.
> > To view this discussion on the web visit https://groups.google.com/d/msgid/syzkaller-bugs/20190227231202.tycdbcqtk5ylwp4k%40smtp.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
--
Rodrigo Siqueira
https://siqueira.tech
Graduate Student
Department of Computer Science
University of São Paulo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH v2] drm/vgem: fix use-after-free when drm_gem_handle_create() fails
2019-02-26 21:44 ` [PATCH v2] " Eric Biggers
2019-02-27 23:52 ` Laura Abbott
@ 2019-03-04 23:24 ` Rodrigo Siqueira
1 sibling, 0 replies; 17+ messages in thread
From: Rodrigo Siqueira @ 2019-03-04 23:24 UTC (permalink / raw)
To: Eric Biggers
Cc: dri-devel, Daniel Vetter, syzkaller-bugs, linux-kernel, stable,
syzbot+e73f2fb5ed5a5df36d33
[-- Attachment #1: Type: text/plain, Size: 1909 bytes --]
On 02/26, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> If drm_gem_handle_create() fails in vgem_gem_create(), then the
> drm_vgem_gem_object is freed twice: once when the reference is dropped
> by drm_gem_object_put_unlocked(), and again by __vgem_gem_destroy().
>
> This was hit by syzkaller using fault injection.
>
> Fix it by skipping the second free.
>
> Reported-by: syzbot+e73f2fb5ed5a5df36d33@syzkaller.appspotmail.com
> Fixes: af33a9190d02 ("drm/vgem: Enable dmabuf import interfaces")
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Laura Abbott <labbott@redhat.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@google.com>
> ---
> drivers/gpu/drm/vgem/vgem_drv.c | 6 +-----
> 1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c
> index 5930facd6d2d8..11a8f99ba18c5 100644
> --- a/drivers/gpu/drm/vgem/vgem_drv.c
> +++ b/drivers/gpu/drm/vgem/vgem_drv.c
> @@ -191,13 +191,9 @@ static struct drm_gem_object *vgem_gem_create(struct drm_device *dev,
> ret = drm_gem_handle_create(file, &obj->base, handle);
> drm_gem_object_put_unlocked(&obj->base);
> if (ret)
> - goto err;
> + return ERR_PTR(ret);
>
> return &obj->base;
> -
> -err:
> - __vgem_gem_destroy(obj);
> - return ERR_PTR(ret);
> }
>
> static int vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
> --
> 2.21.0.rc2.261.ga7da99ff1b-goog
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Applied to drm-misc-fixes.
Thanks
--
Rodrigo Siqueira
https://siqueira.tech
Graduate Student
Department of Computer Science
University of São Paulo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/vkms: fix use-after-free when drm_gem_handle_create() fails
2019-03-04 23:23 ` Rodrigo Siqueira
@ 2019-03-05 14:25 ` Dmitry Vyukov
2019-03-10 15:36 ` Rodrigo Siqueira
0 siblings, 1 reply; 17+ messages in thread
From: Dmitry Vyukov @ 2019-03-05 14:25 UTC (permalink / raw)
To: Rodrigo Siqueira
Cc: Eric Biggers, DRI, syzkaller-bugs, LKML, Haneen Mohammed,
Daniel Vetter, Chris Wilson, stable
On Tue, Mar 5, 2019 at 12:23 AM Rodrigo Siqueira
<rodrigosiqueiramelo@gmail.com> wrote:
>
> On 02/28, Dmitry Vyukov wrote:
> > On Thu, Feb 28, 2019 at 12:12 AM Rodrigo Siqueira
> > <rodrigosiqueiramelo@gmail.com> wrote:
> > >
> > > On 02/26, Eric Biggers wrote:
> > > > From: Eric Biggers <ebiggers@google.com>
> > > >
> > > > If drm_gem_handle_create() fails in vkms_gem_create(), then the
> > > > vkms_gem_object is freed twice: once when the reference is dropped by
> > > > drm_gem_object_put_unlocked(), and again by the extra calls to
> > > > drm_gem_object_release() and kfree().
> > > >
> > > > Fix it by skipping the second release and free.
> > > >
> > > > This bug was originally found in the vgem driver by syzkaller using
> > > > fault injection, but I noticed it's also present in the vkms driver.
> > > >
> > > > Fixes: 559e50fd34d1 ("drm/vkms: Add dumb operations")
> > > > Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> > > > Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
> > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > > Cc: stable@vger.kernel.org
> > > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > > > ---
> > > > drivers/gpu/drm/vkms/vkms_gem.c | 5 +----
> > > > 1 file changed, 1 insertion(+), 4 deletions(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c
> > > > index 138b0bb325cf9..69048e73377dc 100644
> > > > --- a/drivers/gpu/drm/vkms/vkms_gem.c
> > > > +++ b/drivers/gpu/drm/vkms/vkms_gem.c
> > > > @@ -111,11 +111,8 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
> > > >
> > > > ret = drm_gem_handle_create(file, &obj->gem, handle);
> > > > drm_gem_object_put_unlocked(&obj->gem);
> > > > - if (ret) {
> > > > - drm_gem_object_release(&obj->gem);
> > > > - kfree(obj);
> > > > + if (ret)
> > > > return ERR_PTR(ret);
> > > > - }
> > > >
> > > > return &obj->gem;
> > > > }
> > > > --
> > > > 2.21.0.rc2.261.ga7da99ff1b-goog
> > > >
> > >
> > > Hi,
> > >
> > > Thanks for your patch! :)
> > >
> > > The patch looks good for me. I also tested it under the IGT tests on my
> > > local VM and everything was fine.
>
> Hi,
>
> Patch applied to drm-misc-fixes.
>
> > Hi Rodrigo,
> >
> > What are IGT tests? How can I run them?
>
> Hi Dmitry,
>
> IGT is a test suite focused on DRM drivers.
>
> You can clone the project using the link below:
>
> https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
>
> In the README, you will find the software dependencies. After you
> install all the required package, just use:
>
> mkdir build && meson build && cd build && ninja
Hi Rodrigo,
Thanks for the info, but this did not work for me.
I installed all recommended packages (including libdw-dev), but then got:
igt-gpu-tools$ mkdir -p build && meson build && cd build && ninja
The Meson build system
Version: 0.46.1
Source dir: /src/igt-gpu-tools
Build dir: /src/igt-gpu-tools/build
Build type: native build
Project name: igt-gpu-tools
Native C compiler: ccache cc (gcc 7.3.0 "cc (Debian 7.3.0-5) 7.3.0")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Compiler for C supports arguments -Wbad-function-cast: YES
Compiler for C supports arguments -Wdeclaration-after-statement: YES
Compiler for C supports arguments -Wformat=2: YES
Compiler for C supports arguments -Wimplicit-fallthrough=0: YES
Compiler for C supports arguments -Wlogical-op: YES
Compiler for C supports arguments -Wmissing-declarations: YES
Compiler for C supports arguments -Wmissing-format-attribute: YES
Compiler for C supports arguments -Wmissing-noreturn: YES
Compiler for C supports arguments -Wmissing-prototypes: YES
Compiler for C supports arguments -Wnested-externs: YES
Compiler for C supports arguments -Wold-style-definition: YES
Compiler for C supports arguments -Wpointer-arith: YES
Compiler for C supports arguments -Wredundant-decls: YES
Compiler for C supports arguments -Wshadow: YES
Compiler for C supports arguments -Wstrict-prototypes: YES
Compiler for C supports arguments -Wuninitialized: YES
Compiler for C supports arguments -Wunused: YES
Compiler for C supports arguments -Wno-clobbered -Wclobbered: YES
Compiler for C supports arguments -Wno-maybe-uninitialized
-Wmaybe-uninitialized: YES
Compiler for C supports arguments -Wno-missing-field-initializers
-Wmissing-field-initializers: YES
Compiler for C supports arguments -Wno-pointer-arith -Wpointer-arith: YES
Compiler for C supports arguments -Wno-sign-compare -Wsign-compare: YES
Compiler for C supports arguments -Wno-type-limits -Wtype-limits: YES
Compiler for C supports arguments -Wno-unused-parameter -Wunused-parameter: YES
Compiler for C supports arguments -Wno-unused-result -Wunused-result: YES
Compiler for C supports arguments -Werror=address: YES
Compiler for C supports arguments -Werror=array-bounds: YES
Compiler for C supports arguments -Werror=implicit: YES
Compiler for C supports arguments -Werror=init-self: YES
Compiler for C supports arguments -Werror=int-to-pointer-cast: YES
Compiler for C supports arguments -Werror=main: YES
Compiler for C supports arguments -Werror=missing-braces: YES
Compiler for C supports arguments -Werror=nonnull: YES
Compiler for C supports arguments -Werror=pointer-to-int-cast: YES
Compiler for C supports arguments -Werror=return-type: YES
Compiler for C supports arguments -Werror=sequence-point: YES
Compiler for C supports arguments -Werror=trigraphs: YES
Compiler for C supports arguments -Werror=write-strings: YES
Found pkg-config: /usr/bin/pkg-config (0.29)
Native dependency libdrm found: YES 2.4.91
Native dependency libdrm_intel found: YES 2.4.91
Native dependency libdrm_nouveau found: YES 2.4.91
Native dependency libdrm_amdgpu found: YES 2.4.91
Native dependency pciaccess found: YES 0.13.4
Native dependency libkmod found: YES 24
Native dependency libprocps found: YES 3.3.15
Native dependency libunwind found: YES 1.21
meson.build:151:0: ERROR: Could not generate cargs for libdw:
A full log can be found at /src/igt-gpu-tools/build/meson-logs/meson-log.txt
and meson-log.txt ends with:
Compiler for C supports arguments -Werror=write-strings: YES
Found pkg-config: /usr/bin/pkg-config (0.29)
Determining dependency 'libdrm' with pkg-config executable '/usr/bin/pkg-config'
Native dependency libdrm found: YES 2.4.91
Determining dependency 'libdrm_intel' with pkg-config executable
'/usr/bin/pkg-config'
Native dependency libdrm_intel found: YES 2.4.91
Determining dependency 'libdrm_nouveau' with pkg-config executable
'/usr/bin/pkg-config'
Native dependency libdrm_nouveau found: YES 2.4.91
Determining dependency 'libdrm_amdgpu' with pkg-config executable
'/usr/bin/pkg-config'
Native dependency libdrm_amdgpu found: YES 2.4.91
Determining dependency 'pciaccess' with pkg-config executable
'/usr/bin/pkg-config'
Native dependency pciaccess found: YES 0.13.4
Determining dependency 'libkmod' with pkg-config executable
'/usr/bin/pkg-config'
Native dependency libkmod found: YES 24
Determining dependency 'libprocps' with pkg-config executable
'/usr/bin/pkg-config'
Native dependency libprocps found: YES 3.3.15
Determining dependency 'libunwind' with pkg-config executable
'/usr/bin/pkg-config'
Native dependency libunwind found: YES 1.21
Determining dependency 'libdw' with pkg-config executable '/usr/bin/pkg-config'
meson.build:151:0: ERROR: Could not generate cargs for libdw:
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] drm/vkms: fix use-after-free when drm_gem_handle_create() fails
2019-03-05 14:25 ` Dmitry Vyukov
@ 2019-03-10 15:36 ` Rodrigo Siqueira
0 siblings, 0 replies; 17+ messages in thread
From: Rodrigo Siqueira @ 2019-03-10 15:36 UTC (permalink / raw)
To: Dmitry Vyukov
Cc: Eric Biggers, DRI, syzkaller-bugs, LKML, Haneen Mohammed,
Daniel Vetter, Chris Wilson, stable
[-- Attachment #1: Type: text/plain, Size: 8357 bytes --]
On 03/05, Dmitry Vyukov wrote:
> On Tue, Mar 5, 2019 at 12:23 AM Rodrigo Siqueira
> <rodrigosiqueiramelo@gmail.com> wrote:
> >
> > On 02/28, Dmitry Vyukov wrote:
> > > On Thu, Feb 28, 2019 at 12:12 AM Rodrigo Siqueira
> > > <rodrigosiqueiramelo@gmail.com> wrote:
> > > >
> > > > On 02/26, Eric Biggers wrote:
> > > > > From: Eric Biggers <ebiggers@google.com>
> > > > >
> > > > > If drm_gem_handle_create() fails in vkms_gem_create(), then the
> > > > > vkms_gem_object is freed twice: once when the reference is dropped by
> > > > > drm_gem_object_put_unlocked(), and again by the extra calls to
> > > > > drm_gem_object_release() and kfree().
> > > > >
> > > > > Fix it by skipping the second release and free.
> > > > >
> > > > > This bug was originally found in the vgem driver by syzkaller using
> > > > > fault injection, but I noticed it's also present in the vkms driver.
> > > > >
> > > > > Fixes: 559e50fd34d1 ("drm/vkms: Add dumb operations")
> > > > > Cc: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
> > > > > Cc: Haneen Mohammed <hamohammed.sa@gmail.com>
> > > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > > > > Cc: stable@vger.kernel.org
> > > > > Signed-off-by: Eric Biggers <ebiggers@google.com>
> > > > > ---
> > > > > drivers/gpu/drm/vkms/vkms_gem.c | 5 +----
> > > > > 1 file changed, 1 insertion(+), 4 deletions(-)
> > > > >
> > > > > diff --git a/drivers/gpu/drm/vkms/vkms_gem.c b/drivers/gpu/drm/vkms/vkms_gem.c
> > > > > index 138b0bb325cf9..69048e73377dc 100644
> > > > > --- a/drivers/gpu/drm/vkms/vkms_gem.c
> > > > > +++ b/drivers/gpu/drm/vkms/vkms_gem.c
> > > > > @@ -111,11 +111,8 @@ struct drm_gem_object *vkms_gem_create(struct drm_device *dev,
> > > > >
> > > > > ret = drm_gem_handle_create(file, &obj->gem, handle);
> > > > > drm_gem_object_put_unlocked(&obj->gem);
> > > > > - if (ret) {
> > > > > - drm_gem_object_release(&obj->gem);
> > > > > - kfree(obj);
> > > > > + if (ret)
> > > > > return ERR_PTR(ret);
> > > > > - }
> > > > >
> > > > > return &obj->gem;
> > > > > }
> > > > > --
> > > > > 2.21.0.rc2.261.ga7da99ff1b-goog
> > > > >
> > > >
> > > > Hi,
> > > >
> > > > Thanks for your patch! :)
> > > >
> > > > The patch looks good for me. I also tested it under the IGT tests on my
> > > > local VM and everything was fine.
> >
> > Hi,
> >
> > Patch applied to drm-misc-fixes.
> >
> > > Hi Rodrigo,
> > >
> > > What are IGT tests? How can I run them?
> >
> > Hi Dmitry,
> >
> > IGT is a test suite focused on DRM drivers.
> >
> > You can clone the project using the link below:
> >
> > https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
> >
> > In the README, you will find the software dependencies. After you
> > install all the required package, just use:
> >
> > mkdir build && meson build && cd build && ninja
>
> Hi Rodrigo,
>
> Thanks for the info, but this did not work for me.
> I installed all recommended packages (including libdw-dev), but then got:
Hi Dmitry,
I would like to recommend you to join the dri-devel channel (Freenode).
There you can quickly get help from me and others ;)
My nick in the dri-devel is 'siqueira'.
Best Regards
> igt-gpu-tools$ mkdir -p build && meson build && cd build && ninja
> The Meson build system
> Version: 0.46.1
> Source dir: /src/igt-gpu-tools
> Build dir: /src/igt-gpu-tools/build
> Build type: native build
> Project name: igt-gpu-tools
> Native C compiler: ccache cc (gcc 7.3.0 "cc (Debian 7.3.0-5) 7.3.0")
> Build machine cpu family: x86_64
> Build machine cpu: x86_64
> Compiler for C supports arguments -Wbad-function-cast: YES
> Compiler for C supports arguments -Wdeclaration-after-statement: YES
> Compiler for C supports arguments -Wformat=2: YES
> Compiler for C supports arguments -Wimplicit-fallthrough=0: YES
> Compiler for C supports arguments -Wlogical-op: YES
> Compiler for C supports arguments -Wmissing-declarations: YES
> Compiler for C supports arguments -Wmissing-format-attribute: YES
> Compiler for C supports arguments -Wmissing-noreturn: YES
> Compiler for C supports arguments -Wmissing-prototypes: YES
> Compiler for C supports arguments -Wnested-externs: YES
> Compiler for C supports arguments -Wold-style-definition: YES
> Compiler for C supports arguments -Wpointer-arith: YES
> Compiler for C supports arguments -Wredundant-decls: YES
> Compiler for C supports arguments -Wshadow: YES
> Compiler for C supports arguments -Wstrict-prototypes: YES
> Compiler for C supports arguments -Wuninitialized: YES
> Compiler for C supports arguments -Wunused: YES
> Compiler for C supports arguments -Wno-clobbered -Wclobbered: YES
> Compiler for C supports arguments -Wno-maybe-uninitialized
> -Wmaybe-uninitialized: YES
> Compiler for C supports arguments -Wno-missing-field-initializers
> -Wmissing-field-initializers: YES
> Compiler for C supports arguments -Wno-pointer-arith -Wpointer-arith: YES
> Compiler for C supports arguments -Wno-sign-compare -Wsign-compare: YES
> Compiler for C supports arguments -Wno-type-limits -Wtype-limits: YES
> Compiler for C supports arguments -Wno-unused-parameter -Wunused-parameter: YES
> Compiler for C supports arguments -Wno-unused-result -Wunused-result: YES
> Compiler for C supports arguments -Werror=address: YES
> Compiler for C supports arguments -Werror=array-bounds: YES
> Compiler for C supports arguments -Werror=implicit: YES
> Compiler for C supports arguments -Werror=init-self: YES
> Compiler for C supports arguments -Werror=int-to-pointer-cast: YES
> Compiler for C supports arguments -Werror=main: YES
> Compiler for C supports arguments -Werror=missing-braces: YES
> Compiler for C supports arguments -Werror=nonnull: YES
> Compiler for C supports arguments -Werror=pointer-to-int-cast: YES
> Compiler for C supports arguments -Werror=return-type: YES
> Compiler for C supports arguments -Werror=sequence-point: YES
> Compiler for C supports arguments -Werror=trigraphs: YES
> Compiler for C supports arguments -Werror=write-strings: YES
> Found pkg-config: /usr/bin/pkg-config (0.29)
> Native dependency libdrm found: YES 2.4.91
> Native dependency libdrm_intel found: YES 2.4.91
> Native dependency libdrm_nouveau found: YES 2.4.91
> Native dependency libdrm_amdgpu found: YES 2.4.91
> Native dependency pciaccess found: YES 0.13.4
> Native dependency libkmod found: YES 24
> Native dependency libprocps found: YES 3.3.15
> Native dependency libunwind found: YES 1.21
>
> meson.build:151:0: ERROR: Could not generate cargs for libdw:
>
> A full log can be found at /src/igt-gpu-tools/build/meson-logs/meson-log.txt
>
>
> and meson-log.txt ends with:
>
> Compiler for C supports arguments -Werror=write-strings: YES
> Found pkg-config: /usr/bin/pkg-config (0.29)
> Determining dependency 'libdrm' with pkg-config executable '/usr/bin/pkg-config'
> Native dependency libdrm found: YES 2.4.91
> Determining dependency 'libdrm_intel' with pkg-config executable
> '/usr/bin/pkg-config'
> Native dependency libdrm_intel found: YES 2.4.91
> Determining dependency 'libdrm_nouveau' with pkg-config executable
> '/usr/bin/pkg-config'
> Native dependency libdrm_nouveau found: YES 2.4.91
> Determining dependency 'libdrm_amdgpu' with pkg-config executable
> '/usr/bin/pkg-config'
> Native dependency libdrm_amdgpu found: YES 2.4.91
> Determining dependency 'pciaccess' with pkg-config executable
> '/usr/bin/pkg-config'
> Native dependency pciaccess found: YES 0.13.4
> Determining dependency 'libkmod' with pkg-config executable
> '/usr/bin/pkg-config'
> Native dependency libkmod found: YES 24
> Determining dependency 'libprocps' with pkg-config executable
> '/usr/bin/pkg-config'
> Native dependency libprocps found: YES 3.3.15
> Determining dependency 'libunwind' with pkg-config executable
> '/usr/bin/pkg-config'
> Native dependency libunwind found: YES 1.21
> Determining dependency 'libdw' with pkg-config executable '/usr/bin/pkg-config'
>
> meson.build:151:0: ERROR: Could not generate cargs for libdw:
--
Rodrigo Siqueira
https://siqueira.tech
Graduate Student
Department of Computer Science
University of São Paulo
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2022-07-22 16:23 KASAN: use-after-free Read in drm_gem_object_release Dipanjan Das
@ 2022-08-02 19:02 ` Dipanjan Das
0 siblings, 0 replies; 17+ messages in thread
From: Dipanjan Das @ 2022-08-02 19:02 UTC (permalink / raw)
To: maarten.lankhorst, mripard, sean, airlied, daniel, dri-devel,
linux-kernel
Cc: syzkaller, fleischermarius, its.priyanka.bose
On Fri, Jul 22, 2022 at 9:23 AM Dipanjan Das
<mail.dipanjan.das@gmail.com> wrote:
> ======================================================
> description: KASAN: use-after-free Read in drm_gem_object_release
> affected file: drivers/gpu/drm/drm_gem.c
> kernel version: 5.4.206
> kernel commit: 981f87403bb9841f1e0b7953e12a51f09a47a4f0
> git tree: upstream
> kernel config: https://syzkaller.appspot.com/text?tag=KernelConfig&x=1aab6d4187ddf667
> crash reproducer: attached
> ======================================================
> Crash log:
> ======================================================
> BUG: KASAN: use-after-free in drm_gem_object_release+0xf7/0x120
> drivers/gpu/drm/drm_gem.c:952
> ==================================================================
> BUG: KASAN: double-free or invalid-free in
> drm_gem_vram_create+0x1b7/0x1f0
> drivers/gpu/drm/drm_gem_vram_helper.c:142
We did an initial analysis for this bug and figured out the following:
If ttm_bo_init_reserved() fails, the `gbo` and `gbo->bo.base` will be
freed by ttm_buffer_object_destroy(). But then drm_gem_vram_create()
and drm_gem_vram_init() will attempt to free `gbo` and `gbo->bo.base`
again. This will result in UAF and Double Free. A similar bug (the
stack traces were a bit different) has been patched by this upstream
commit: https://github.com/torvalds/linux/commit/da62cb7230f0871c30dc9789071f63229158d261.
We applied this patch and can confirm that the repro does not trigger
the issue anymore.
--
Thanks and Regards,
Dipanjan
^ permalink raw reply [flat|nested] 17+ messages in thread
* KASAN: use-after-free Read in drm_gem_object_release
@ 2022-07-22 16:23 Dipanjan Das
2022-08-02 19:02 ` Dipanjan Das
0 siblings, 1 reply; 17+ messages in thread
From: Dipanjan Das @ 2022-07-22 16:23 UTC (permalink / raw)
To: maarten.lankhorst, mripard, sean, airlied, daniel, dri-devel,
linux-kernel
Cc: syzkaller, fleischermarius, its.priyanka.bose
[-- Attachment #1: Type: text/plain, Size: 12449 bytes --]
Hi,
We would like to report the following bug which has been found by our
modified version of syzkaller.
======================================================
description: KASAN: use-after-free Read in drm_gem_object_release
affected file: drivers/gpu/drm/drm_gem.c
kernel version: 5.4.206
kernel commit: 981f87403bb9841f1e0b7953e12a51f09a47a4f0
git tree: upstream
kernel config: https://syzkaller.appspot.com/text?tag=KernelConfig&x=1aab6d4187ddf667
crash reproducer: attached
======================================================
Crash log:
======================================================
BUG: KASAN: use-after-free in drm_gem_object_release+0xf7/0x120
drivers/gpu/drm/drm_gem.c:952
Read of size 8 at addr ffff888069f2d110 by task syz-executor.2/9649
CPU: 0 PID: 9649 Comm: syz-executor.2 Tainted: G OE 5.4.206+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.13.0-1ubuntu1.1 04/01/2014
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1a0/0x217 lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xd3/0x343 mm/kasan/report.c:374
__kasan_report.cold+0x75/0x8d mm/kasan/report.c:506
kasan_report+0x10/0x20 mm/kasan/common.c:645
drm_gem_object_release+0xf7/0x120 drivers/gpu/drm/drm_gem.c:952
drm_gem_vram_init drivers/gpu/drm/drm_gem_vram_helper.c:106 [inline]
drm_gem_vram_create+0x180/0x1f0 drivers/gpu/drm/drm_gem_vram_helper.c:135
drm_gem_vram_fill_create_dumb+0x13b/0x2c0
drivers/gpu/drm/drm_gem_vram_helper.c:382
drm_gem_vram_driver_dumb_create+0x5e/0xe0
drivers/gpu/drm/drm_gem_vram_helper.c:509
drm_mode_create_dumb+0x2a0/0x330 drivers/gpu/drm/drm_dumb_buffers.c:94
drm_ioctl_kernel+0x21a/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
drm_ioctl+0x52f/0xa70 drivers/gpu/drm/drm_ioctl.c:890
vfs_ioctl fs/ioctl.c:47 [inline]
file_ioctl fs/ioctl.c:510 [inline]
do_vfs_ioctl+0xd30/0x1340 fs/ioctl.c:697
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:714
__do_sys_ioctl fs/ioctl.c:721 [inline]
__se_sys_ioctl fs/ioctl.c:719 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:719
do_syscall_64+0xf6/0x7b0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f6b40bd24ed
Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6b3eb82be8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f6b40cf0f60 RCX: 00007f6b40bd24ed
RDX: 0000000020000180 RSI: 00000000c02064b2 RDI: 0000000000000003
RBP: 00007f6b3eb82c40 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000014
R13: 00007ffc4fb462af R14: 00007f6b40cf0f60 R15: 00007f6b3eb82d80
Allocated by task 9649:
save_stack+0x1b/0x80 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
__kasan_kmalloc+0xd2/0xe0 mm/kasan/common.c:521
kmem_cache_alloc_trace+0x13a/0x4e0 mm/slab.c:3550
kmalloc include/linux/slab.h:556 [inline]
kzalloc include/linux/slab.h:690 [inline]
drm_gem_vram_create+0x53/0x1f0 drivers/gpu/drm/drm_gem_vram_helper.c:131
drm_gem_vram_fill_create_dumb+0x13b/0x2c0
drivers/gpu/drm/drm_gem_vram_helper.c:382
drm_gem_vram_driver_dumb_create+0x5e/0xe0
drivers/gpu/drm/drm_gem_vram_helper.c:509
drm_mode_create_dumb+0x2a0/0x330 drivers/gpu/drm/drm_dumb_buffers.c:94
drm_ioctl_kernel+0x21a/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
drm_ioctl+0x52f/0xa70 drivers/gpu/drm/drm_ioctl.c:890
vfs_ioctl fs/ioctl.c:47 [inline]
file_ioctl fs/ioctl.c:510 [inline]
do_vfs_ioctl+0xd30/0x1340 fs/ioctl.c:697
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:714
__do_sys_ioctl fs/ioctl.c:721 [inline]
__se_sys_ioctl fs/ioctl.c:719 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:719
do_syscall_64+0xf6/0x7b0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Freed by task 9649:
save_stack+0x1b/0x80 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
kasan_set_free_info mm/kasan/common.c:334 [inline]
__kasan_slab_free+0x103/0x150 mm/kasan/common.c:478
__cache_free mm/slab.c:3425 [inline]
kfree+0x10b/0x330 mm/slab.c:3756
ttm_bo_release_list+0x335/0x4e0 drivers/gpu/drm/ttm/ttm_bo.c:166
kref_put include/linux/kref.h:65 [inline]
kref_put include/linux/kref.h:62 [inline]
ttm_bo_release+0x44c/0xf60 drivers/gpu/drm/ttm/ttm_bo.c:686
kref_put include/linux/kref.h:65 [inline]
kref_put include/linux/kref.h:62 [inline]
ttm_bo_put drivers/gpu/drm/ttm/ttm_bo.c:691 [inline]
ttm_bo_init_reserved+0x8c1/0x10c0 drivers/gpu/drm/ttm/ttm_bo.c:1390
ttm_bo_init+0x10e/0x4a0 drivers/gpu/drm/ttm/ttm_bo.c:1419
drm_gem_vram_init drivers/gpu/drm/drm_gem_vram_helper.c:97 [inline]
drm_gem_vram_create+0x15c/0x1f0 drivers/gpu/drm/drm_gem_vram_helper.c:135
drm_gem_vram_fill_create_dumb+0x13b/0x2c0
drivers/gpu/drm/drm_gem_vram_helper.c:382
drm_gem_vram_driver_dumb_create+0x5e/0xe0
drivers/gpu/drm/drm_gem_vram_helper.c:509
drm_mode_create_dumb+0x2a0/0x330 drivers/gpu/drm/drm_dumb_buffers.c:94
drm_ioctl_kernel+0x21a/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
drm_ioctl+0x52f/0xa70 drivers/gpu/drm/drm_ioctl.c:890
vfs_ioctl fs/ioctl.c:47 [inline]
file_ioctl fs/ioctl.c:510 [inline]
do_vfs_ioctl+0xd30/0x1340 fs/ioctl.c:697
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:714
__do_sys_ioctl fs/ioctl.c:721 [inline]
__se_sys_ioctl fs/ioctl.c:719 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:719
do_syscall_64+0xf6/0x7b0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff888069f2d000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 272 bytes inside of
1024-byte region [ffff888069f2d000, ffff888069f2d400)
The buggy address belongs to the page:
page:ffffea0001a7cb40 refcount:1 mapcount:0 mapping:ffff888119400c40 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea0002831748 ffffea00019062c8 ffff888119400c40
raw: 0000000000000000 ffff888069f2d000 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888069f2d000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888069f2d080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888069f2d100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888069f2d180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888069f2d200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
==================================================================
BUG: KASAN: double-free or invalid-free in
drm_gem_vram_create+0x1b7/0x1f0
drivers/gpu/drm/drm_gem_vram_helper.c:142
CPU: 0 PID: 9649 Comm: syz-executor.2 Tainted: G B OE 5.4.206+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.13.0-1ubuntu1.1 04/01/2014
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x1a0/0x217 lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xd3/0x343 mm/kasan/report.c:374
kasan_report_invalid_free+0x61/0xa0 mm/kasan/report.c:468
__kasan_slab_free+0x135/0x150 mm/kasan/common.c:457
__cache_free mm/slab.c:3425 [inline]
kfree+0x10b/0x330 mm/slab.c:3756
drm_gem_vram_create+0x1b7/0x1f0 drivers/gpu/drm/drm_gem_vram_helper.c:142
drm_gem_vram_fill_create_dumb+0x13b/0x2c0
drivers/gpu/drm/drm_gem_vram_helper.c:382
drm_gem_vram_driver_dumb_create+0x5e/0xe0
drivers/gpu/drm/drm_gem_vram_helper.c:509
drm_mode_create_dumb+0x2a0/0x330 drivers/gpu/drm/drm_dumb_buffers.c:94
drm_ioctl_kernel+0x21a/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
drm_ioctl+0x52f/0xa70 drivers/gpu/drm/drm_ioctl.c:890
vfs_ioctl fs/ioctl.c:47 [inline]
file_ioctl fs/ioctl.c:510 [inline]
do_vfs_ioctl+0xd30/0x1340 fs/ioctl.c:697
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:714
__do_sys_ioctl fs/ioctl.c:721 [inline]
__se_sys_ioctl fs/ioctl.c:719 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:719
do_syscall_64+0xf6/0x7b0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x7f6b40bd24ed
Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f6b3eb82be8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f6b40cf0f60 RCX: 00007f6b40bd24ed
RDX: 0000000020000180 RSI: 00000000c02064b2 RDI: 0000000000000003
RBP: 00007f6b3eb82c40 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000014
R13: 00007ffc4fb462af R14: 00007f6b40cf0f60 R15: 00007f6b3eb82d80
Allocated by task 9649:
save_stack+0x1b/0x80 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
__kasan_kmalloc+0xd2/0xe0 mm/kasan/common.c:521
kmem_cache_alloc_trace+0x13a/0x4e0 mm/slab.c:3550
kmalloc include/linux/slab.h:556 [inline]
kzalloc include/linux/slab.h:690 [inline]
drm_gem_vram_create+0x53/0x1f0 drivers/gpu/drm/drm_gem_vram_helper.c:131
drm_gem_vram_fill_create_dumb+0x13b/0x2c0
drivers/gpu/drm/drm_gem_vram_helper.c:382
drm_gem_vram_driver_dumb_create+0x5e/0xe0
drivers/gpu/drm/drm_gem_vram_helper.c:509
drm_mode_create_dumb+0x2a0/0x330 drivers/gpu/drm/drm_dumb_buffers.c:94
drm_ioctl_kernel+0x21a/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
drm_ioctl+0x52f/0xa70 drivers/gpu/drm/drm_ioctl.c:890
vfs_ioctl fs/ioctl.c:47 [inline]
file_ioctl fs/ioctl.c:510 [inline]
do_vfs_ioctl+0xd30/0x1340 fs/ioctl.c:697
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:714
__do_sys_ioctl fs/ioctl.c:721 [inline]
__se_sys_ioctl fs/ioctl.c:719 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:719
do_syscall_64+0xf6/0x7b0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Freed by task 9649:
save_stack+0x1b/0x80 mm/kasan/common.c:71
set_track mm/kasan/common.c:79 [inline]
kasan_set_free_info mm/kasan/common.c:334 [inline]
__kasan_slab_free+0x103/0x150 mm/kasan/common.c:478
__cache_free mm/slab.c:3425 [inline]
kfree+0x10b/0x330 mm/slab.c:3756
ttm_bo_release_list+0x335/0x4e0 drivers/gpu/drm/ttm/ttm_bo.c:166
kref_put include/linux/kref.h:65 [inline]
kref_put include/linux/kref.h:62 [inline]
ttm_bo_release+0x44c/0xf60 drivers/gpu/drm/ttm/ttm_bo.c:686
kref_put include/linux/kref.h:65 [inline]
kref_put include/linux/kref.h:62 [inline]
ttm_bo_put drivers/gpu/drm/ttm/ttm_bo.c:691 [inline]
ttm_bo_init_reserved+0x8c1/0x10c0 drivers/gpu/drm/ttm/ttm_bo.c:1390
ttm_bo_init+0x10e/0x4a0 drivers/gpu/drm/ttm/ttm_bo.c:1419
drm_gem_vram_init drivers/gpu/drm/drm_gem_vram_helper.c:97 [inline]
drm_gem_vram_create+0x15c/0x1f0 drivers/gpu/drm/drm_gem_vram_helper.c:135
drm_gem_vram_fill_create_dumb+0x13b/0x2c0
drivers/gpu/drm/drm_gem_vram_helper.c:382
drm_gem_vram_driver_dumb_create+0x5e/0xe0
drivers/gpu/drm/drm_gem_vram_helper.c:509
drm_mode_create_dumb+0x2a0/0x330 drivers/gpu/drm/drm_dumb_buffers.c:94
drm_ioctl_kernel+0x21a/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
drm_ioctl+0x52f/0xa70 drivers/gpu/drm/drm_ioctl.c:890
vfs_ioctl fs/ioctl.c:47 [inline]
file_ioctl fs/ioctl.c:510 [inline]
do_vfs_ioctl+0xd30/0x1340 fs/ioctl.c:697
ksys_ioctl+0x9b/0xc0 fs/ioctl.c:714
__do_sys_ioctl fs/ioctl.c:721 [inline]
__se_sys_ioctl fs/ioctl.c:719 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:719
do_syscall_64+0xf6/0x7b0 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff888069f2d000
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 0 bytes inside of
1024-byte region [ffff888069f2d000, ffff888069f2d400)
The buggy address belongs to the page:
page:ffffea0001a7cb40 refcount:1 mapcount:0 mapping:ffff888119400c40 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea0002831748 ffffea00019062c8 ffff888119400c40
raw: 0000000000000000 ffff888069f2d000 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888069f2cf00: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
ffff888069f2cf80: 00 00 00 00 00 fc fc fc fc fc fc fc fc fc fc fc
>ffff888069f2d000: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888069f2d080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888069f2d100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
--
Thanks and Regards,
Dipanjan
[-- Attachment #2: repro.syz --]
[-- Type: application/octet-stream, Size: 171 bytes --]
r0 = syz_open_dev$dri(&(0x7f0000000540), 0x2000000000000000, 0x0)
ioctl$DRM_IOCTL_MODE_CREATE_DUMB(r0, 0xc02064b2, &(0x7f0000000180)={0x7, 0xfc000, 0xc39}) (fail_nth: 20)
[-- Attachment #3: repro.c --]
[-- Type: text/x-csrc, Size: 5514 bytes --]
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <linux/capability.h>
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2)
{
if (a0 == 0xc || a0 == 0xb) {
char buf[128];
sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2);
return open(buf, O_RDWR, 0);
} else {
char buf[1024];
char* hash;
strncpy(buf, (char*)a0, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
while ((hash = strchr(buf, '#'))) {
*hash = '0' + (char)(a1 % 10);
a1 /= 10;
}
return open(buf, a2, 0);
}
}
static void setup_common()
{
if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) {
}
}
static void setup_binderfs()
{
if (mkdir("/dev/binderfs", 0777)) {
}
if (mount("binder", "/dev/binderfs", "binder", 0, NULL)) {
}
if (symlink("/dev/binderfs", "./binderfs")) {
}
}
static void loop();
static void sandbox_common()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setsid();
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = (200 << 20);
setrlimit(RLIMIT_AS, &rlim);
rlim.rlim_cur = rlim.rlim_max = 32 << 20;
setrlimit(RLIMIT_MEMLOCK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 136 << 20;
setrlimit(RLIMIT_FSIZE, &rlim);
rlim.rlim_cur = rlim.rlim_max = 1 << 20;
setrlimit(RLIMIT_STACK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
rlim.rlim_cur = rlim.rlim_max = 256;
setrlimit(RLIMIT_NOFILE, &rlim);
if (unshare(CLONE_NEWNS)) {
}
if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) {
}
if (unshare(CLONE_NEWIPC)) {
}
if (unshare(0x02000000)) {
}
if (unshare(CLONE_NEWUTS)) {
}
if (unshare(CLONE_SYSVSEM)) {
}
typedef struct {
const char* name;
const char* value;
} sysctl_t;
static const sysctl_t sysctls[] = {
{"/proc/sys/kernel/shmmax", "16777216"},
{"/proc/sys/kernel/shmall", "536870912"},
{"/proc/sys/kernel/shmmni", "1024"},
{"/proc/sys/kernel/msgmax", "8192"},
{"/proc/sys/kernel/msgmni", "1024"},
{"/proc/sys/kernel/msgmnb", "1024"},
{"/proc/sys/kernel/sem", "1024 1048576 500 1024"},
};
unsigned i;
for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++)
write_file(sysctls[i].name, sysctls[i].value);
}
static int wait_for_loop(int pid)
{
if (pid < 0)
exit(1);
int status = 0;
while (waitpid(-1, &status, __WALL) != pid) {
}
return WEXITSTATUS(status);
}
static void drop_caps(void)
{
struct __user_cap_header_struct cap_hdr = {};
struct __user_cap_data_struct cap_data[2] = {};
cap_hdr.version = _LINUX_CAPABILITY_VERSION_3;
cap_hdr.pid = getpid();
if (syscall(SYS_capget, &cap_hdr, &cap_data))
exit(1);
const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE);
cap_data[0].effective &= ~drop;
cap_data[0].permitted &= ~drop;
cap_data[0].inheritable &= ~drop;
if (syscall(SYS_capset, &cap_hdr, &cap_data))
exit(1);
}
static int do_sandbox_none(void)
{
if (unshare(CLONE_NEWPID)) {
}
int pid = fork();
if (pid != 0)
return wait_for_loop(pid);
setup_common();
sandbox_common();
drop_caps();
if (unshare(CLONE_NEWNET)) {
}
setup_binderfs();
loop();
exit(1);
}
static int inject_fault(int nth)
{
int fd;
fd = open("/proc/thread-self/fail-nth", O_RDWR);
if (fd == -1)
exit(1);
char buf[16];
sprintf(buf, "%d", nth);
if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf))
exit(1);
return fd;
}
static void setup_fault()
{
static struct {
const char* file;
const char* val;
bool fatal;
} files[] = {
{"/sys/kernel/debug/failslab/ignore-gfp-wait", "N", true},
{"/sys/kernel/debug/fail_futex/ignore-private", "N", false},
{"/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem", "N", false},
{"/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait", "N", false},
{"/sys/kernel/debug/fail_page_alloc/min-order", "0", false},
};
unsigned i;
for (i = 0; i < sizeof(files) / sizeof(files[0]); i++) {
if (!write_file(files[i].file, files[i].val)) {
if (files[i].fatal)
exit(1);
}
}
}
uint64_t r[1] = {0xffffffffffffffff};
void loop(void)
{
intptr_t res = 0;
memcpy((void*)0x20000540, "/dev/dri/card#\000", 15);
res = -1;
res = syz_open_dev(0x20000540, 0x2000000000000000, 0);
if (res != -1)
r[0] = res;
*(uint32_t*)0x20000180 = 7;
*(uint32_t*)0x20000184 = 0xfc000;
*(uint32_t*)0x20000188 = 0xc39;
*(uint32_t*)0x2000018c = 0;
inject_fault(20);
syscall(__NR_ioctl, r[0], 0xc02064b2, 0x20000180ul);
}
int main(void)
{
syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
setup_fault();
do_sandbox_none();
return 0;
}
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2022-08-02 19:03 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-25 19:18 KASAN: use-after-free Read in drm_gem_object_release syzbot
2018-10-29 11:51 ` Dmitry Vyukov
2019-02-26 20:47 ` [PATCH] drm/vgem: fix use-after-free when drm_gem_handle_create() fails Eric Biggers
2019-02-26 21:01 ` Chris Wilson
2019-02-26 21:30 ` Eric Biggers
2019-02-26 21:44 ` [PATCH v2] " Eric Biggers
2019-02-27 23:52 ` Laura Abbott
2019-03-04 23:24 ` Rodrigo Siqueira
2019-02-26 22:08 ` [PATCH] drm/vkms: " Eric Biggers
2019-02-26 22:14 ` Chris Wilson
2019-02-27 23:12 ` Rodrigo Siqueira
2019-02-28 6:41 ` Dmitry Vyukov
2019-03-04 23:23 ` Rodrigo Siqueira
2019-03-05 14:25 ` Dmitry Vyukov
2019-03-10 15:36 ` Rodrigo Siqueira
2022-07-22 16:23 KASAN: use-after-free Read in drm_gem_object_release Dipanjan Das
2022-08-02 19:02 ` Dipanjan Das
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).