Skip to content

Commit b5f020f

Browse files
hartkoppmarckleinebudde
authored andcommitted
can: isotp: tx-path: zero initialize outgoing CAN frames
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]>
1 parent 5aa3c33 commit b5f020f

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);
@@ -895,7 +895,7 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
895895
so->tx.idx = 0;
896896

897897
cf = (struct canfd_frame *)skb->data;
898-
skb_put(skb, so->ll.mtu);
898+
skb_put_zero(skb, so->ll.mtu);
899899

900900
/* check for single frame transmission depending on TX_DL */
901901
if (size <= so->tx.ll_dl - SF_PCI_SZ4 - ae - off) {

0 commit comments

Comments
 (0)