Skip to contentSkip to conversation

Staging: comedi: fix information leak

PATCH In review Matteo Semenzato 3 participants 3 messages Mar 9, 2015 – Mar 10, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: comedi: fix information leak

From: Matteo Semenzato <[email protected]>

The comedi_cmd struct has an hole after chanlist_len that could contain uninitialized memory, this struct is copied to userspace.

---
 drivers/staging/comedi/comedi_fops.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/staging/comedi/comedi_fops.c +2 -0
index 727640e..1cdf0a2 100644
@@ -1718,6 +1718,8 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
 	unsigned int __user *user_chanlist;
 	int ret;
 
+	memset(&cmd, 0, sizeof(cmd));
+
 	/* get the user's cmd and do some simple validation */
 	ret = __comedi_get_user_cmd(dev, arg, &cmd);
 	if (ret)
Signature · 1 line
2.3.2
#1 lore raw
Quoted 16 lines · Matteo Semenzato

From: Matteo Semenzato <[email protected]>

The comedi_cmd struct has an hole after chanlist_len that could contain uninitialized memory, this struct is copied to userspace.

---
  drivers/staging/comedi/comedi_fops.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/staging/comedi/comedi_fops.c +0 -0
index 727640e..1cdf0a2 100644

drivers/staging/comedi/comedi_fops.c static int do_cmdtest_ioctl(struct comedi_device *dev, · line 1725

Quoted 8 lines
drivers/staging/comedi/comedi_fops.c +2 -0
@@ -1718,6 +1718,8 @@ static int do_cmdtest_ioctl(struct comedi_device *dev,
  	unsigned int __user *user_chanlist;
  	int ret;
 
+	memset(&cmd, 0, sizeof(cmd));
+
  	/* get the user's cmd and do some simple validation */
  	ret = __comedi_get_user_cmd(dev, arg, &cmd);
  	if (ret)

I see no information leak there. The cmd variable gets copied over with user memory by the call to __comedi_get_user_cmd(), so zero-filling it first is rather pointless.

Signature · 2 lines
-=( Ian Abbott @ MEV Ltd.    E-mail: <[email protected]> )=-
-=(                          Web: http://www.mev.co.uk/  )=-
#2 lore raw
In reply to Matteo Semenzato
Quoted 5 lines · Matteo Semenzato

From: Matteo Semenzato <[email protected]>

The comedi_cmd struct has an hole after chanlist_len that could contain uninitialized memory, this struct is copied to userspace.

Is this a Smatch warning? If so then, I appologize because it's a false positive. You really need to have the cross function database built for that test to work.

The struct is initialized in __comedi_get_user_cmd().

regards,
dan carpenter