Re: [PATCH] drivers/i2c/i2c-dev: Fix kernel memory disclosure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

---
 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@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxxxx>
>
> 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
>>
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux