# \[patch\] Input: potential info leak in input\_event\_to\_user()

- Subsystems: INPUT (KEYBOARD, MOUSE, JOYSTICK, TOUCHSCREEN) DRIVERS, THE REST
- Maintainers: Dmitry Torokhov, Linus Torvalds
- List: linux-input
- 3 messages, 2 authors
- Page: https://ratatoskr.run/linux-input/2011/09/8917808/t

## \[patch\] Input: potential info leak in input\_event\_to\_user()

- From: Dan Carpenter \<hidden\>
- Date: 2011-09-23 06:22:16 
- Message: https://ratatoskr.run/linux-input/2011/09/8917808.md

```text
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 */


Signed-off-by: Dan Carpenter <redacted>

diff --git a/drivers/input/input-compat.c b/drivers/input/input-compat.c
index e46a867..007850a 100644
--- a/drivers/input/input-compat.c
+++ b/drivers/input/input-compat.c
@@ -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;
```

## Re: \[patch\] Input: potential info leak in input\_event\_to\_user()

- From: Dmitry Torokhov \<dmitry.torokhov@gmail.com\>
- Date: 2011-09-23 07:30:04 
- Message: https://ratatoskr.run/linux-input/2011/09/8917811.md

```text
On Fri, Sep 23, 2011 at 09:22:07AM +0300, Dan Carpenter wrote:
> 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 */

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...

> 
> 
> Signed-off-by: Dan Carpenter <redacted>
> 
> diff --git a/drivers/input/input-compat.c b/drivers/input/input-compat.c
> index e46a867..007850a 100644
> --- a/drivers/input/input-compat.c
> +++ b/drivers/input/input-compat.c
> @@ -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;

-- 
Dmitry
```

## Re: \[patch\] Input: potential info leak in input\_event\_to\_user()

- From: Dan Carpenter \<hidden\>
- Date: 2011-09-23 07:33:51 
- Message: https://ratatoskr.run/linux-input/2011/09/8917813.md

```text
Sorry for the noise.  This is wrong.

regards,
dan carpenter
```
