Skip to contentSkip to conversation

isotp: do not validate RX address when the broadcast flag is active

PATCH In review Thomseeen 3 participants 7 messages Dec 4, 2020 – Dec 6, 2020

Subsystems (2)
lore
Share & tools
lore

Thomseeen

author
#0 lore raw

PATCH 1/1 isotp: do not validate RX address when the broadcast flag is active

EADDRNOTAVAIL shouldn't be thrown when an invalid RX address (e.g. NO_CAN_ID) is set while the socket is used with the CAN_ISOTP_SF_BROADCAST flag.

---
 net/can/isotp.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
net/can/isotp.c +13 -8
index fb6dba1..ae939bf 100644
@@ -1106,20 +1106,25 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
 #endif
 		return -EINVAL;
 
-	if (addr->can_addr.tp.rx_id == addr->can_addr.tp.tx_id)
-		return -EADDRNOTAVAIL;
+	/* do not register frame reception for functional addressing */
+	if (so->opt.flags & CAN_ISOTP_SF_BROADCAST)
+		do_rx_reg = 0;
+
+	/* do not validate rx address for functional addressing */
+	if (do_rx_reg) {
+		if (addr->can_addr.tp.rx_id == addr->can_addr.tp.tx_id)
+			return -EADDRNOTAVAIL;
 
-	if ((addr->can_addr.tp.rx_id | addr->can_addr.tp.tx_id) &
-	    (CAN_ERR_FLAG | CAN_RTR_FLAG))
+		if (addr->can_addr.tp.rx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG))
+			return -EADDRNOTAVAIL;
+	}
+
+	if (addr->can_addr.tp.tx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG))
 		return -EADDRNOTAVAIL;
 
 	if (!addr->can_ifindex)
 		return -ENODEV;
 
-	/* do not register frame reception for functional addressing */
-	if (so->opt.flags & CAN_ISOTP_SF_BROADCAST)
-		do_rx_reg = 0;
-
 	lock_sock(sk);
 
 	if (so->bound && addr->can_ifindex == so->ifindex &&

--
2.25.1

#1 lore raw
Quoted 4 lines · Thomseeen

EADDRNOTAVAIL shouldn't be thrown when an invalid RX address (e.g. NO_CAN_ID) is set while the socket is used with the CAN_ISOTP_SF_BROADCAST flag.

Is this your realname? For the kernel the s-o-b requires your realname. For details about the S-o-b, see:

https://elixir.bootlin.com/linux/v5.9.12/source/Documentation/process/submitting-patches.rst#L423

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
maintainer
#2 lore raw
Quoted 11 lines · Marc Kleine-Budde
Quoted 4 lines · Thomseeen

EADDRNOTAVAIL shouldn't be thrown when an invalid RX address (e.g. NO_CAN_ID) is set while the socket is used with the CAN_ISOTP_SF_BROADCAST flag.

Is this your realname? For the kernel the s-o-b requires your realname. For details about the S-o-b, see:

https://elixir.bootlin.com/linux/v5.9.12/source/Documentation/process/submitting-patches.rst#L423

Thomas' name is correct in my patch here:
https://lore.kernel.org/linux-can/[email protected]/T/#m3c780406ff756cd0b66f1d34744fb4d8eb4abaf6

Regards,
Oliver

#3 lore raw
In reply to Marc Kleine-Budde

Hi,

Quoted 7 lines · Marc Kleine-Budde
Quoted 4 lines · Thomseeen

EADDRNOTAVAIL shouldn't be thrown when an invalid RX address (e.g. NO_CAN_ID) is set while the socket is used with the CAN_ISOTP_SF_BROADCAST flag.

Is this your realname? For the kernel the s-o-b requires your realname. [...]

sorry, it is of course not. Messed up with my git configs. It should be:

Should I repost the patch with a proper tag?

Regards
Thomas

maintainer Acked-by on v1 1/1
#4 lore raw
In reply to Thomseeen
Quoted 4 lines · Thomseeen

EADDRNOTAVAIL shouldn't be thrown when an invalid RX address (e.g. NO_CAN_ID) is set while the socket is used with the CAN_ISOTP_SF_BROADCAST flag.

Quoted 45 lines
---
  net/can/isotp.c | 21 +++++++++++++--------
  1 file changed, 13 insertions(+), 8 deletions(-)
net/can/isotp.c +13 -9
index fb6dba1..ae939bf 100644
@@ -1106,20 +1106,25 @@ static int isotp_bind(struct socket *sock, struct sockaddr *uaddr, int len)
  #endif
  		return -EINVAL;
 
-	if (addr->can_addr.tp.rx_id == addr->can_addr.tp.tx_id)
-		return -EADDRNOTAVAIL;
+	/* do not register frame reception for functional addressing */
+	if (so->opt.flags & CAN_ISOTP_SF_BROADCAST)
+		do_rx_reg = 0;
+
+	/* do not validate rx address for functional addressing */
+	if (do_rx_reg) {
+		if (addr->can_addr.tp.rx_id == addr->can_addr.tp.tx_id)
+			return -EADDRNOTAVAIL;
 
-	if ((addr->can_addr.tp.rx_id | addr->can_addr.tp.tx_id) &
-	    (CAN_ERR_FLAG | CAN_RTR_FLAG))
+		if (addr->can_addr.tp.rx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG))
+			return -EADDRNOTAVAIL;
+	}
+
+	if (addr->can_addr.tp.tx_id & (CAN_ERR_FLAG | CAN_RTR_FLAG))
  		return -EADDRNOTAVAIL;
 
  	if (!addr->can_ifindex)
  		return -ENODEV;
 
-	/* do not register frame reception for functional addressing */
-	if (so->opt.flags & CAN_ISOTP_SF_BROADCAST)
-		do_rx_reg = 0;
-
  	lock_sock(sk);
 
  	if (so->bound && addr->can_ifindex == so->ifindex &&
--

2.25.1

#5 lore raw
Quoted 7 lines · Oliver Hartkopp
Quoted 4 lines · Thomseeen

EADDRNOTAVAIL shouldn't be thrown when an invalid RX address (e.g. NO_CAN_ID) is set while the socket is used with the CAN_ISOTP_SF_BROADCAST flag.

Should this be squashed into "support for functional addressing"?

Can you re-post the two or three isotp patches, as they should go into can-next/net-next?

Quoted 2 lines

98bef9295d07 can: isotp: isotp_setsockopt(): block setsockopt on bound sockets 21f10f1b5c3a can: isotp: add SF_BROADCAST support for functional addressing

Marc

Signature · 4 lines
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |
maintainer
#6 lore raw
Quoted 5 lines · Marc Kleine-Budde
Quoted 4 lines · Oliver Hartkopp
Quoted 3 lines · Thomseeen

EADDRNOTAVAIL shouldn't be thrown when an invalid RX address (e.g. NO_CAN_ID) is set while the socket is used with the CAN_ISOTP_SF_BROADCAST flag.

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Should this be squashed into "support for functional addressing"?

Can you re-post the two or three isotp patches, as they should go into can-next/net-next?

Yes, will do.

Quoted 5 lines
Quoted 2 lines

98bef9295d07 can: isotp: isotp_setsockopt(): block setsockopt on bound sockets 21f10f1b5c3a can: isotp: add SF_BROADCAST support for functional addressing

Marc