Skip to contentSkip to conversation

can: dev: prevent potential information leak in can_fill_info()

PATCH In review Dan Carpenter 2 participants 2 messages Jan 21, 2021

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

PATCH 1/1 can: dev: prevent potential information leak in can_fill_info()

The "bec" struct isn't necessarily always initialized. For example, the mcp251xfd_get_berr_counter() function doesn't initialize anything if the interface is down.

Fixes 52c793f24054 ("can: netlink support for bus-error reporting and counters")
---
 drivers/net/can/dev/netlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/dev/netlink.c +1 -1
index 3ae884cdf677..7a1ff6fcbb8f 100644
@@ -263,7 +263,7 @@ static int can_fill_info(struct sk_buff *skb, const struct net_device *dev)
 {
 	struct can_priv *priv = netdev_priv(dev);
 	struct can_ctrlmode cm = {.flags = priv->ctrlmode};
-	struct can_berr_counter bec;
+	struct can_berr_counter bec = {};
 	enum can_state state = priv->state;
 
 	if (priv->do_get_state)
Signature · 1 line
2.29.2
#1 lore raw

Hey Dan,

Quoted 6 lines · Dan Carpenter

The "bec" struct isn't necessarily always initialized. For example, the mcp251xfd_get_berr_counter() function doesn't initialize anything if the interface is down.

Fixes 52c793f24054 ("can: netlink support for bus-error reporting and counters")

Thanks for the patch. As this is a fix, I've backported it to net/master, which is before the split of the dev.c into separate files. Applied to linux-can/testing.

regards,
Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |