can: isotp: isotp_bind(): return -EINVAL on incorrect CAN ID formatting

Commit 3ea566422c ("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 <derekrobertwill@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
Oliver Hartkopp 2022-05-15 20:16:33 +02:00 committed by Marc Kleine-Budde
parent 9f39d36530
commit 2aa39889c4
1 changed files with 5 additions and 0 deletions

View File

@ -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;