All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure
@ 2016-10-11 12:52 Vlad Tsyrklevich
  2016-10-25  9:45 ` Wolfram Sang
  0 siblings, 1 reply; 6+ messages in thread
From: Vlad Tsyrklevich @ 2016-10-11 12:52 UTC (permalink / raw)
  To: linux-i2c; +Cc: wsa, Vlad Tsyrklevich

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>

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

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

* Re: [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure
  2016-10-11 12:52 [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure Vlad Tsyrklevich
@ 2016-10-25  9:45 ` Wolfram Sang
  2017-01-09 10:19   ` Vlad Tsyrklevich
  0 siblings, 1 reply; 6+ messages in thread
From: Wolfram Sang @ 2016-10-25  9:45 UTC (permalink / raw)
  To: Vlad Tsyrklevich; +Cc: linux-i2c

[-- 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 --]

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

* Re: [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure
  2016-10-25  9:45 ` Wolfram Sang
@ 2017-01-09 10:19   ` Vlad Tsyrklevich
  2017-01-09 14:48     ` Wolfram Sang
  0 siblings, 1 reply; 6+ messages in thread
From: Vlad Tsyrklevich @ 2017-01-09 10:19 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c

I apologize for the long delay, this reply got lost in my inbox. I've
added an updated patch below:

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>

---
 drivers/i2c/i2c-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 66f323f..6f638bb 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -331,7 +331,7 @@ static noinline int i2cdev_ioctl_smbus(struct
i2c_client *client,
    unsigned long arg)
 {
  struct i2c_smbus_ioctl_data data_arg;
- union i2c_smbus_data temp;
+ union i2c_smbus_data temp = {};
  int datasize, res;

  if (copy_from_user(&data_arg,

On Tue, Oct 25, 2016 at 4:45 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
> 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
>>

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

* Re: [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure
  2017-01-09 10:19   ` Vlad Tsyrklevich
@ 2017-01-09 14:48     ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2017-01-09 14:48 UTC (permalink / raw)
  To: Vlad Tsyrklevich; +Cc: linux-i2c

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

On Mon, Jan 09, 2017 at 05:19:23PM +0700, Vlad Tsyrklevich wrote:
> I apologize for the long delay, this reply got lost in my inbox. I've
> added an updated patch below:

No problem, thanks for doing it. Looks good. Can you please resend as a
seperate patch (not embedded in the midst of a message?) Thank you!

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


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

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

* Re: [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure
  2017-01-09 15:53 Vlad Tsyrklevich
@ 2017-01-12 18:36 ` Wolfram Sang
  0 siblings, 0 replies; 6+ messages in thread
From: Wolfram Sang @ 2017-01-12 18:36 UTC (permalink / raw)
  To: Vlad Tsyrklevich; +Cc: linux-i2c

On Mon, Jan 09, 2017 at 10:53:36PM +0700, 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>

Applied to for-current, thanks!

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

* [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure
@ 2017-01-09 15:53 Vlad Tsyrklevich
  2017-01-12 18:36 ` Wolfram Sang
  0 siblings, 1 reply; 6+ messages in thread
From: Vlad Tsyrklevich @ 2017-01-09 15:53 UTC (permalink / raw)
  To: wsa; +Cc: linux-i2c, Vlad Tsyrklevich

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>
---
 drivers/i2c/i2c-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 66f323f..6f638bb 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -331,7 +331,7 @@ static noinline int i2cdev_ioctl_smbus(struct i2c_client *client,
 		unsigned long arg)
 {
 	struct i2c_smbus_ioctl_data data_arg;
-	union i2c_smbus_data temp;
+	union i2c_smbus_data temp = {};
 	int datasize, res;
 
 	if (copy_from_user(&data_arg,
-- 
2.7.0

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

end of thread, other threads:[~2017-01-12 18:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-11 12:52 [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure Vlad Tsyrklevich
2016-10-25  9:45 ` Wolfram Sang
2017-01-09 10:19   ` Vlad Tsyrklevich
2017-01-09 14:48     ` Wolfram Sang
2017-01-09 15:53 Vlad Tsyrklevich
2017-01-12 18:36 ` Wolfram Sang

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.