All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Thomseeen <thwa1@web.de>, linux-can@vger.kernel.org
Subject: Re: [PATCH] isotp: do not validate RX address when the broadcast flag is active
Date: Sat, 5 Dec 2020 22:15:21 +0100	[thread overview]
Message-ID: <d7f4c720-199f-8837-829e-653c435f52d1@hartkopp.net> (raw)
In-Reply-To: <20201204135557.55599-1-thwa1@web.de>



On 04.12.20 14:55, Thomseeen wrote:
> 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.
> 
> Signed-off-by: Thomseeen <thwa1@web.de>

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

> ---
>   net/can/isotp.c | 21 +++++++++++++--------
>   1 file changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index fb6dba1..ae939bf 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
> @@ -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
> 

  parent reply	other threads:[~2020-12-05 21:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-04 13:55 [PATCH] isotp: do not validate RX address when the broadcast flag is active Thomseeen
2020-12-05 20:59 ` Marc Kleine-Budde
2020-12-05 21:05   ` Oliver Hartkopp
2020-12-05 21:15   ` thwa1
2020-12-05 21:15 ` Oliver Hartkopp [this message]
2020-12-05 21:23   ` Marc Kleine-Budde
2020-12-06 10:32     ` Oliver Hartkopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d7f4c720-199f-8837-829e-653c435f52d1@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=thwa1@web.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.