Skip to contentSkip to conversation

Patch "drm: Prevent overwriting from userspace underallocating core ioctl" has been added to staging queue

3.5.y.z extended stable Luis Henriques 1 participant 1 message Nov 6, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This is a note to let you know that I have just added a patch titled

drm: Prevent overwriting from userspace underallocating core ioctl

to the linux-3.5.y-queue branch of the 3.5.y.z extended stable tree which can be found at:

http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.5.y-queue

If you, or anyone else, feels it should not be added to this tree, please reply to this email.

For more information about the 3.5.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Luis

------

From c0614f3697a7cbaa3ef53b8ef64866797e5112c0 Mon Sep 17 00:00:00 2001
From: Chris Wilson <[email protected]>
Date: Wed, 16 Oct 2013 11:22:44 +0100
Subject: drm: Prevent overwriting from userspace underallocating core ioctl
structs
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

commit b062672e305ce071f21eb9e18b102c2a430e0999 upstream.

Apply the protections from

commit 1b2f1489633888d4a06028315dc19d65768a1c05

Author: Dave Airlie <[email protected]>
Date:   Sat Aug 14 20:20:34 2010 +1000

drm: block userspace under allocating buffer and having drivers overwrite it (v2)

to the core ioctl structs as well, for we found one instance where there is a 32-/64-bit size mismatch and were guilty of writing beyond the end of the user's buffer.

Cc Dave Airlie <[email protected]>
[ luis: backported to 3.5: adjusted context ]
---
 drivers/gpu/drm/drm_drv.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_drv.c +8 -1
index 8a9d079..df54da9 100644
@@ -422,9 +422,16 @@ long drm_ioctl(struct file *filp,
 			asize = drv_size;
 	}
 	else if ((nr >= DRM_COMMAND_END) || (nr < DRM_COMMAND_BASE)) {
+		u32 drv_size;
+
 		ioctl = &drm_ioctls[nr];
-		cmd = ioctl->cmd;
+
+		drv_size = _IOC_SIZE(ioctl->cmd);
 		usize = asize = _IOC_SIZE(cmd);
+		if (drv_size > asize)
+			asize = drv_size;
+
+		cmd = ioctl->cmd;
 	} else
 		goto err_i1;
 

--
1.8.3.2

Signature · 3 lines
kernel-team mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/kernel-team