Skip to content

Commit

Permalink
can: isotp: isotp_setsockopt(): only allow to set low level TX flags …
Browse files Browse the repository at this point in the history
…for CAN-FD

CAN-FD frames have struct canfd_frame::flags, while classic CAN frames
don't.

This patch refuses to set TX flags (struct
can_isotp_ll_options::tx_flags) on non CAN-FD isotp sockets.

Fixes: e057dd3fc20f ("can: add ISO 15765-2:2016 transport protocol")
Link: https://lore.kernel.org/r/20210218215434.1708249-2-mkl@pengutronix.de
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
  • Loading branch information
hartkopp committed Mar 19, 2021
1 parent f1866ab commit 96a8caa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/can/isotp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,8 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname,
if (ll.mtu != CAN_MTU && ll.mtu != CANFD_MTU)
return -EINVAL;

if (ll.mtu == CAN_MTU && ll.tx_dl > CAN_MAX_DLEN)
if (ll.mtu == CAN_MTU &&
(ll.tx_dl > CAN_MAX_DLEN || ll.tx_flags != 0))
return -EINVAL;

memcpy(&so->ll, &ll, sizeof(ll));
Expand Down

0 comments on commit 96a8caa

Please sign in to comment.