From: Guangshuo Li <lgs201920130244@gmail.com>
To: Inki Dae <inki.dae@samsung.com>,
Seung-Woo Kim <sw0312.kim@samsung.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Krzysztof Kozlowski <krzk@kernel.org>,
Peter Griffin <peter.griffin@linaro.org>,
Alim Akhtar <alim.akhtar@samsung.com>,
Jeongjun Park <aha310510@gmail.com>,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Guangshuo Li <lgs201920130244@gmail.com>
Subject: [PATCH] drm/exynos: vidi: fix EDID leak on concurrent connection ioctl
Date: Wed, 8 Jul 2026 11:28:47 +0800 [thread overview]
Message-ID: <20260708032847.712897-1-lgs201920130244@gmail.com> (raw)
The change referenced by the Fixes tag added ctx->lock protection around
struct vidi_context members related to EDID allocation and freeing, but
vidi_connection_ioctl() still checks ctx->connected separately from the
state update.
Two authenticated clients can therefore issue concurrent connect
requests. Both can observe ctx->connected as disconnected before either
one updates it, then both allocate a drm_edid and assign ctx->raw_edid.
The second assignment overwrites the first drm_edid pointer, leaking the
first allocation.
Keep the connection-state check and the ctx->raw_edid/ctx->connected
updates in the same critical section. If a concurrent request has already
changed the connection state by the time a newly allocated EDID is ready,
drop the new EDID before returning.
Fixes: 52b330799e2d ("drm/exynos: vidi: use ctx->lock to protect struct vidi_context member variables related to memory alloc/free")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
drivers/gpu/drm/exynos/exynos_drm_vidi.c | 33 ++++++++++++++----------
1 file changed, 20 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 67bbf9b8bc0e..bc0af9e6bc81 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -252,15 +252,6 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
return -EINVAL;
}
- mutex_lock(&ctx->lock);
- if (ctx->connected == vidi->connection) {
- mutex_unlock(&ctx->lock);
- DRM_DEV_DEBUG_KMS(ctx->dev,
- "same connection request.\n");
- return -EINVAL;
- }
- mutex_unlock(&ctx->lock);
-
if (vidi->connection) {
const struct drm_edid *drm_edid;
const void __user *edid_userptr = u64_to_user_ptr(vidi->edid);
@@ -293,21 +284,37 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
"edid data is invalid.\n");
return -EINVAL;
}
+
mutex_lock(&ctx->lock);
+ if (ctx->connected == vidi->connection) {
+ mutex_unlock(&ctx->lock);
+ drm_edid_free(drm_edid);
+ DRM_DEV_DEBUG_KMS(ctx->dev,
+ "same connection request.\n");
+ return -EINVAL;
+ }
+
+ drm_edid_free(ctx->raw_edid);
+
ctx->raw_edid = drm_edid;
+ ctx->connected = vidi->connection;
mutex_unlock(&ctx->lock);
} else {
/* with connection = 0, free raw_edid */
mutex_lock(&ctx->lock);
+ if (ctx->connected == vidi->connection) {
+ mutex_unlock(&ctx->lock);
+ DRM_DEV_DEBUG_KMS(ctx->dev,
+ "same connection request.\n");
+ return -EINVAL;
+ }
+
drm_edid_free(ctx->raw_edid);
ctx->raw_edid = NULL;
+ ctx->connected = vidi->connection;
mutex_unlock(&ctx->lock);
}
- mutex_lock(&ctx->lock);
- ctx->connected = vidi->connection;
- mutex_unlock(&ctx->lock);
-
drm_helper_hpd_irq_event(ctx->drm_dev);
return 0;
--
2.43.0
reply other threads:[~2026-07-08 3:29 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260708032847.712897-1-lgs201920130244@gmail.com \
--to=lgs201920130244@gmail.com \
--cc=aha310510@gmail.com \
--cc=airlied@gmail.com \
--cc=alim.akhtar@samsung.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=inki.dae@samsung.com \
--cc=krzk@kernel.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=peter.griffin@linaro.org \
--cc=simona@ffwll.ch \
--cc=sw0312.kim@samsung.com \
/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