From: Edward Adam Davis <eadavis@qq.com>
To: syzbot+0f999d26a4fd79c3a23b@syzkaller.appspotmail.com
Cc: airlied@gmail.com, daniel@ffwll.ch,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
syzkaller-bugs@googlegroups.com, tzimmermann@suse.de
Subject: [PATCH v2] drm/atomic-helpers: fix uaf in drm_atomic_helper_wait_for_vblanks
Date: Thu, 15 Feb 2024 23:12:29 +0800 [thread overview]
Message-ID: <tencent_C325B38DA11227DDA7DDBE192E4FE88DEC07@qq.com> (raw)
In-Reply-To: <000000000000ec4c32061143ec95@google.com>
To briefly summarize the issues reported by syzbot, there are two task call stacks
as follows:
Task A Task B
------------------------------------ ----------------------------------
drm_atomic_commit
drm_atomic_helper_commit
commit_work
commit_tail
drm_atomic_helper_commit_tail commit_tail
drm_atomic_helper_commit_tail
drm_client_modeset_commit_atomic
drm_atomic_state_default_clear
drm_atomic_helper_wait_for_vblanks
When two prerequisites are met simultaneously, the current issue will be triggered:
1. There is an overlap in the memory range occupied by the crtcs member set contained
in the instance state of "struct drm_atomic_state" created by Task A and Task B
2. The context of drm_atomic_helper_commit_tail() has no lock protection, resulting
in the instance state->crtcs sub item being released by other task
The solution is to add a lock in drm_atomic_helper_commit_tail() to ensure that
there is no other task interference when accessing the instance state.
Reported-and-tested-by: syzbot+0f999d26a4fd79c3a23b@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
drivers/gpu/drm/drm_atomic_helper.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 39ef0a6addeb..b16ff9020097 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1743,7 +1743,9 @@ EXPORT_SYMBOL(drm_atomic_helper_wait_for_flip_done);
void drm_atomic_helper_commit_tail(struct drm_atomic_state *old_state)
{
struct drm_device *dev = old_state->dev;
+ static DEFINE_MUTEX(lock);
+ mutex_lock(&lock);
drm_atomic_helper_commit_modeset_disables(dev, old_state);
drm_atomic_helper_commit_planes(dev, old_state, 0);
@@ -1757,6 +1759,7 @@ void drm_atomic_helper_commit_tail(struct drm_atomic_state *old_state)
drm_atomic_helper_wait_for_vblanks(dev, old_state);
drm_atomic_helper_cleanup_planes(dev, old_state);
+ mutex_unlock(&lock);
}
EXPORT_SYMBOL(drm_atomic_helper_commit_tail);
--
2.43.0
prev parent reply other threads:[~2024-02-15 15:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 10:50 [syzbot] [dri?] KASAN: slab-use-after-free Read in drm_atomic_helper_wait_for_vblanks (2) syzbot
2024-02-13 14:08 ` syzbot
2024-02-14 1:32 ` Hillf Danton
2024-02-14 2:01 ` syzbot
2024-02-14 3:39 ` Hillf Danton
2024-02-14 3:55 ` syzbot
2024-02-14 7:01 ` Hillf Danton
2024-02-14 7:26 ` syzbot
2024-02-14 11:18 ` Hillf Danton
2024-02-14 11:55 ` syzbot
2024-02-15 10:15 ` Edward Adam Davis
2024-02-15 10:39 ` syzbot
2024-02-15 13:02 ` [PATCH] drm/atomic-helpers: fix uaf in drm_atomic_helper_wait_for_vblanks Edward Adam Davis
2024-02-15 15:12 ` Edward Adam Davis [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tencent_C325B38DA11227DDA7DDBE192E4FE88DEC07@qq.com \
--to=eadavis@qq.com \
--cc=airlied@gmail.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=syzbot+0f999d26a4fd79c3a23b@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®