Skip to content

Commit 235d702

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 a540f76 commit 235d702

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
@@ -263,13 +263,27 @@ int vidi_connection_ioctl(struct drm_device *drm_dev, void *data,
263263

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

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

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

0 commit comments

Comments
 (0)