linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] uhid: Pad short UHID_CREATE writes from compat tasks
@ 2013-11-26  7:02 Ben Hutchings
  2013-11-26 12:45 ` David Herrmann
  2013-11-26 12:58 ` [PATCH v2] HID: uhid: fix leak for 64/32 UHID_CREATE David Herrmann
  0 siblings, 2 replies; 5+ messages in thread
From: Ben Hutchings @ 2013-11-26  7:02 UTC (permalink / raw)
  To: David Herrmann; +Cc: linux-input

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

Short event writes are normally padded with zeroes, but the compat
fixup for UHID_CREATE didn't ensure this.  This appears to allow an
information leak.

Compile-tested only.

Fixes: befde0226a59 ('HID: uhid: make creating devices work on 64/32 systems')
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Cc: stable@vger.kernel.org
---
I have no familiarity with uhid so I haven't written a test for this.
It looks like it would be possible to write a UHID_CREATE event that
only covers fields up to rd_size, and the following data on the heap
would be copied to the HID device metadata and be readable that way.

Ben.

 drivers/hid/uhid.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 5bf2fb7..579a7115 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -298,6 +298,9 @@ static int uhid_event_from_user(const char __user *buffer, size_t len,
 				kfree(compat);
 				return -EFAULT;
 			}
+			if (len < sizeof(*compat))
+				memset((char *)buffer + len, 0,
+				       sizeof(*compat) - len);
 
 			/* Shuffle the data over to proper structure */
 			event->type = type;

-- 
Ben Hutchings
Usenet is essentially a HUGE group of people passing notes in class.
                      - Rachel Kadel, `A Quick Guide to Newsgroup Etiquette'

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

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

end of thread, other threads:[~2013-11-27  9:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-26  7:02 [PATCH] uhid: Pad short UHID_CREATE writes from compat tasks Ben Hutchings
2013-11-26 12:45 ` David Herrmann
2013-11-26 12:58 ` [PATCH v2] HID: uhid: fix leak for 64/32 UHID_CREATE David Herrmann
2013-11-26 14:29   ` Ben Hutchings
2013-11-27  9:54     ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).