Skip to contentSkip to conversation

Input: potential info leak in input_event_to_user()

PATCH In review Dan Carpenter 2 participants 3 messages Sep 23, 2011

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

PATCH 1/1 Input: potential info leak in input_event_to_user()

Smatch has a new check for Rosenberg type information leaks where structs are copied to the user with uninitialized stack data in them.

The issue here is that struct input_event_compat has a hole in it.

struct input_event_compat {
        struct compat_timeval {
        } time;                             /*     0     0 */

        /* XXX 8 bytes hole, try to pack */

        short unsigned int         type;    /*     8     2 */
drivers/input/input-compat.c +2 -0
index e46a867..007850a 100644
@@ -44,6 +44,8 @@ int input_event_to_user(char __user *buffer,
 	if (INPUT_COMPAT_TEST) {
 		struct input_event_compat compat_event;
 
+		memset(&compat_event, 0, sizeof(compat_event));
+
 		compat_event.time.tv_sec = event->time.tv_sec;
 		compat_event.time.tv_usec = event->time.tv_usec;
 		compat_event.type = event->type;
maintainer
#1 lore raw
Quoted 5 lines · Dan Carpenter

Smatch has a new check for Rosenberg type information leaks where structs are copied to the user with uninitialized stack data in them.

The issue here is that struct input_event_compat has a hole in it.

Quoted 7 lines
struct input_event_compat {
        struct compat_timeval {
        } time;                             /*     0     0 */

        /* XXX 8 bytes hole, try to pack */

        short unsigned int         type;    /*     8     2 */

Hm, are you sure? 8-bytes is way too much. I'd expect type to be aligned on 2-byte boundary, at least on x86_64...

Quoted 17 lines
drivers/input/input-compat.c +2 -0
index e46a867..007850a 100644
@@ -44,6 +44,8 @@ int input_event_to_user(char __user *buffer,
 	if (INPUT_COMPAT_TEST) {
 		struct input_event_compat compat_event;
 
+		memset(&compat_event, 0, sizeof(compat_event));
+
 		compat_event.time.tv_sec = event->time.tv_sec;
 		compat_event.time.tv_usec = event->time.tv_usec;
 		compat_event.type = event->type;
Signature · 1 line
Dmitry