Skip to content

Commit d734970

Browse files
hartkoppmarckleinebudde
authored andcommitted
can: isotp: stop timeout monitoring when no first frame was sent
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]>
1 parent 49aefd1 commit d734970

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
@@ -906,6 +906,7 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
906906
struct canfd_frame *cf;
907907
int ae = (so->opt.flags & CAN_ISOTP_EXTEND_ADDR) ? 1 : 0;
908908
int wait_tx_done = (so->opt.flags & CAN_ISOTP_WAIT_TX_DONE) ? 1 : 0;
909+
s64 hrtimer_sec = 0;
909910
int off;
910911
int err;
911912

@@ -1004,7 +1005,9 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
10041005
isotp_create_fframe(cf, so, ae);
10051006

10061007
/* start timeout for FC */
1007-
hrtimer_start(&so->txtimer, ktime_set(1, 0), HRTIMER_MODE_REL_SOFT);
1008+
hrtimer_sec = 1;
1009+
hrtimer_start(&so->txtimer, ktime_set(hrtimer_sec, 0),
1010+
HRTIMER_MODE_REL_SOFT);
10081011
}
10091012

10101013
/* send the first or only CAN frame */
@@ -1017,6 +1020,11 @@ static int isotp_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
10171020
if (err) {
10181021
pr_notice_once("can-isotp: %s: can_send_ret %pe\n",
10191022
__func__, ERR_PTR(err));
1023+
1024+
/* no transmission -> no timeout monitoring */
1025+
if (hrtimer_sec)
1026+
hrtimer_cancel(&so->txtimer);
1027+
10201028
goto err_out_drop;
10211029
}
10221030

0 commit comments

Comments
 (0)