linux-i2c.vger.kernel.org archive mirror
 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
* [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
  -- strict thread matches above, loose matches on Subject: below --
2017-01-09 15:53 Vlad Tsyrklevich
2017-01-12 18:36 ` Wolfram Sang

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