lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <56724e21-65a0-ea65-ed65-a24b68ed99df@iogearbox.net>
Date: Mon, 3 Jun 2024 09:11:55 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: Ido Schimmel <idosch@...dia.com>
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org,
 David Bauer <mail@...id-bauer.net>, Nikolay Aleksandrov
 <razor@...ckwall.org>, Martin KaFai Lau <martin.lau@...nel.org>
Subject: Re: [PATCH net] vxlan: Fix regression when dropping packets due to
 invalid src addresses

On 6/2/24 10:37 AM, Ido Schimmel wrote:
> On Fri, May 31, 2024 at 05:41:37PM +0200, Daniel Borkmann wrote:
>> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
>> index f78dd0438843..7353f27b02dc 100644
>> --- a/drivers/net/vxlan/vxlan_core.c
>> +++ b/drivers/net/vxlan/vxlan_core.c
>> @@ -1605,6 +1605,7 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan,
>>   			  struct vxlan_sock *vs,
>>   			  struct sk_buff *skb, __be32 vni)
>>   {
>> +	bool learning = vxlan->cfg.flags & VXLAN_F_LEARN;
>>   	union vxlan_addr saddr;
>>   	u32 ifindex = skb->dev->ifindex;
>>   
>> @@ -1616,8 +1617,11 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan,
>>   	if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr))
>>   		return false;
>>   
>> -	/* Ignore packets from invalid src-address */
>> -	if (!is_valid_ether_addr(eth_hdr(skb)->h_source))
>> +	/* Ignore packets from invalid src-address when in learning mode,
>> +	 * otherwise let them through e.g. when originating from NOARP
>> +	 * devices with all-zero mac, etc.
>> +	 */
>> +	if (learning && !is_valid_ether_addr(eth_hdr(skb)->h_source))
>>   		return false;
>>   
>>   	/* Get address from the outer IP header */
>> @@ -1631,7 +1635,7 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan,
>>   #endif
>>   	}
>>   
>> -	if ((vxlan->cfg.flags & VXLAN_F_LEARN) &&
>> +	if (learning &&
>>   	    vxlan_snoop(skb->dev, &saddr, eth_hdr(skb)->h_source, ifindex, vni))
>>   		return false;
> 
> Daniel, I think we can simply move this check out of the main path to
> vxlan_snoop() which is only called when learning is enabled:
> 
> diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c
> index 7496c14e8329..89f3945b448f 100644
> --- a/drivers/net/vxlan/vxlan_core.c
> +++ b/drivers/net/vxlan/vxlan_core.c
> @@ -1446,6 +1446,10 @@ static bool vxlan_snoop(struct net_device *dev,
>          struct vxlan_fdb *f;
>          u32 ifindex = 0;
>   
> +       /* Ignore packets from invalid src-address */
> +       if (!is_valid_ether_addr(src_mac))
> +               return true;
> +
>   #if IS_ENABLED(CONFIG_IPV6)
>          if (src_ip->sa.sa_family == AF_INET6 &&
>              (ipv6_addr_type(&src_ip->sin6.sin6_addr) & IPV6_ADDR_LINKLOCAL))
> @@ -1616,10 +1620,6 @@ static bool vxlan_set_mac(struct vxlan_dev *vxlan,
>          if (ether_addr_equal(eth_hdr(skb)->h_source, vxlan->dev->dev_addr))
>                  return false;
>   
> -       /* Ignore packets from invalid src-address */
> -       if (!is_valid_ether_addr(eth_hdr(skb)->h_source))
> -               return false;
> -
>          /* Get address from the outer IP header */
>          if (vxlan_get_sk_family(vs) == AF_INET) {
>                  saddr.sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
> 
> WDYT?

Makes sense, that looks better. Will send a v2, thanks Ido!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