Skip to content

Commit d94ef51

Browse files
committed
Merge tag 'linux-can-fixes-for-5.18-20220417' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
Marc Kleine-Budde says: ==================== pull-request: can 2022-04-17 this is a pull request of 1 patch for net/master. The patch is by Oliver Hartkopp and fixes a timeout monitoring problem in the ISO TP protocol found by the syzbot. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 49aefd1 + d734970 commit d94ef51

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)