Skip to contentSkip to conversation

net: usb: mcs7830: adjust incorrect comment implying a vulnerability

PATCH In review Ethan Nelson-Moore 2 participants 2 messages May 5

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: usb: mcs7830: adjust incorrect comment implying a vulnerability

The mcs7830 driver contains a comment indicating that mcs7830_get_regs leaks uninitialized memory to user space on some devices. If true, this would indicate a security vulnerability. However, I investigated the issue and found that it is not true because ethtool_get_regs (in net/ethtool/ioctl.c) uses vzalloc to allocate its buffer, which zeroes the memory. Update the comment to explain this behavior.

---
 drivers/net/usb/mcs7830.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/usb/mcs7830.c +2 -1
index d6698f30218d..dfdc7bd74166 100644
@@ -22,7 +22,8 @@
  * - implement get_eeprom/[set_eeprom]
  * - switch PHY on/off on ifup/ifdown (perhaps in usbnet.c, via MII)
  * - mcs7830_get_regs() handling is weird: for rev 2 we return 32 regs,
- *   can access only ~ 24, remaining user buffer is uninitialized garbage
+ *   can access only ~ 24; this is not a security vulnerability because
+ *   ethtool_get_regs allocates a zeroed buffer
  * - anything else?
  */
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 1 line · Ethan Nelson-Moore

The mcs7830 driver contains a comment indicating that mcs7830_get_regs

See, even in the comment the function is referred as func(). Please, follow this convention everywhere (comments, commit messages, documentation where it's appropriate).

Quoted 3 lines

leaks uninitialized memory to user space on some devices. If true, this would indicate a security vulnerability. However, I investigated the issue and found that it is not true because ethtool_get_regs (in

ethtool_get_regs()

Quoted 1 line

net/ethtool/ioctl.c) uses vzalloc to allocate its buffer, which zeroes

vzalloc()

Quoted 1 line

the memory. Update the comment to explain this behavior.

...

Quoted 6 lines

* - implement get_eeprom/[set_eeprom]
* - switch PHY on/off on ifup/ifdown (perhaps in usbnet.c, via MII)
* - mcs7830_get_regs() handling is weird: for rev 2 we return 32 regs,

- *   can access only ~ 24, remaining user buffer is uninitialized garbage
+ *   can access only ~ 24; this is not a security vulnerability because
+ *   ethtool_get_regs allocates a zeroed buffer

Same as above.

Quoted 1 line

* - anything else?

...

Also, while the patches are not conflicting with or dependent on each other, they are against the same driver, hence the series is preferable over individual patches.

Signature · 2 lines
With Best Regards,
Andy Shevchenko