* KASAN: use-after-free Read in drm_gem_object_release
@ 2020-07-10 8:24 butt3rflyh4ck
2020-07-10 10:39 ` Greg KH
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: butt3rflyh4ck @ 2020-07-10 8:24 UTC (permalink / raw)
To: security
Cc: robdclark, airlied, syzkaller-bugs, dri-devel, chris, seanpaul,
sam, emil.velikov
I report a bug (in linux-5.8.0-rc4) found by syzkaller.
kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.8.0-rc4.config
I test the reproducer and crash too.
In the drm_em_vram_t() function, ttm_bo_init() function call
ttm_bo_init_reserved(),
the ttm_bo_init_reserved() function call ttm_bo_put(), it will free
gbo->bo that is struct ttm_buffer_object.
then, goto the err_drm_gem_object_release lable,
drm_gem_object_release() function will free gbo->bo.base, so cause use
after free.
crash log:
==================================================================
BUG: KASAN: use-after-free in drm_gem_object_release+0xf7/0x120
drivers/gpu/drm/drm_gem.c:953
Read of size 8 at addr ffff888064dfd928 by task syz-executor.2/1320
CPU: 1 PID: 1320 Comm: syz-executor.2 Not tainted 5.8.0-rc4+ #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.10.2-1ubuntu1 04/01/2014
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x18f/0x20d lib/dump_stack.c:118
print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383
__kasan_report mm/kasan/report.c:513 [inline]
kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
drm_gem_object_release+0xf7/0x120 drivers/gpu/drm/drm_gem.c:953
drm_gem_vram_init drivers/gpu/drm/drm_gem_vram_helper.c:211 [inline]
drm_gem_vram_create+0x3e6/0x5e0 drivers/gpu/drm/drm_gem_vram_helper.c:244
drm_gem_vram_fill_create_dumb+0x17a/0x310
drivers/gpu/drm/drm_gem_vram_helper.c:615
drm_gem_vram_driver_dumb_create+0x51/0xb0
drivers/gpu/drm/drm_gem_vram_helper.c:710
drm_mode_create_dumb+0x27c/0x300 drivers/gpu/drm/drm_dumb_buffers.c:94
drm_ioctl_kernel+0x220/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
drm_ioctl+0x4d2/0x96f drivers/gpu/drm/drm_ioctl.c:887
vfs_ioctl fs/ioctl.c:48 [inline]
ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
__do_sys_ioctl fs/ioctl.c:762 [inline]
__se_sys_ioctl fs/ioctl.c:760 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x467a29
Code: Bad RIP value.
RSP: 002b:00007f98f2d40c48 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 000000000076bf00 RCX: 0000000000467a29
RDX: 0000000020000040 RSI: 00000000c02064b2 RDI: 0000000000000003
RBP: 000000000070c600 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f98f2d416bc
R13: 0000000000000297 R14: 0000000000702040 R15: 00000000004d2418
Allocated by task 1320:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
__kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
kmem_cache_alloc_trace+0x14f/0x2d0 mm/slab.c:3551
kmalloc include/linux/slab.h:555 [inline]
kzalloc include/linux/slab.h:669 [inline]
drm_gem_vram_create+0x425/0x5e0 drivers/gpu/drm/drm_gem_vram_helper.c:239
drm_gem_vram_fill_create_dumb+0x17a/0x310
drivers/gpu/drm/drm_gem_vram_helper.c:615
drm_gem_vram_driver_dumb_create+0x51/0xb0
drivers/gpu/drm/drm_gem_vram_helper.c:710
drm_mode_create_dumb+0x27c/0x300 drivers/gpu/drm/drm_dumb_buffers.c:94
drm_ioctl_kernel+0x220/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
drm_ioctl+0x4d2/0x96f drivers/gpu/drm/drm_ioctl.c:887
vfs_ioctl fs/ioctl.c:48 [inline]
ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
__do_sys_ioctl fs/ioctl.c:762 [inline]
__se_sys_ioctl fs/ioctl.c:760 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9
Freed by task 1320:
save_stack+0x1b/0x40 mm/kasan/common.c:48
set_track mm/kasan/common.c:56 [inline]
kasan_set_free_info mm/kasan/common.c:316 [inline]
__kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455
__cache_free mm/slab.c:3426 [inline]
kfree+0x103/0x2c0 mm/slab.c:3757
ttm_bo_release+0xae1/0x1350 drivers/gpu/drm/ttm/ttm_bo.c:632
kref_put include/linux/kref.h:65 [inline]
ttm_bo_put drivers/gpu/drm/ttm/ttm_bo.c:638 [inline]
ttm_bo_init_reserved+0xb04/0xd00 drivers/gpu/drm/ttm/ttm_bo.c:1339
ttm_bo_init+0x10e/0x330 drivers/gpu/drm/ttm/ttm_bo.c:1366
drm_gem_vram_init drivers/gpu/drm/drm_gem_vram_helper.c:202 [inline]
drm_gem_vram_create+0x3c1/0x5e0 drivers/gpu/drm/drm_gem_vram_helper.c:244
drm_gem_vram_fill_create_dumb+0x17a/0x310
drivers/gpu/drm/drm_gem_vram_helper.c:615
drm_gem_vram_driver_dumb_create+0x51/0xb0
drivers/gpu/drm/drm_gem_vram_helper.c:710
drm_mode_create_dumb+0x27c/0x300 drivers/gpu/drm/drm_dumb_buffers.c:94
drm_ioctl_kernel+0x220/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
drm_ioctl+0x4d2/0x96f drivers/gpu/drm/drm_ioctl.c:887
vfs_ioctl fs/ioctl.c:48 [inline]
ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
__do_sys_ioctl fs/ioctl.c:762 [inline]
__se_sys_ioctl fs/ioctl.c:760 [inline]
__x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
entry_SYSCALL_64_after_hwframe+0x44/0xa9
The buggy address belongs to the object at ffff888064dfd800
which belongs to the cache kmalloc-1k of size 1024
The buggy address is located 296 bytes inside of
1024-byte region [ffff888064dfd800, ffff888064dfdc00)
The buggy address belongs to the page:
page:ffffea0001937f40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
flags: 0xfffe0000000200(slab)
raw: 00fffe0000000200 ffffea0000f3c248 ffffea0001ad7388 ffff88806bc00c40
raw: 0000000000000000 ffff888064dfd000 0000000100000002 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888064dfd800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888064dfd880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff888064dfd900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff888064dfd980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff888064dfda00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Regards,
butt3rflyh4ck.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2020-07-10 8:24 KASAN: use-after-free Read in drm_gem_object_release butt3rflyh4ck
@ 2020-07-10 10:39 ` Greg KH
2020-07-10 11:52 ` Dan Carpenter
2020-07-14 7:41 ` Thomas Zimmermann
2 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2020-07-10 10:39 UTC (permalink / raw)
To: butt3rflyh4ck
Cc: robdclark, security, airlied, syzkaller-bugs, dri-devel, chris,
seanpaul, sam, emil.velikov
On Fri, Jul 10, 2020 at 04:24:03PM +0800, butt3rflyh4ck wrote:
> I report a bug (in linux-5.8.0-rc4) found by syzkaller.
Great!
But can you also submit a fix for this as well? We are drowning in
syzkaller reports and just throwing them at us doesn't really help
anyone here anymore.
thanks,
greg k-h
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2020-07-10 8:24 KASAN: use-after-free Read in drm_gem_object_release butt3rflyh4ck
2020-07-10 10:39 ` Greg KH
@ 2020-07-10 11:52 ` Dan Carpenter
2020-07-10 14:01 ` butt3rflyh4ck
` (2 more replies)
2020-07-14 7:41 ` Thomas Zimmermann
2 siblings, 3 replies; 10+ messages in thread
From: Dan Carpenter @ 2020-07-10 11:52 UTC (permalink / raw)
To: butt3rflyh4ck
Cc: robdclark, security, airlied, syzkaller-bugs, dri-devel, chris,
seanpaul, sam, emil.velikov
On Fri, Jul 10, 2020 at 04:24:03PM +0800, butt3rflyh4ck wrote:
> I report a bug (in linux-5.8.0-rc4) found by syzkaller.
>
> kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.8.0-rc4.config
>
> I test the reproducer and crash too.
>
> In the drm_em_vram_t() function, ttm_bo_init() function call
^^^^^^^^^^^^^
This a typo. The function name is drm_gem_vram_init().
> ttm_bo_init_reserved(),
> the ttm_bo_init_reserved() function call ttm_bo_put(), it will free
> gbo->bo that is struct ttm_buffer_object.
>
> then, goto the err_drm_gem_object_release lable,
> drm_gem_object_release() function will free gbo->bo.base, so cause use
> after free.
>
There is a third free in drm_gem_vram_create(). This is a triple free
bug. The correct place to free this is in drm_gem_vram_create() because
that's where it was allocated.
This code is quite subtle so I'm not going to attempt to fix it because
I can't test it.
regards,
dan carpenter
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2020-07-10 11:52 ` Dan Carpenter
@ 2020-07-10 14:01 ` butt3rflyh4ck
2020-07-10 14:03 ` butt3rflyh4ck
2020-07-13 16:12 ` Daniel Vetter
2 siblings, 0 replies; 10+ messages in thread
From: butt3rflyh4ck @ 2020-07-10 14:01 UTC (permalink / raw)
To: Dan Carpenter
Cc: robdclark, security, airlied, syzkaller-bugs, dri-devel, chris,
Sean Paul, sam, emil.velikov
[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]
Thank you for pointing out my spelling error. ok, I upload a PoC and
compile it to a binary. you can test it.
regards,
butt3rflyh4ck.
On Fri, Jul 10, 2020 at 7:53 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Fri, Jul 10, 2020 at 04:24:03PM +0800, butt3rflyh4ck wrote:
> > I report a bug (in linux-5.8.0-rc4) found by syzkaller.
> >
> > kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.8.0-rc4.config
> >
> > I test the reproducer and crash too.
> >
> > In the drm_em_vram_t() function, ttm_bo_init() function call
> ^^^^^^^^^^^^^
> This a typo. The function name is drm_gem_vram_init().
>
> > ttm_bo_init_reserved(),
> > the ttm_bo_init_reserved() function call ttm_bo_put(), it will free
> > gbo->bo that is struct ttm_buffer_object.
> >
> > then, goto the err_drm_gem_object_release lable,
> > drm_gem_object_release() function will free gbo->bo.base, so cause use
> > after free.
> >
>
> There is a third free in drm_gem_vram_create(). This is a triple free
> bug. The correct place to free this is in drm_gem_vram_create() because
> that's where it was allocated.
>
> This code is quite subtle so I'm not going to attempt to fix it because
> I can't test it.
>
> regards,
> dan carpenter
>
[-- Attachment #2: uaf-drm_gem_object_release.c --]
[-- Type: application/octet-stream, Size: 4647 bytes --]
[-- Attachment #3: uaf-drm_gem_object_release --]
[-- Type: application/octet-stream, Size: 871704 bytes --]
[-- Attachment #4: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2020-07-10 11:52 ` Dan Carpenter
2020-07-10 14:01 ` butt3rflyh4ck
@ 2020-07-10 14:03 ` butt3rflyh4ck
2020-07-13 16:12 ` Daniel Vetter
2 siblings, 0 replies; 10+ messages in thread
From: butt3rflyh4ck @ 2020-07-10 14:03 UTC (permalink / raw)
To: Dan Carpenter
Cc: robdclark, security, airlied, Greg Kroah-Hartman, syzkaller-bugs,
dri-devel, chris, Sean Paul, sam, emil.velikov
[-- Attachment #1: Type: text/plain, Size: 1254 bytes --]
Thank you for pointing out my spelling error. ok, I upload a PoC and
compile it to a binary. you can test it.
regards,
butt3rflyh4ck.
On Fri, Jul 10, 2020 at 7:53 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Fri, Jul 10, 2020 at 04:24:03PM +0800, butt3rflyh4ck wrote:
> > I report a bug (in linux-5.8.0-rc4) found by syzkaller.
> >
> > kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.8.0-rc4.config
> >
> > I test the reproducer and crash too.
> >
> > In the drm_em_vram_t() function, ttm_bo_init() function call
> ^^^^^^^^^^^^^
> This a typo. The function name is drm_gem_vram_init().
>
> > ttm_bo_init_reserved(),
> > the ttm_bo_init_reserved() function call ttm_bo_put(), it will free
> > gbo->bo that is struct ttm_buffer_object.
> >
> > then, goto the err_drm_gem_object_release lable,
> > drm_gem_object_release() function will free gbo->bo.base, so cause use
> > after free.
> >
>
> There is a third free in drm_gem_vram_create(). This is a triple free
> bug. The correct place to free this is in drm_gem_vram_create() because
> that's where it was allocated.
>
> This code is quite subtle so I'm not going to attempt to fix it because
> I can't test it.
>
> regards,
> dan carpenter
>
[-- Attachment #2: uaf-drm_gem_object_release.c --]
[-- Type: application/octet-stream, Size: 4647 bytes --]
[-- Attachment #3: uaf-drm_gem_object_release --]
[-- Type: application/octet-stream, Size: 871704 bytes --]
[-- Attachment #4: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2020-07-10 11:52 ` Dan Carpenter
2020-07-10 14:01 ` butt3rflyh4ck
2020-07-10 14:03 ` butt3rflyh4ck
@ 2020-07-13 16:12 ` Daniel Vetter
2020-07-13 16:47 ` butt3rflyh4ck
2 siblings, 1 reply; 10+ messages in thread
From: Daniel Vetter @ 2020-07-13 16:12 UTC (permalink / raw)
To: Dan Carpenter, Thomas Zimmermann
Cc: Rob Clark, security, Dave Airlie, butt3rflyh4ck, syzkaller-bugs,
dri-devel, Wilson, Chris, Sean Paul, Sam Ravnborg, Emil Velikov
Adding Thomas, who's the main author for vram helpers.
-Daniel
On Fri, Jul 10, 2020 at 1:53 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Fri, Jul 10, 2020 at 04:24:03PM +0800, butt3rflyh4ck wrote:
> > I report a bug (in linux-5.8.0-rc4) found by syzkaller.
> >
> > kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.8.0-rc4.config
> >
> > I test the reproducer and crash too.
> >
> > In the drm_em_vram_t() function, ttm_bo_init() function call
> ^^^^^^^^^^^^^
> This a typo. The function name is drm_gem_vram_init().
>
> > ttm_bo_init_reserved(),
> > the ttm_bo_init_reserved() function call ttm_bo_put(), it will free
> > gbo->bo that is struct ttm_buffer_object.
> >
> > then, goto the err_drm_gem_object_release lable,
> > drm_gem_object_release() function will free gbo->bo.base, so cause use
> > after free.
> >
>
> There is a third free in drm_gem_vram_create(). This is a triple free
> bug. The correct place to free this is in drm_gem_vram_create() because
> that's where it was allocated.
>
> This code is quite subtle so I'm not going to attempt to fix it because
> I can't test it.
>
> regards,
> dan carpenter
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2020-07-13 16:12 ` Daniel Vetter
@ 2020-07-13 16:47 ` butt3rflyh4ck
0 siblings, 0 replies; 10+ messages in thread
From: butt3rflyh4ck @ 2020-07-13 16:47 UTC (permalink / raw)
To: Daniel Vetter
Cc: Rob Clark, security, Dave Airlie, Greg Kroah-Hartman,
syzkaller-bugs, dri-devel, Wilson, Chris, Sean Paul,
Thomas Zimmermann, Sam Ravnborg, Dan Carpenter, Emil Velikov
[-- Attachment #1: Type: text/plain, Size: 1589 bytes --]
Ok, firstly, thank Dan Carpenter for pointing out my spelling error
and I upload a PoC and compile it to a binary, hope that helpful for
you to test it.
regards,
butt3rflyh4ck
On Tue, Jul 14, 2020 at 12:12 AM Daniel Vetter <daniel@ffwll.ch> wrote:
>
> Adding Thomas, who's the main author for vram helpers.
> -Daniel
>
> On Fri, Jul 10, 2020 at 1:53 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > On Fri, Jul 10, 2020 at 04:24:03PM +0800, butt3rflyh4ck wrote:
> > > I report a bug (in linux-5.8.0-rc4) found by syzkaller.
> > >
> > > kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.8.0-rc4.config
> > >
> > > I test the reproducer and crash too.
> > >
> > > In the drm_em_vram_t() function, ttm_bo_init() function call
> > ^^^^^^^^^^^^^
> > This a typo. The function name is drm_gem_vram_init().
> >
> > > ttm_bo_init_reserved(),
> > > the ttm_bo_init_reserved() function call ttm_bo_put(), it will free
> > > gbo->bo that is struct ttm_buffer_object.
> > >
> > > then, goto the err_drm_gem_object_release lable,
> > > drm_gem_object_release() function will free gbo->bo.base, so cause use
> > > after free.
> > >
> >
> > There is a third free in drm_gem_vram_create(). This is a triple free
> > bug. The correct place to free this is in drm_gem_vram_create() because
> > that's where it was allocated.
> >
> > This code is quite subtle so I'm not going to attempt to fix it because
> > I can't test it.
> >
> > regards,
> > dan carpenter
> >
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
[-- Attachment #2: uaf-drm_gem_object_release --]
[-- Type: application/octet-stream, Size: 871704 bytes --]
[-- Attachment #3: uaf-drm_gem_object_release.c --]
[-- Type: application/octet-stream, Size: 4647 bytes --]
[-- Attachment #4: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2020-07-10 8:24 KASAN: use-after-free Read in drm_gem_object_release butt3rflyh4ck
2020-07-10 10:39 ` Greg KH
2020-07-10 11:52 ` Dan Carpenter
@ 2020-07-14 7:41 ` Thomas Zimmermann
2020-07-14 8:46 ` Thomas Zimmermann
2 siblings, 1 reply; 10+ messages in thread
From: Thomas Zimmermann @ 2020-07-14 7:41 UTC (permalink / raw)
To: butt3rflyh4ck, security
Cc: robdclark, airlied, syzkaller-bugs, dri-devel, chris, seanpaul,
sam, emil.velikov
[-- Attachment #1.1.1: Type: text/plain, Size: 7020 bytes --]
Hi
Am 10.07.20 um 10:24 schrieb butt3rflyh4ck:
> I report a bug (in linux-5.8.0-rc4) found by syzkaller.
>
> kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.8.0-rc4.config
>
> I test the reproducer and crash too.
>
> In the drm_em_vram_t() function, ttm_bo_init() function call
> ttm_bo_init_reserved(),
> the ttm_bo_init_reserved() function call ttm_bo_put(), it will free
> gbo->bo that is struct ttm_buffer_object.
>
> then, goto the err_drm_gem_object_release lable,
> drm_gem_object_release() function will free gbo->bo.base, so cause use
> after free.
Thanks for reporting. I think we recently had a patch for this problem,
[1] but I asked for some changes. Are you in a position to test a fix?
Best regards
Thomas
[1]
https://lore.kernel.org/dri-devel/20200620062134.82961-1-jiayang5@huawei.com/
>
> crash log:
> ==================================================================
> BUG: KASAN: use-after-free in drm_gem_object_release+0xf7/0x120
> drivers/gpu/drm/drm_gem.c:953
> Read of size 8 at addr ffff888064dfd928 by task syz-executor.2/1320
>
> CPU: 1 PID: 1320 Comm: syz-executor.2 Not tainted 5.8.0-rc4+ #1
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
> 1.10.2-1ubuntu1 04/01/2014
> Call Trace:
> __dump_stack lib/dump_stack.c:77 [inline]
> dump_stack+0x18f/0x20d lib/dump_stack.c:118
> print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383
> __kasan_report mm/kasan/report.c:513 [inline]
> kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
> drm_gem_object_release+0xf7/0x120 drivers/gpu/drm/drm_gem.c:953
> drm_gem_vram_init drivers/gpu/drm/drm_gem_vram_helper.c:211 [inline]
> drm_gem_vram_create+0x3e6/0x5e0 drivers/gpu/drm/drm_gem_vram_helper.c:244
> drm_gem_vram_fill_create_dumb+0x17a/0x310
> drivers/gpu/drm/drm_gem_vram_helper.c:615
> drm_gem_vram_driver_dumb_create+0x51/0xb0
> drivers/gpu/drm/drm_gem_vram_helper.c:710
> drm_mode_create_dumb+0x27c/0x300 drivers/gpu/drm/drm_dumb_buffers.c:94
> drm_ioctl_kernel+0x220/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
> drm_ioctl+0x4d2/0x96f drivers/gpu/drm/drm_ioctl.c:887
> vfs_ioctl fs/ioctl.c:48 [inline]
> ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
> __do_sys_ioctl fs/ioctl.c:762 [inline]
> __se_sys_ioctl fs/ioctl.c:760 [inline]
> __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
> do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
> RIP: 0033:0x467a29
> Code: Bad RIP value.
> RSP: 002b:00007f98f2d40c48 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
> RAX: ffffffffffffffda RBX: 000000000076bf00 RCX: 0000000000467a29
> RDX: 0000000020000040 RSI: 00000000c02064b2 RDI: 0000000000000003
> RBP: 000000000070c600 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 00007f98f2d416bc
> R13: 0000000000000297 R14: 0000000000702040 R15: 00000000004d2418
>
> Allocated by task 1320:
> save_stack+0x1b/0x40 mm/kasan/common.c:48
> set_track mm/kasan/common.c:56 [inline]
> __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
> kmem_cache_alloc_trace+0x14f/0x2d0 mm/slab.c:3551
> kmalloc include/linux/slab.h:555 [inline]
> kzalloc include/linux/slab.h:669 [inline]
> drm_gem_vram_create+0x425/0x5e0 drivers/gpu/drm/drm_gem_vram_helper.c:239
> drm_gem_vram_fill_create_dumb+0x17a/0x310
> drivers/gpu/drm/drm_gem_vram_helper.c:615
> drm_gem_vram_driver_dumb_create+0x51/0xb0
> drivers/gpu/drm/drm_gem_vram_helper.c:710
> drm_mode_create_dumb+0x27c/0x300 drivers/gpu/drm/drm_dumb_buffers.c:94
> drm_ioctl_kernel+0x220/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
> drm_ioctl+0x4d2/0x96f drivers/gpu/drm/drm_ioctl.c:887
> vfs_ioctl fs/ioctl.c:48 [inline]
> ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
> __do_sys_ioctl fs/ioctl.c:762 [inline]
> __se_sys_ioctl fs/ioctl.c:760 [inline]
> __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
> do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> Freed by task 1320:
> save_stack+0x1b/0x40 mm/kasan/common.c:48
> set_track mm/kasan/common.c:56 [inline]
> kasan_set_free_info mm/kasan/common.c:316 [inline]
> __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455
> __cache_free mm/slab.c:3426 [inline]
> kfree+0x103/0x2c0 mm/slab.c:3757
> ttm_bo_release+0xae1/0x1350 drivers/gpu/drm/ttm/ttm_bo.c:632
> kref_put include/linux/kref.h:65 [inline]
> ttm_bo_put drivers/gpu/drm/ttm/ttm_bo.c:638 [inline]
> ttm_bo_init_reserved+0xb04/0xd00 drivers/gpu/drm/ttm/ttm_bo.c:1339
> ttm_bo_init+0x10e/0x330 drivers/gpu/drm/ttm/ttm_bo.c:1366
> drm_gem_vram_init drivers/gpu/drm/drm_gem_vram_helper.c:202 [inline]
> drm_gem_vram_create+0x3c1/0x5e0 drivers/gpu/drm/drm_gem_vram_helper.c:244
> drm_gem_vram_fill_create_dumb+0x17a/0x310
> drivers/gpu/drm/drm_gem_vram_helper.c:615
> drm_gem_vram_driver_dumb_create+0x51/0xb0
> drivers/gpu/drm/drm_gem_vram_helper.c:710
> drm_mode_create_dumb+0x27c/0x300 drivers/gpu/drm/drm_dumb_buffers.c:94
> drm_ioctl_kernel+0x220/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
> drm_ioctl+0x4d2/0x96f drivers/gpu/drm/drm_ioctl.c:887
> vfs_ioctl fs/ioctl.c:48 [inline]
> ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
> __do_sys_ioctl fs/ioctl.c:762 [inline]
> __se_sys_ioctl fs/ioctl.c:760 [inline]
> __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
> do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
>
> The buggy address belongs to the object at ffff888064dfd800
> which belongs to the cache kmalloc-1k of size 1024
> The buggy address is located 296 bytes inside of
> 1024-byte region [ffff888064dfd800, ffff888064dfdc00)
> The buggy address belongs to the page:
> page:ffffea0001937f40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
> flags: 0xfffe0000000200(slab)
> raw: 00fffe0000000200 ffffea0000f3c248 ffffea0001ad7388 ffff88806bc00c40
> raw: 0000000000000000 ffff888064dfd000 0000000100000002 0000000000000000
> page dumped because: kasan: bad access detected
>
> Memory state around the buggy address:
> ffff888064dfd800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff888064dfd880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>> ffff888064dfd900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ^
> ffff888064dfd980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ffff888064dfda00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
> ==================================================================
>
> Regards,
> butt3rflyh4ck.
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 516 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
2020-07-14 7:41 ` Thomas Zimmermann
@ 2020-07-14 8:46 ` Thomas Zimmermann
0 siblings, 0 replies; 10+ messages in thread
From: Thomas Zimmermann @ 2020-07-14 8:46 UTC (permalink / raw)
To: butt3rflyh4ck, security
Cc: robdclark, airlied, syzkaller-bugs, dri-devel, chris, seanpaul,
sam, emil.velikov
[-- Attachment #1.1.1: Type: text/plain, Size: 7410 bytes --]
Am 14.07.20 um 09:41 schrieb Thomas Zimmermann:
> Hi
>
> Am 10.07.20 um 10:24 schrieb butt3rflyh4ck:
>> I report a bug (in linux-5.8.0-rc4) found by syzkaller.
>>
>> kernel config: https://github.com/butterflyhack/syzkaller-fuzz/blob/master/v5.8.0-rc4.config
>>
>> I test the reproducer and crash too.
>>
>> In the drm_em_vram_t() function, ttm_bo_init() function call
>> ttm_bo_init_reserved(),
>> the ttm_bo_init_reserved() function call ttm_bo_put(), it will free
>> gbo->bo that is struct ttm_buffer_object.
>>
>> then, goto the err_drm_gem_object_release lable,
>> drm_gem_object_release() function will free gbo->bo.base, so cause use
>> after free.
>
> Thanks for reporting. I think we recently had a patch for this problem,
> [1] but I asked for some changes. Are you in a position to test a fix?
>
> Best regards
> Thomas
>
>
> [1]
> https://lore.kernel.org/dri-devel/20200620062134.82961-1-jiayang5@huawei.com/
I sent out a patchset with this patch and a few additional changes.
https://lore.kernel.org/dri-devel/20200714083238.28479-1-tzimmermann@suse.de/T/#t
Best regards
Thomas
>
>>
>> crash log:
>> ==================================================================
>> BUG: KASAN: use-after-free in drm_gem_object_release+0xf7/0x120
>> drivers/gpu/drm/drm_gem.c:953
>> Read of size 8 at addr ffff888064dfd928 by task syz-executor.2/1320
>>
>> CPU: 1 PID: 1320 Comm: syz-executor.2 Not tainted 5.8.0-rc4+ #1
>> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
>> 1.10.2-1ubuntu1 04/01/2014
>> Call Trace:
>> __dump_stack lib/dump_stack.c:77 [inline]
>> dump_stack+0x18f/0x20d lib/dump_stack.c:118
>> print_address_description.constprop.0.cold+0xae/0x436 mm/kasan/report.c:383
>> __kasan_report mm/kasan/report.c:513 [inline]
>> kasan_report.cold+0x1f/0x37 mm/kasan/report.c:530
>> drm_gem_object_release+0xf7/0x120 drivers/gpu/drm/drm_gem.c:953
>> drm_gem_vram_init drivers/gpu/drm/drm_gem_vram_helper.c:211 [inline]
>> drm_gem_vram_create+0x3e6/0x5e0 drivers/gpu/drm/drm_gem_vram_helper.c:244
>> drm_gem_vram_fill_create_dumb+0x17a/0x310
>> drivers/gpu/drm/drm_gem_vram_helper.c:615
>> drm_gem_vram_driver_dumb_create+0x51/0xb0
>> drivers/gpu/drm/drm_gem_vram_helper.c:710
>> drm_mode_create_dumb+0x27c/0x300 drivers/gpu/drm/drm_dumb_buffers.c:94
>> drm_ioctl_kernel+0x220/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
>> drm_ioctl+0x4d2/0x96f drivers/gpu/drm/drm_ioctl.c:887
>> vfs_ioctl fs/ioctl.c:48 [inline]
>> ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
>> __do_sys_ioctl fs/ioctl.c:762 [inline]
>> __se_sys_ioctl fs/ioctl.c:760 [inline]
>> __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
>> do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
>> entry_SYSCALL_64_after_hwframe+0x44/0xa9
>> RIP: 0033:0x467a29
>> Code: Bad RIP value.
>> RSP: 002b:00007f98f2d40c48 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
>> RAX: ffffffffffffffda RBX: 000000000076bf00 RCX: 0000000000467a29
>> RDX: 0000000020000040 RSI: 00000000c02064b2 RDI: 0000000000000003
>> RBP: 000000000070c600 R08: 0000000000000000 R09: 0000000000000000
>> R10: 0000000000000000 R11: 0000000000000246 R12: 00007f98f2d416bc
>> R13: 0000000000000297 R14: 0000000000702040 R15: 00000000004d2418
>>
>> Allocated by task 1320:
>> save_stack+0x1b/0x40 mm/kasan/common.c:48
>> set_track mm/kasan/common.c:56 [inline]
>> __kasan_kmalloc.constprop.0+0xc2/0xd0 mm/kasan/common.c:494
>> kmem_cache_alloc_trace+0x14f/0x2d0 mm/slab.c:3551
>> kmalloc include/linux/slab.h:555 [inline]
>> kzalloc include/linux/slab.h:669 [inline]
>> drm_gem_vram_create+0x425/0x5e0 drivers/gpu/drm/drm_gem_vram_helper.c:239
>> drm_gem_vram_fill_create_dumb+0x17a/0x310
>> drivers/gpu/drm/drm_gem_vram_helper.c:615
>> drm_gem_vram_driver_dumb_create+0x51/0xb0
>> drivers/gpu/drm/drm_gem_vram_helper.c:710
>> drm_mode_create_dumb+0x27c/0x300 drivers/gpu/drm/drm_dumb_buffers.c:94
>> drm_ioctl_kernel+0x220/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
>> drm_ioctl+0x4d2/0x96f drivers/gpu/drm/drm_ioctl.c:887
>> vfs_ioctl fs/ioctl.c:48 [inline]
>> ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
>> __do_sys_ioctl fs/ioctl.c:762 [inline]
>> __se_sys_ioctl fs/ioctl.c:760 [inline]
>> __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
>> do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
>> entry_SYSCALL_64_after_hwframe+0x44/0xa9
>>
>> Freed by task 1320:
>> save_stack+0x1b/0x40 mm/kasan/common.c:48
>> set_track mm/kasan/common.c:56 [inline]
>> kasan_set_free_info mm/kasan/common.c:316 [inline]
>> __kasan_slab_free+0xf5/0x140 mm/kasan/common.c:455
>> __cache_free mm/slab.c:3426 [inline]
>> kfree+0x103/0x2c0 mm/slab.c:3757
>> ttm_bo_release+0xae1/0x1350 drivers/gpu/drm/ttm/ttm_bo.c:632
>> kref_put include/linux/kref.h:65 [inline]
>> ttm_bo_put drivers/gpu/drm/ttm/ttm_bo.c:638 [inline]
>> ttm_bo_init_reserved+0xb04/0xd00 drivers/gpu/drm/ttm/ttm_bo.c:1339
>> ttm_bo_init+0x10e/0x330 drivers/gpu/drm/ttm/ttm_bo.c:1366
>> drm_gem_vram_init drivers/gpu/drm/drm_gem_vram_helper.c:202 [inline]
>> drm_gem_vram_create+0x3c1/0x5e0 drivers/gpu/drm/drm_gem_vram_helper.c:244
>> drm_gem_vram_fill_create_dumb+0x17a/0x310
>> drivers/gpu/drm/drm_gem_vram_helper.c:615
>> drm_gem_vram_driver_dumb_create+0x51/0xb0
>> drivers/gpu/drm/drm_gem_vram_helper.c:710
>> drm_mode_create_dumb+0x27c/0x300 drivers/gpu/drm/drm_dumb_buffers.c:94
>> drm_ioctl_kernel+0x220/0x2e0 drivers/gpu/drm/drm_ioctl.c:787
>> drm_ioctl+0x4d2/0x96f drivers/gpu/drm/drm_ioctl.c:887
>> vfs_ioctl fs/ioctl.c:48 [inline]
>> ksys_ioctl+0x11a/0x180 fs/ioctl.c:753
>> __do_sys_ioctl fs/ioctl.c:762 [inline]
>> __se_sys_ioctl fs/ioctl.c:760 [inline]
>> __x64_sys_ioctl+0x6f/0xb0 fs/ioctl.c:760
>> do_syscall_64+0x60/0xe0 arch/x86/entry/common.c:384
>> entry_SYSCALL_64_after_hwframe+0x44/0xa9
>>
>> The buggy address belongs to the object at ffff888064dfd800
>> which belongs to the cache kmalloc-1k of size 1024
>> The buggy address is located 296 bytes inside of
>> 1024-byte region [ffff888064dfd800, ffff888064dfdc00)
>> The buggy address belongs to the page:
>> page:ffffea0001937f40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0
>> flags: 0xfffe0000000200(slab)
>> raw: 00fffe0000000200 ffffea0000f3c248 ffffea0001ad7388 ffff88806bc00c40
>> raw: 0000000000000000 ffff888064dfd000 0000000100000002 0000000000000000
>> page dumped because: kasan: bad access detected
>>
>> Memory state around the buggy address:
>> ffff888064dfd800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>> ffff888064dfd880: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>>> ffff888064dfd900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>> ^
>> ffff888064dfd980: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>> ffff888064dfda00: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>> ==================================================================
>>
>> Regards,
>> butt3rflyh4ck.
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel
>>
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 516 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: KASAN: use-after-free Read in drm_gem_object_release
[not found] <00000000000053fea105791276d8@google.com>
@ 2018-10-29 11:51 ` Dmitry Vyukov
0 siblings, 0 replies; 10+ 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] 10+ messages in thread
end of thread, back to index
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10 8:24 KASAN: use-after-free Read in drm_gem_object_release butt3rflyh4ck
2020-07-10 10:39 ` Greg KH
2020-07-10 11:52 ` Dan Carpenter
2020-07-10 14:01 ` butt3rflyh4ck
2020-07-10 14:03 ` butt3rflyh4ck
2020-07-13 16:12 ` Daniel Vetter
2020-07-13 16:47 ` butt3rflyh4ck
2020-07-14 7:41 ` Thomas Zimmermann
2020-07-14 8:46 ` Thomas Zimmermann
[not found] <00000000000053fea105791276d8@google.com>
2018-10-29 11:51 ` Dmitry Vyukov
dri-devel Archive on lore.kernel.org
Archives are clonable:
git clone --mirror https://lore.kernel.org/dri-devel/0 dri-devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 dri-devel dri-devel/ https://lore.kernel.org/dri-devel \
dri-devel@lists.freedesktop.org
public-inbox-index dri-devel
Example config snippet for mirrors
Newsgroup available over NNTP:
nntp://nntp.lore.kernel.org/org.freedesktop.lists.dri-devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git