All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm ioctl: Access user-land memory through safe functions.
@ 2015-12-01 18:11 Scotty
  2015-12-08 18:26 ` Scotty Bauer
  0 siblings, 1 reply; 7+ messages in thread
From: Scotty @ 2015-12-01 18:11 UTC (permalink / raw)
  To: agk, snitzer; +Cc: linux-kernel, dm-devel

[-- Attachment #1: Type: text/plain, Size: 0 bytes --]



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-dm-ioctl-Access-user-land-memory-through-safe-functi.patch --]
[-- Type: text/x-patch; name="0001-dm-ioctl-Access-user-land-memory-through-safe-functi.patch", Size: 1533 bytes --]

From b26adf880eba03ac6f2b1dd87426bb96fd2a0282 Mon Sep 17 00:00:00 2001
From: Scotty Bauer <sbauer@eng.utah.edu>
Date: Tue, 1 Dec 2015 10:52:46 -0700
Subject: [PATCH] dm ioctl: Access user-land memory through safe functions.

This patch fixes a user-land dereference. Now we use
the safe copy_from_user to access the memory.

Signed-off-by: Scotty Bauer <sbauer@eng.utah.edu>
---
 drivers/md/dm-ioctl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 80a4395..39a9d1a 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1642,9 +1642,13 @@ static ioctl_fn lookup_ioctl(unsigned int cmd, int *ioctl_flags)
 static int check_version(unsigned int cmd, struct dm_ioctl __user *user)
 {
 	uint32_t version[3];
+	uint32_t __user *version_ptr;
 	int r = 0;
 
-	if (copy_from_user(version, user->version, sizeof(version)))
+	if (copy_from_user(&version_ptr, &user->version, sizeof(version_ptr)))
+		return -EFAULT;
+
+	if (copy_from_user(version, version_ptr, sizeof(version)))
 		return -EFAULT;
 
 	if ((DM_VERSION_MAJOR != version[0]) ||
@@ -1663,7 +1667,7 @@ static int check_version(unsigned int cmd, struct dm_ioctl __user *user)
 	version[0] = DM_VERSION_MAJOR;
 	version[1] = DM_VERSION_MINOR;
 	version[2] = DM_VERSION_PATCHLEVEL;
-	if (copy_to_user(user->version, version, sizeof(version)))
+	if (copy_to_user(version_ptr, version, sizeof(version)))
 		return -EFAULT;
 
 	return r;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-01-07  2:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01 18:11 [PATCH] dm ioctl: Access user-land memory through safe functions Scotty
2015-12-08 18:26 ` Scotty Bauer
2016-01-05 20:16   ` Mike Snitzer
2016-01-05 21:13     ` Mike Snitzer
2016-01-07  1:22       ` Scotty Bauer
2016-01-07  1:22         ` Scotty Bauer
2016-01-07  2:07         ` Mike Snitzer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.