Skip to content

Commit 0b7bc92

Browse files
hartkoppgregkh
authored andcommitted
can: isotp: tx-path: zero initialize outgoing CAN frames
[ Upstream commit b5f020f ] Commit d4eb538 ("can: isotp: TX-path: ensure that CAN frame flags are initialized") ensured the TX flags to be properly set for outgoing CAN frames. In fact the root cause of the issue results from a missing initialization of outgoing CAN frames created by isotp. This is no problem on the CAN bus as the CAN driver only picks the correctly defined content from the struct can(fd)_frame. But when the outgoing frames are monitored (e.g. with candump) we potentially leak some bytes in the unused content of struct can(fd)_frame. Fixes: e057dd3 ("can: add ISO 15765-2:2016 transport protocol") Cc: Marc Kleine-Budde <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Hartkopp <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent ccd5565 commit 0b7bc92

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/can/isotp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static int isotp_send_fc(struct sock *sk, int ae, u8 flowstatus)
196196
nskb->dev = dev;
197197
can_skb_set_owner(nskb, sk);
198198
ncf = (struct canfd_frame *)nskb->data;
199-
skb_put(nskb, so->ll.mtu);
199+
skb_put_zero(nskb, so->ll.mtu);
200200

201201
/* create & send flow control reply */
202202
ncf->can_id = so->txid;
@@ -779,7 +779,7 @@ static enum hrtimer_restart isotp_tx_timer_handler(struct hrtimer *hrtimer)
779779
can_skb_prv(skb)->skbcnt = 0;
780780

781781
cf = (struct canfd_frame *)skb->data;
782-
skb_put(skb, so->ll.mtu);
782+
skb_put_zero(skb, so->ll.mtu);
783783

784784
/* create consecutive frame */
785785
isotp_fill_dataframe(cf, so, ae, 0);
@@ -887,7 +887,7 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
887887
so->tx.idx = 0;
888888

889889
cf = (struct canfd_frame *)skb->data;
890-
skb_put(skb, so->ll.mtu);
890+
skb_put_zero(skb, so->ll.mtu);
891891

892892
/* take care of a potential SF_DL ESC offset for TX_DL > 8 */
893893
off = (so->tx.ll_dl > CAN_MAX_DLEN) ? 1 : 0;

0 commit comments

Comments
 (0)