Skip to contentSkip to conversation

can: j1939: fix missing CAN header initialization

PATCH Applied Oliver Hartkopp 2 participants 2 messages Nov 4, 2022

Subsystems (5)
lore
Share & tools
lore

Oliver Hartkopp

author maintainer
#0 lore raw

PATCH 1/1 can: j1939: fix missing CAN header initialization

The read access to struct canxl_frame::len inside of a j1939 created skbuff revealed a missing initialization of reserved and later filled elements in struct can_frame.

This patch initializes the 8 byte CAN header with zero.

Fixes 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Cc Oleksij Rempel <[email protected]>
Reported-by [email protected]
---
 net/can/j1939/main.c | 3 +++
 1 file changed, 3 insertions(+)
net/can/j1939/main.c +3 -0
index 144c86b0e3ff..821d4ff303b3 100644
@@ -334,10 +334,13 @@ int j1939_send_one(struct j1939_priv *priv, struct sk_buff *skb)
 	dlc = skb->len;
 
 	/* re-claim the CAN_HDR from the SKB */
 	cf = skb_push(skb, J1939_CAN_HDR);
 
+	/* initialize header structure */
+	memset(cf, 0, J1939_CAN_HDR);
+
 	/* make it a full can frame again */
 	skb_put(skb, J1939_CAN_FTR + (8 - dlc));
 
 	canid = CAN_EFF_FLAG |
 		(skcb->priority << 26) |
Signature · 1 line
2.30.2
maintainer Applied
#1 lore raw
Quoted 11 lines · Oliver Hartkopp

The read access to struct canxl_frame::len inside of a j1939 created skbuff revealed a missing initialization of reserved and later filled elements in struct can_frame.

This patch initializes the 8 byte CAN header with zero.

Fixes 9d71dd0c7009 ("can: add support of SAE J1939 protocol")
Cc Oleksij Rempel <[email protected]>
Reported-by [email protected]

Applied to linux-can + add stable on Cc.

Thanks,
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 |