* [PATCH can-next] can: isotp: return -EINVAL on incorrect CAN ID formatting
@ 2022-05-15 18:16 Oliver Hartkopp
0 siblings, 0 replies; only message in thread
From: Oliver Hartkopp @ 2022-05-15 18:16 UTC (permalink / raw)
To: linux-can; +Cc: Oliver Hartkopp, Derek Will
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).
Suggested-by: Derek Will <derekrobertwill@gmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
---
net/can/isotp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/can/isotp.c b/net/can/isotp.c
index 2caeeae8ec16..4a4007f10970 100644
--- a/net/can/isotp.c
+++ b/net/can/isotp.c
@@ -1230,10 +1230,15 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
if (rx_id & CAN_EFF_FLAG)
rx_id &= (CAN_EFF_FLAG | CAN_EFF_MASK);
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;
lock_sock(sk);
--
2.30.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-15 18:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-15 18:16 [PATCH can-next] can: isotp: return -EINVAL on incorrect CAN ID formatting Oliver Hartkopp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).