linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-input@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] Input: potential info leak in input_event_to_user()
Date: Fri, 23 Sep 2011 00:29:57 -0700	[thread overview]
Message-ID: <20110923072957.GA613@core.coreip.homeip.net> (raw)
In-Reply-To: <20110923062207.GF4387@elgon.mountain>

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 <dan.carpenter@oracle.com>
> 
> 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

  reply	other threads:[~2011-09-23  7:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-23  6:22 [patch] Input: potential info leak in input_event_to_user() Dan Carpenter
2011-09-23  7:29 ` Dmitry Torokhov [this message]
2011-09-23  7:31 ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110923072957.GA613@core.coreip.homeip.net \
    --to=dmitry.torokhov@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-input@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).