[dm-devel] [PATCH v2] dm ioctl: prevent stack leak in dm ioctl call

Adrian Salido salidoa at google.com
Thu Apr 27 17:32:55 UTC 2017


When calling a dm ioctl that doesn't process any data
(IOCTL_FLAGS_NO_PARAMS), the contents of the data field in
struct dm_ioctl are left initialized. Current code is
incorrectly extending the size of data copied back to user,
causing the contents of kernel stack to be leaked to user.
Fix by only copying contents before data and the functions
processing ioctl to override.

Cc: stable at vger.kernel.org
Signed-off-by: Adrian Salido <salidoa at google.com>
---
 drivers/md/dm-ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 4da6fc6b1ffd..3d040f52539c 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1848,7 +1848,7 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user)
 	if (r)
 		goto out;
 
-	param->data_size = sizeof(*param);
+	param->data_size = offsetof(struct dm_ioctl, data);
 	r = fn(param, input_param_size);
 
 	if (unlikely(param->flags & DM_BUFFER_FULL_FLAG) &&
-- 
2.13.0.rc0.306.g87b477812d-goog




More information about the dm-devel mailing list