All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wolfram Sang <wsa@the-dreams.de>
To: Vlad Tsyrklevich <vlad@tsyrklevich.net>
Cc: linux-i2c@vger.kernel.org
Subject: Re: [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure
Date: Tue, 25 Oct 2016 11:45:13 +0200	[thread overview]
Message-ID: <20161025094512.GF1597@katana> (raw)
In-Reply-To: <1476190348-37589-1-git-send-email-vlad@tsyrklevich.net>

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

On Tue, Oct 11, 2016 at 02:52:28PM +0200, Vlad Tsyrklevich wrote:
> i2c_smbus_xfer() does not always fill an entire block, allowing
> kernel stack memory disclosure through the temp variable. Clear
> it before it's read to.
> 
> Signed-off-by: Vlad Tsyrklevich <vlad@tsyrklevich.net>

Yes, thanks. But what about clearing 'temp' when it is declared? This
would be rock-solid for all future code paths.

> 
> ---
>  drivers/i2c/i2c-dev.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
> index 66f323f..62cb111 100644
> --- a/drivers/i2c/i2c-dev.c
> +++ b/drivers/i2c/i2c-dev.c
> @@ -393,6 +393,8 @@ static noinline int i2cdev_ioctl_smbus(struct i2c_client *client,
>  	    (data_arg.read_write == I2C_SMBUS_WRITE)) {
>  		if (copy_from_user(&temp, data_arg.data, datasize))
>  			return -EFAULT;
> +	} else {
> +		memset(&temp, 0, datasize);
>  	}
>  	if (data_arg.size == I2C_SMBUS_I2C_BLOCK_BROKEN) {
>  		/* Convert old I2C block commands to the new
> -- 
> 2.7.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

  reply	other threads:[~2016-10-25  9:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-11 12:52 [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure Vlad Tsyrklevich
2016-10-25  9:45 ` Wolfram Sang [this message]
2017-01-09 10:19   ` Vlad Tsyrklevich
2017-01-09 14:48     ` Wolfram Sang
  -- strict thread matches above, loose matches on Subject: below --
2017-01-09 15:53 Vlad Tsyrklevich
2017-01-12 18:36 ` Wolfram Sang

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=20161025094512.GF1597@katana \
    --to=wsa@the-dreams.de \
    --cc=linux-i2c@vger.kernel.org \
    --cc=vlad@tsyrklevich.net \
    /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 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.