[syzbot] [dri?] WARNING in drm_prime_destroy_file_private (2)

17 views
Skip to first unread message

syzbot

unread,
Dec 27, 2023, 3:51:20 PM12/27/23
to air...@gmail.com, akinob...@gmail.com, ak...@linux-foundation.org, christia...@amd.com, dan...@ffwll.ch, dri-...@lists.freedesktop.org, j...@nvidia.com, linaro...@lists.linaro.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, maarten....@linux.intel.com, mri...@kernel.org, sumit....@linaro.org, syzkall...@googlegroups.com, tzimm...@suse.de, zhengq...@bytedance.com
Hello,

syzbot found the following issue on:

HEAD commit: 5254c0cbc92d Merge tag 'block-6.7-2023-12-22' of git://git..
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=10cc6995e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=314e9ad033a7d3a7
dashboard link: https://syzkaller.appspot.com/bug?extid=59dcc2e7283a6f5f5ba1
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13e35809e80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=155d5fd6e80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ebe09a5995ee/disk-5254c0cb.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/02178d7f5f98/vmlinux-5254c0cb.xz
kernel image: https://storage.googleapis.com/syzbot-assets/12307f47d87c/bzImage-5254c0cb.xz

The issue was bisected to:

commit ea4452de2ae987342fadbdd2c044034e6480daad
Author: Qi Zheng <zhengq...@bytedance.com>
Date: Fri Nov 18 10:00:11 2022 +0000

mm: fix unexpected changes to {failslab|fail_page_alloc}.attr

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=13027f76e80000
final oops: https://syzkaller.appspot.com/x/report.txt?x=10827f76e80000
console output: https://syzkaller.appspot.com/x/log.txt?x=17027f76e80000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+59dcc2...@syzkaller.appspotmail.com
Fixes: ea4452de2ae9 ("mm: fix unexpected changes to {failslab|fail_page_alloc}.attr")

