diff options
author | Oliver Hartkopp <socketcan@hartkopp.net> | 2023-10-31 10:29:13 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-11-08 17:30:50 +0100 |
commit | 0386f37047899b3af95b00090b1f4ff4f5990f8d (patch) | |
tree | e8fb0b9ea0bb628c2cb99237e753f823d3d6843a | |
parent | 93b1e3f3a263e9986e8f46d23f1a932d4e34adf4 (diff) | |
download | linux-stable-0386f37047899b3af95b00090b1f4ff4f5990f8d.tar.gz linux-stable-0386f37047899b3af95b00090b1f4ff4f5990f8d.tar.bz2 linux-stable-0386f37047899b3af95b00090b1f4ff4f5990f8d.zip |
can: isotp: isotp_bind(): return -EINVAL on incorrect CAN ID formatting
commit 2aa39889c463195a0dfe2aff9fad413139c32a4f upstream
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 <derekrobertwill@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/can/isotp.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/net/can/isotp.c b/net/can/isotp.c index fb179a333784..902cb61b6495 100644 --- a/net/can/isotp.c +++ b/net/can/isotp.c @@ -1142,6 +1142,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; |