Skip to content

Commit 4949e32

Browse files
name2965gregkh
authored andcommitted
drm/exynos: vidi: fix to avoid directly dereferencing user pointer
commit d4c98c0 upstream. In vidi_connection_ioctl(), vidi->edid(user pointer) is directly dereferenced in the kernel. This allows arbitrary kernel memory access from the user space, so instead of directly accessing the user pointer in the kernel, we should modify it to copy edid to kernel memory using copy_from_user() and use it. Cc: <stable@vger.kernel.org> Signed-off-by: Jeongjun Park <aha310510@gmail.com> Signed-off-by: Inki Dae <inki.dae@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b5fc86d commit 4949e32

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

drivers/gpu/drm/exynos/exynos_drm_vidi.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,13 +262,27 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
262262

263263
if (vidi->connection) {
264264
const struct drm_edid *drm_edid;
265-
const struct edid *raw_edid;
265+
const void __user *edid_userptr = u64_to_user_ptr(vidi->edid);
266+
void *edid_buf;
267+
struct edid hdr;
266268
size_t size;
267269

268-
raw_edid = (const struct edid *)(unsigned long)vidi->edid;
269-
size = (raw_edid->extensions + 1) * EDID_LENGTH;
270+
if (copy_from_user(&hdr, edid_userptr, sizeof(hdr)))
271+
return -EFAULT;
270272

271-
drm_edid = drm_edid_alloc(raw_edid, size);
273+
size = (hdr.extensions + 1) * EDID_LENGTH;
274+
275+
edid_buf = kmalloc(size, GFP_KERNEL);
276+
if (!edid_buf)
277+
return -ENOMEM;
278+
279+
if (copy_from_user(edid_buf, edid_userptr, size)) {
280+
kfree(edid_buf);
281+
return -EFAULT;
282+
}
283+
284+
drm_edid = drm_edid_alloc(edid_buf, size);
285+
kfree(edid_buf);
272286
if (!drm_edid)
273287
return -ENOMEM;
274288

0 commit comments

Comments
 (0)