R10: 0000000000000000 R11: 0000000000000246 R12: 00007efe98069194
R13: 00007efe97fd2210 R14: 0000000000000002 R15: 6972642f7665642f
</TASK>
------------[ cut here ]------------
WARNING: CPU: 0 PID: 5107 at drivers/gpu/drm/drm_prime.c:227 drm_prime_destroy_file_private+0x43/0x60 drivers/gpu/drm/drm_prime.c:227
Modules linked in:
CPU: 0 PID: 5107 Comm: syz-executor227 Not tainted 6.7.0-rc6-syzkaller-00248-g5254c0cbc92d #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
RIP: 0010:drm_prime_destroy_file_private+0x43/0x60 drivers/gpu/drm/drm_prime.c:227
Code: 00 00 fc ff df 48 89 fa 48 c1 ea 03 80 3c 02 00 75 21 48 8b 83 90 00 00 00 48 85 c0 75 06 5b e9 13 f1 93 fc e8 0e f1 93 fc 90 <0f> 0b 90 5b e9 04 f1 93 fc e8 3f 9b ea fc eb d8 66 66 2e 0f 1f 84
RSP: 0018:ffffc90003bdf9e0 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff888019f28378 RCX: ffffc90003bdf9b0
RDX: ffff888018ff9dc0 RSI: ffffffff84f380c2 RDI: ffff888019f28408
RBP: ffff888019f28000 R08: 0000000000000001 R09: 0000000000000001
R10: ffffffff8f193a57 R11: 0000000000000000 R12: ffff88814829a000
R13: ffff888019f282a8 R14: ffff88814829a068 R15: ffff88814829a0a0
FS: 0000000000000000(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007efe98050410 CR3: 000000006d1ff000 CR4: 0000000000350ef0
Call Trace:
<TASK>
drm_file_free.part.0+0x738/0xb90 drivers/gpu/drm/drm_file.c:290
drm_file_free drivers/gpu/drm/drm_file.c:247 [inline]
drm_close_helper.isra.0+0x180/0x1f0 drivers/gpu/drm/drm_file.c:307
drm_release+0x22a/0x4f0 drivers/gpu/drm/drm_file.c:494
__fput+0x270/0xb70 fs/file_table.c:394
task_work_run+0x14d/0x240 kernel/task_work.c:180
exit_task_work include/linux/task_work.h:38 [inline]
do_exit+0xa8a/0x2ad0 kernel/exit.c:869
do_group_exit+0xd4/0x2a0 kernel/exit.c:1018
get_signal+0x23b5/0x2790 kernel/signal.c:2904
arch_do_signal_or_restart+0x90/0x7f0 arch/x86/kernel/signal.c:309
exit_to_user_mode_loop kernel/entry/common.c:168 [inline]
exit_to_user_mode_prepare+0x121/0x240 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x1e/0x60 kernel/entry/common.c:296
do_syscall_64+0x4d/0x110 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7efe98014769
Code: Unable to access opcode bytes at 0x7efe9801473f.
RSP: 002b:00007efe97fd2208 EFLAGS: 00000246 ORIG_RAX: 00000000000000ca
RAX: fffffffffffffe00 RBX: 00007efe9809c408 RCX: 00007efe98014769
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 00007efe9809c408
RBP: 00007efe9809c400 R08: 0000000000003131 R09: 0000000000003131
R10: 0000000000000000 R11: 0000000000000246 R12: 00007efe98069194
R13: 00007efe97fd2210 R14: 0000000000000002 R15: 6972642f7665642f
</TASK>


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

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Qi Zheng

unread,
Dec 28, 2023, 4:58:33 AM12/28/23
to syzbot, air...@gmail.com, akinob...@gmail.com, ak...@linux-foundation.org, christia...@amd.com, dan...@ffwll.ch, dri-...@lists.freedesktop.org, j...@nvidia.com, linaro...@lists.linaro.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, maarten....@linux.intel.com, mri...@kernel.org, sumit....@linaro.org, syzkall...@googlegroups.com, tzimm...@suse.de
The warning is caused by !RB_EMPTY_ROOT(&prime_fpriv->dmabufs):

drm_prime_destroy_file_private
--> WARN_ON(!RB_EMPTY_ROOT(&prime_fpriv->dmabufs));

It seems irrelevant to the logic of fault injection. So I don't see
why the commit ea4452de2ae9 can cause this warning. :(

Hillf Danton

unread,
Dec 28, 2023, 6:56:43 AM12/28/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Wed, 27 Dec 2023 12:51:18 -0800
> HEAD commit: 5254c0cbc92d Merge tag 'block-6.7-2023-12-22' of git://git..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=155d5fd6e80000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

--- x/drivers/gpu/drm/drm_file.c
+++ y/drivers/gpu/drm/drm_file.c
@@ -287,6 +287,7 @@ void drm_file_free(struct drm_file *file
if (dev->driver->postclose)
dev->driver->postclose(dev, file);

+ drm_gem_release(dev, file);
drm_prime_destroy_file_private(&file->prime);

WARN_ON(!list_empty(&file->event_list));
--

syzbot

unread,
Dec 28, 2023, 7:16:06 AM12/28/23
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
WARNING in drm_prime_destroy_file_private

------------[ cut here ]------------
WARNING: CPU: 0 PID: 5524 at drivers/gpu/drm/drm_prime.c:227 drm_prime_destroy_file_private+0x43/0x60 drivers/gpu/drm/drm_prime.c:227
Modules linked in:
CPU: 0 PID: 5524 Comm: syz-executor.0 Not tainted 6.7.0-rc7-syzkaller-00016-gf5837722ffec-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
RIP: 0010:drm_prime_destroy_file_private+0x43/0x60 drivers/gpu/drm/drm_prime.c:227
Code: 00 00 fc ff df 48 89 fa 48 c1 ea 03 80 3c 02 00 75 21 48 8b 83 90 00 00 00 48 85 c0 75 06 5b e9 63 ee 93 fc e8 5e ee 93 fc 90 <0f> 0b 90 5b e9 54 ee 93 fc e8 8f 98 ea fc eb d8 66 66 2e 0f 1f 84
RSP: 0018:ffffc900056efd90 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffff8880774dc378 RCX: ffffffff8a70d235
RDX: ffff88801d6dd940 RSI: ffffffff84f38372 RDI: ffff8880774dc408
RBP: ffff8880774dc000 R08: 0000000000000007 R09: 0000000000000002
R10: 0000000000000000 R11: 0000000000000000 R12: ffff88801ca98000
R13: ffff8880774dc2a8 R14: ffff88801ca98068 R15: ffff88801ca980a0
FS: 00005555562e1480(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555cfd62e950 CR3: 0000000020039000 CR4: 0000000000350ef0
Call Trace:
<TASK>
drm_file_free.part.0+0x743/0xba0 drivers/gpu/drm/drm_file.c:291
drm_file_free drivers/gpu/drm/drm_file.c:247 [inline]
drm_close_helper.isra.0+0x180/0x1f0 drivers/gpu/drm/drm_file.c:308
drm_release+0x22a/0x4f0 drivers/gpu/drm/drm_file.c:495
__fput+0x270/0xb70 fs/file_table.c:394
__fput_sync+0x47/0x50 fs/file_table.c:475
__do_sys_close fs/open.c:1587 [inline]
__se_sys_close fs/open.c:1572 [inline]
__x64_sys_close+0x87/0xf0 fs/open.c:1572
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x40/0x110 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7fb53da7bbda
Code: 48 3d 00 f0 ff ff 77 48 c3 0f 1f 80 00 00 00 00 48 83 ec 18 89 7c 24 0c e8 03 7f 02 00 8b 7c 24 0c 89 c2 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 36 89 d7 89 44 24 0c e8 63 7f 02 00 8b 44 24
RSP: 002b:00007ffe292dcd60 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007fb53da7bbda
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007fb53db9d980 R08: 0000001b2e960000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000014229
R13: ffffffffffffffff R14: 00007fb53d600000 R15: 0000000000013ee8
</TASK>


Tested on:

commit: f5837722 Merge tag 'mm-hotfixes-stable-2023-12-27-15-0..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=173b1a7ee80000
kernel config: https://syzkaller.appspot.com/x/.config?x=c7bcb8f62f1e2c3e
dashboard link: https://syzkaller.appspot.com/bug?extid=59dcc2e7283a6f5f5ba1
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=17f84d09e80000

Hillf Danton

unread,
Dec 29, 2023, 6:29:14 AM12/29/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Wed, 27 Dec 2023 12:51:18 -0800
> HEAD commit: 5254c0cbc92d Merge tag 'block-6.7-2023-12-22' of git://git..
> git tree: upstream
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -287,6 +287,7 @@ void drm_file_free(struct drm_file *file
if (dev->driver->postclose)
dev->driver->postclose(dev, file);

+ drm_prime_del_handles(&file->prime);
drm_prime_destroy_file_private(&file->prime);

WARN_ON(!list_empty(&file->event_list));
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -76,6 +76,7 @@ void drm_prime_init_file_private(struct
void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
uint32_t handle);
+void drm_prime_del_handles(struct drm_prime_file_private *prime_fpriv);

/* drm_drv.c */
struct drm_minor *drm_minor_acquire(unsigned int minor_id);
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -185,6 +185,27 @@ static int drm_prime_lookup_buf_handle(s
return -ENOENT;
}

+void drm_prime_del_handles(struct drm_prime_file_private *prime_fpriv)
+{
+ struct drm_prime_member *member;
+ struct rb_node *rb;
+
+ mutex_lock(&prime_fpriv->lock);
+ for (;;) {
+ rb = rb_first(&prime_fpriv->dmabufs);
+ if (!rb)
+ break;
+ member = rb_entry(rb, struct drm_prime_member, handle_rb);
+
+ rb_erase(&member->handle_rb, &prime_fpriv->handles);
+ rb_erase(&member->dmabuf_rb, &prime_fpriv->dmabufs);
+
+ dma_buf_put(member->dma_buf);
+ kfree(member);
+ }
+ mutex_unlock(&prime_fpriv->lock);
+}
+
void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
uint32_t handle)
{
--

syzbot

unread,
Dec 29, 2023, 7:23:06 AM12/29/23
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in drm_prime_del_handles

general protection fault, probably for non-canonical address 0xe000130900000017: 0000 [#1] PREEMPT SMP KASAN
KASAN: maybe wild-memory-access in range [0x0000b848000000b8-0x0000b848000000bf]
CPU: 0 PID: 5576 Comm: syz-executor.0 Not tainted 6.7.0-rc7-syzkaller-00029-g8735c7c84d1b-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
RIP: 0010:__rb_erase_augmented include/linux/rbtree_augmented.h:292 [inline]
RIP: 0010:rb_erase+0xbb/0x1360 lib/rbtree.c:443
Code: 5e 10 4c 89 f5 48 ba 00 00 00 00 00 fc ff df 48 85 db 75 0b e9 e8 04 00 00 48 89 dd 48 89 c3 4c 8d 63 10 4c 89 e0 48 c1 e8 03 <80> 3c 10 00 0f 85 de 0b 00 00 48 8b 43 10 48 85 c0 75 dc 4c 8d 7b
RSP: 0018:ffffc900052b7d20 EFLAGS: 00010216
RAX: 0000170900000017 RBX: 0000b848000000a8 RCX: ffff88802836d408
RDX: dffffc0000000000 RSI: ffff88802836d408 RDI: ffff8880297d2c10
RBP: ffffffff84f35220 R08: 0000000000000000 R09: fffffbfff1e327aa
R10: ffffc900052b7d70 R11: 0000000000000000 R12: 0000b848000000b8
R13: ffff888020c8c5f8 R14: ffff8880297d2c00 R15: 0000000000000001
FS: 0000555556db8480(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6ad1c2fd58 CR3: 0000000017726000 CR4: 0000000000350ef0
Call Trace:
<TASK>
drm_prime_del_handles+0x55/0xb0 drivers/gpu/drm/drm_prime.c:201
drm_file_free.part.0+0x73b/0xba0 drivers/gpu/drm/drm_file.c:290
drm_file_free drivers/gpu/drm/drm_file.c:247 [inline]
drm_close_helper.isra.0+0x180/0x1f0 drivers/gpu/drm/drm_file.c:308
drm_release+0x22a/0x4f0 drivers/gpu/drm/drm_file.c:495
__fput+0x270/0xb70 fs/file_table.c:394
__fput_sync+0x47/0x50 fs/file_table.c:475
__do_sys_close fs/open.c:1587 [inline]
__se_sys_close fs/open.c:1572 [inline]
__x64_sys_close+0x87/0xf0 fs/open.c:1572
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x40/0x110 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f6ad0e7bbda
Code: 48 3d 00 f0 ff ff 77 48 c3 0f 1f 80 00 00 00 00 48 83 ec 18 89 7c 24 0c e8 03 7f 02 00 8b 7c 24 0c 89 c2 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 36 89 d7 89 44 24 0c e8 63 7f 02 00 8b 44 24
RSP: 002b:00007ffc7c5e8f10 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f6ad0e7bbda
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007f6ad0f9d980 R08: 0000001b2e860000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000013a70
R13: ffffffffffffffff R14: 00007f6ad0a00000 R15: 000000000001372f
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__rb_erase_augmented include/linux/rbtree_augmented.h:292 [inline]
RIP: 0010:rb_erase+0xbb/0x1360 lib/rbtree.c:443
Code: 5e 10 4c 89 f5 48 ba 00 00 00 00 00 fc ff df 48 85 db 75 0b e9 e8 04 00 00 48 89 dd 48 89 c3 4c 8d 63 10 4c 89 e0 48 c1 e8 03 <80> 3c 10 00 0f 85 de 0b 00 00 48 8b 43 10 48 85 c0 75 dc 4c 8d 7b
RSP: 0018:ffffc900052b7d20 EFLAGS: 00010216
RAX: 0000170900000017 RBX: 0000b848000000a8 RCX: ffff88802836d408
RDX: dffffc0000000000 RSI: ffff88802836d408 RDI: ffff8880297d2c10
RBP: ffffffff84f35220 R08: 0000000000000000 R09: fffffbfff1e327aa
R10: ffffc900052b7d70 R11: 0000000000000000 R12: 0000b848000000b8
R13: ffff888020c8c5f8 R14: ffff8880297d2c00 R15: 0000000000000001
FS: 0000555556db8480(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f6ad1c2fd58 CR3: 0000000017726000 CR4: 0000000000350ef0
----------------
Code disassembly (best guess):
0: 5e pop %rsi
1: 10 4c 89 f5 adc %cl,-0xb(%rcx,%rcx,4)
5: 48 ba 00 00 00 00 00 movabs $0xdffffc0000000000,%rdx
c: fc ff df
f: 48 85 db test %rbx,%rbx
12: 75 0b jne 0x1f
14: e9 e8 04 00 00 jmp 0x501
19: 48 89 dd mov %rbx,%rbp
1c: 48 89 c3 mov %rax,%rbx
1f: 4c 8d 63 10 lea 0x10(%rbx),%r12
23: 4c 89 e0 mov %r12,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 80 3c 10 00 cmpb $0x0,(%rax,%rdx,1) <-- trapping instruction
2e: 0f 85 de 0b 00 00 jne 0xc12
34: 48 8b 43 10 mov 0x10(%rbx),%rax
38: 48 85 c0 test %rax,%rax
3b: 75 dc jne 0x19
3d: 4c rex.WR
3e: 8d .byte 0x8d
3f: 7b .byte 0x7b


Tested on:

commit: 8735c7c8 Merge tag '6.7rc7-smb3-srv-fix' of git://git...
console output: https://syzkaller.appspot.com/x/log.txt?x=133148d9e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=c7bcb8f62f1e2c3e
dashboard link: https://syzkaller.appspot.com/bug?extid=59dcc2e7283a6f5f5ba1
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1041c931e80000

Hillf Danton

unread,
Dec 29, 2023, 8:04:08 PM12/29/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Wed, 27 Dec 2023 12:51:18 -0800
> HEAD commit: 5254c0cbc92d Merge tag 'block-6.7-2023-12-22' of git://git..
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=155d5fd6e80000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -287,6 +287,7 @@ void drm_file_free(struct drm_file *file
if (dev->driver->postclose)
dev->driver->postclose(dev, file);

+ drm_prime_del_handles(&file->prime);
drm_prime_destroy_file_private(&file->prime);

WARN_ON(!list_empty(&file->event_list));
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -76,6 +76,7 @@ void drm_prime_init_file_private(struct
void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv);
void drm_prime_remove_buf_handle(struct drm_prime_file_private *prime_fpriv,
uint32_t handle);
+void drm_prime_del_handles(struct drm_prime_file_private *prime_fpriv);

/* drm_drv.c */
struct drm_minor *drm_minor_acquire(unsigned int minor_id);
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -106,6 +106,8 @@ static int drm_prime_add_buf_handle(stru
get_dma_buf(dma_buf);
member->dma_buf = dma_buf;
member->handle = handle;
+ RB_CLEAR_NODE(&member->dmabuf_rb);
+ RB_CLEAR_NODE(&member->handle_rb);

rb = NULL;
p = &prime_fpriv->dmabufs.rb_node;
@@ -185,6 +187,27 @@ static int drm_prime_lookup_buf_handle(s

syzbot

unread,
Dec 29, 2023, 8:22:06 PM12/29/23
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
general protection fault in drm_prime_del_handles

general protection fault, probably for non-canonical address 0xe000130900000017: 0000 [#1] PREEMPT SMP KASAN
KASAN: maybe wild-memory-access in range [0x0000b848000000b8-0x0000b848000000bf]
CPU: 1 PID: 5576 Comm: syz-executor.0 Not tainted 6.7.0-rc7-syzkaller-00041-gf016f7547aee-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
RIP: 0010:__rb_erase_augmented include/linux/rbtree_augmented.h:292 [inline]
RIP: 0010:rb_erase+0xbb/0x1360 lib/rbtree.c:443
Code: 5e 10 4c 89 f5 48 ba 00 00 00 00 00 fc ff df 48 85 db 75 0b e9 e8 04 00 00 48 89 dd 48 89 c3 4c 8d 63 10 4c 89 e0 48 c1 e8 03 <80> 3c 10 00 0f 85 de 0b 00 00 48 8b 43 10 48 85 c0 75 dc 4c 8d 7b
RSP: 0018:ffffc9000526fd20 EFLAGS: 00010216
RAX: 0000170900000017 RBX: 0000b848000000a8 RCX: ffff88806486d408
RDX: dffffc0000000000 RSI: ffff88806486d408 RDI: ffff88802919b810
RBP: ffffffff84f351e0 R08: 0000000000000000 R09: fffffbfff1e327ba
R10: ffffc9000526fd70 R11: 0000000000000000 R12: 0000b848000000b8
R13: ffff88802808eff8 R14: ffff88802919b800 R15: 0000000000000001
FS: 0000555556b94480(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f01823cd5e8 CR3: 0000000023343000 CR4: 0000000000350ef0
Call Trace:
<TASK>
drm_prime_del_handles+0x55/0xb0 drivers/gpu/drm/drm_prime.c:203
drm_file_free.part.0+0x73b/0xba0 drivers/gpu/drm/drm_file.c:290
drm_file_free drivers/gpu/drm/drm_file.c:247 [inline]
drm_close_helper.isra.0+0x180/0x1f0 drivers/gpu/drm/drm_file.c:308
drm_release+0x22a/0x4f0 drivers/gpu/drm/drm_file.c:495
__fput+0x270/0xb70 fs/file_table.c:394
__fput_sync+0x47/0x50 fs/file_table.c:475
__do_sys_close fs/open.c:1587 [inline]
__se_sys_close fs/open.c:1572 [inline]
__x64_sys_close+0x87/0xf0 fs/open.c:1572
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x40/0x110 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x7f32ec87bbda
Code: 48 3d 00 f0 ff ff 77 48 c3 0f 1f 80 00 00 00 00 48 83 ec 18 89 7c 24 0c e8 03 7f 02 00 8b 7c 24 0c 89 c2 b8 03 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 36 89 d7 89 44 24 0c e8 63 7f 02 00 8b 44 24
RSP: 002b:00007ffe0da98170 EFLAGS: 00000293 ORIG_RAX: 0000000000000003
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f32ec87bbda
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007f32ec99d980 R08: 0000001b2ea60000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000014e33
R13: ffffffffffffffff R14: 00007f32ec400000 R15: 0000000000014af2
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__rb_erase_augmented include/linux/rbtree_augmented.h:292 [inline]
RIP: 0010:rb_erase+0xbb/0x1360 lib/rbtree.c:443
Code: 5e 10 4c 89 f5 48 ba 00 00 00 00 00 fc ff df 48 85 db 75 0b e9 e8 04 00 00 48 89 dd 48 89 c3 4c 8d 63 10 4c 89 e0 48 c1 e8 03 <80> 3c 10 00 0f 85 de 0b 00 00 48 8b 43 10 48 85 c0 75 dc 4c 8d 7b
RSP: 0018:ffffc9000526fd20 EFLAGS: 00010216
RAX: 0000170900000017 RBX: 0000b848000000a8 RCX: ffff88806486d408
RDX: dffffc0000000000 RSI: ffff88806486d408 RDI: ffff88802919b810
RBP: ffffffff84f351e0 R08: 0000000000000000 R09: fffffbfff1e327ba
R10: ffffc9000526fd70 R11: 0000000000000000 R12: 0000b848000000b8
R13: ffff88802808eff8 R14: ffff88802919b800 R15: 0000000000000001
FS: 0000555556b94480(0000) GS:ffff8880b9900000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f01823cd5e8 CR3: 0000000023343000 CR4: 0000000000350ef0
----------------
Code disassembly (best guess):
0: 5e pop %rsi
1: 10 4c 89 f5 adc %cl,-0xb(%rcx,%rcx,4)
5: 48 ba 00 00 00 00 00 movabs $0xdffffc0000000000,%rdx
c: fc ff df
f: 48 85 db test %rbx,%rbx
12: 75 0b jne 0x1f
14: e9 e8 04 00 00 jmp 0x501
19: 48 89 dd mov %rbx,%rbp
1c: 48 89 c3 mov %rax,%rbx
1f: 4c 8d 63 10 lea 0x10(%rbx),%r12
23: 4c 89 e0 mov %r12,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 80 3c 10 00 cmpb $0x0,(%rax,%rdx,1) <-- trapping instruction
2e: 0f 85 de 0b 00 00 jne 0xc12
34: 48 8b 43 10 mov 0x10(%rbx),%rax
38: 48 85 c0 test %rax,%rax
3b: 75 dc jne 0x19
3d: 4c rex.WR
3e: 8d .byte 0x8d
3f: 7b .byte 0x7b


Tested on:

commit: f016f754 Merge tag 'gpio-fixes-for-v6.7-rc8' of git://..
console output: https://syzkaller.appspot.com/x/log.txt?x=14b493a1e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=c7bcb8f62f1e2c3e
dashboard link: https://syzkaller.appspot.com/bug?extid=59dcc2e7283a6f5f5ba1
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=1510031de80000

Hillf Danton

unread,
Dec 29, 2023, 8:59:41 PM12/29/23
to syzbot, linux-...@vger.kernel.org, syzkall...@googlegroups.com
On Wed, 27 Dec 2023 12:51:18 -0800
> HEAD commit: 5254c0cbc92d Merge tag 'block-6.7-2023-12-22' of git://git..
> git tree: upstream
+ member = rb_entry(rb, struct drm_prime_member, dmabuf_rb);

syzbot

unread,
Dec 29, 2023, 9:47:10 PM12/29/23
to hda...@sina.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+59dcc2...@syzkaller.appspotmail.com

Tested on:

commit: f016f754 Merge tag 'gpio-fixes-for-v6.7-rc8' of git://..
git tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=1413189ae80000
kernel config: https://syzkaller.appspot.com/x/.config?x=c7bcb8f62f1e2c3e
dashboard link: https://syzkaller.appspot.com/bug?extid=59dcc2e7283a6f5f5ba1
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=14912036e80000

Note: testing is done by a robot and is best-effort only.

Christian König

unread,
Jan 3, 2024, 10:12:53 AMJan 3
to Qi Zheng, syzbot, air...@gmail.com, akinob...@gmail.com, ak...@linux-foundation.org, dan...@ffwll.ch, dri-...@lists.freedesktop.org, j...@nvidia.com, linaro...@lists.linaro.org, linux-...@vger.kernel.org, linux...@vger.kernel.org, maarten....@linux.intel.com, mri...@kernel.org, sumit....@linaro.org, syzkall...@googlegroups.com, tzimm...@suse.de
Am 28.12.23 um 03:57 schrieb Qi Zheng:
Making an educated guess I strongly think syzbot incorrectly bisected this.

What basically happens is that a DRM test case crashes because a file
private data structure is destroyed before all DMA-bufs referring to it
are destroyed.

Looks like a random race condition in a test case to me. Question is
really what test is syzbot running and who is maintaining this test case?

Regards,
Christian.
Reply all
Reply to author
Forward
0 new messages