From: Oliver Hartkopp Date: Sun, 15 May 2022 18:16:33 +0000 (+0200) Subject: can: isotp: isotp_bind(): return -EINVAL on incorrect CAN ID formatting X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=2aa39889c463195a0dfe2aff9fad413139c32a4f;p=linux.git can: isotp: isotp_bind(): return -EINVAL on incorrect CAN ID formatting Commit 3ea566422cbd ("can: isotp: sanitize CAN ID checks in isotp_bind()") checks the given CAN ID address information by sanitizing the input values. This check (silently) removes obsolete bits by masking the given CAN IDs. Derek Will suggested to give a feedback to the application programmer when the 'sanitizing' was actually needed which means the programmer provided CAN ID content in a wrong format (e.g. SFF CAN IDs with a CAN ID > 0x7FF). Link: https://lore.kernel.org/all/20220515181633.76671-1-socketcan@hartkopp.net Suggested-by: Derek Will Signed-off-by: Oliver Hartkopp Signed-off-by: Marc Kleine-Budde --- diff --git a/net/can/isotp.c b/net/can/isotp.c index 2caeeae8ec16f..4a4007f10970e 100644 --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -1232,6 +1232,11 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len) else rx_id &= CAN_SFF_MASK; + /* give feedback on wrong CAN-ID values */ + if (tx_id != addr->can_addr.tp.tx_id || + rx_id != addr->can_addr.tp.rx_id) + return -EINVAL; + if (!addr->can_ifindex) return -ENODEV;