Skip to content

Commit 833b011

Browse files
hartkoppSasha Levin
authored andcommitted
can: isotp: stop timeout monitoring when no first frame was sent
commit d734970 upstream. The first attempt to fix a the 'impossible' WARN_ON_ONCE(1) in isotp_tx_timer_handler() focussed on the identical CAN IDs created by the syzbot reproducer and lead to upstream fix/commit 3ea5664 ("can: isotp: sanitize CAN ID checks in isotp_bind()"). But this did not catch the root cause of the wrong tx.state in the tx_timer handler. In the isotp 'first frame' case a timeout monitoring needs to be started before the 'first frame' is send. But when this sending failed the timeout monitoring for this specific frame has to be disabled too. Otherwise the tx_timer is fired with the 'warn me' tx.state of ISOTP_IDLE. Fixes: e057dd3 ("can: add ISO 15765-2:2016 transport protocol") Link: https://lore.kernel.org/all/[email protected] Reported-by: [email protected] Signed-off-by: Oliver Hartkopp <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 59ded64 commit 833b011

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

net/can/isotp.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
864864
struct canfd_frame *cf;
865865
int ae = (so->opt.flags & CAN_ISOTP_EXTEND_ADDR) ? 1 : 0;
866866
int wait_tx_done = (so->opt.flags & CAN_ISOTP_WAIT_TX_DONE) ? 1 : 0;
867+
s64 hrtimer_sec = 0;
867868
int off;
868869
int err;
869870

@@ -962,7 +963,9 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
962963
isotp_create_fframe(cf, so, ae);
963964

964965
/* start timeout for FC */
965-
hrtimer_start(&so->txtimer, ktime_set(1, 0), HRTIMER_MODE_REL_SOFT);
966+
hrtimer_sec = 1;
967+
hrtimer_start(&so->txtimer, ktime_set(hrtimer_sec, 0),
968+
HRTIMER_MODE_REL_SOFT);
966969
}
967970

968971
/* send the first or only CAN frame */
@@ -975,6 +978,11 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
975978
if (err) {
976979
pr_notice_once("can-isotp: %s: can_send_ret %d\n",
977980
__func__, err);
981+
982+
/* no transmission -> no timeout monitoring */
983+
if (hrtimer_sec)
984+
hrtimer_cancel(&so->txtimer);
985+
978986
goto err_out_drop;
979987
}
980988

0 commit comments

Comments
 (0)