All of lore.kernel.org
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH] drm/bufs: Prevent kernel-infoleak in copy_one_buf()
@ 2020-07-28  1:43 ` Peilin Ye
  0 siblings, 0 replies; 18+ messages in thread
From: Peilin Ye @ 2020-07-28  1:43 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
  Cc: Arnd Bergmann, David Airlie, linux-kernel, dri-devel,
	Daniel Vetter, linux-kernel-mentees, Peilin Ye, Dan Carpenter

copy_one_buf() is copying uninitialized stack memory to userspace due to
the compiler not initializing holes in statically allocated structures.
Fix it by initializing `v` with memset().

Cc: stable@vger.kernel.org
Fixes: 5c7640ab6258 ("switch compat_drm_infobufs() to drm_ioctl_kernel()")
Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
---
 drivers/gpu/drm/drm_bufs.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index a0735fbc144b..f99cd4a3f951 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1349,10 +1349,14 @@ static int copy_one_buf(void *data, int count, struct drm_buf_entry *from)
 {
 	struct drm_buf_info *request = data;
 	struct drm_buf_desc __user *to = &request->list[count];
-	struct drm_buf_desc v = {.count = from->buf_count,
-				 .size = from->buf_size,
-				 .low_mark = from->low_mark,
-				 .high_mark = from->high_mark};
+	struct drm_buf_desc v;
+
+	memset(&v, 0, sizeof(v));
+
+	v.count = from->buf_count;
+	v.size = from->buf_size;
+	v.low_mark = from->low_mark;
+	v.high_mark = from->high_mark;
 
 	if (copy_to_user(to, &v, offsetof(struct drm_buf_desc, flags)))
 		return -EFAULT;
-- 
2.25.1

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

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

end of thread, other threads:[~2020-07-28 19:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-28  1:43 [Linux-kernel-mentees] [PATCH] drm/bufs: Prevent kernel-infoleak in copy_one_buf() Peilin Ye
2020-07-28  1:43 ` Peilin Ye
2020-07-28  1:43 ` Peilin Ye
2020-07-28  8:11 ` Arnd Bergmann
2020-07-28  8:11   ` Arnd Bergmann
2020-07-28  8:11   ` Arnd Bergmann
2020-07-28 11:15   ` Peilin Ye
2020-07-28 11:15     ` Peilin Ye
2020-07-28 11:15     ` Peilin Ye
2020-07-28 11:52 ` [Linux-kernel-mentees] [PATCH v2] " Peilin Ye
2020-07-28 11:52   ` Peilin Ye
2020-07-28 11:52   ` Peilin Ye
2020-07-28 12:35   ` David Laight
2020-07-28 12:35     ` David Laight
2020-07-28 12:35     ` David Laight
2020-07-28 12:50     ` Peilin Ye
2020-07-28 12:50       ` Peilin Ye
2020-07-28 12:50       ` Peilin Ye

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.