]> git.baikalelectronics.ru Git - kernel.git/commitdiff
can: isotp: isotp_setsockopt(): only allow to set low level TX flags for CAN-FD
authorMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 18 Feb 2021 20:58:36 +0000 (21:58 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Tue, 16 Mar 2021 07:40:04 +0000 (08:40 +0100)
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>
net/can/isotp.c

index 3ef7f78e553bc93e2c24db9b5b8a016cc0235f28..e32d446c121e7fc20ba0ac20ea45f611c1ead959 100644 (file)
@@ -1228,7 +1228,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));