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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 17 Feb 2021 13:33:14 +0200
From:   Vladimir Oltean <olteanv@...il.com>
To:     Linus Walleij <linus.walleij@...aro.org>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        Mauri Sandberg <sandberg@...lfence.com>,
        DENG Qingfang <dqfext@...il.com>
Subject: Re: [PATCH] net: dsa: tag_rtl4_a: Support also egress tags

On Wed, Feb 17, 2021 at 12:55:42AM +0100, Linus Walleij wrote:
> Support also transmitting frames using the custom "8899 A"
> 4 byte tag.
> 
> Qingfang came up with the solution: we need to pad the
> ethernet frame to 60 bytes using eth_skb_pad(), then the
> switch will happily accept frames with custom tags.

I think it's pretty frustrating to realize that 'it didn't werk' because
you only tested with ping.

> Cc: Mauri Sandberg <sandberg@...lfence.com>
> Reported-by: DENG Qingfang <dqfext@...il.com>

Reported-by seems like a bit of an understatement. Suggested-by maybe?

> Fixes: efd7fe68f0c6 ("net: dsa: tag_rtl4_a: Implement Realtek 4 byte A tag")
> Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
> ---
>  net/dsa/tag_rtl4_a.c | 43 +++++++++++++++++++++++++++++--------------
>  1 file changed, 29 insertions(+), 14 deletions(-)
> 
> diff --git a/net/dsa/tag_rtl4_a.c b/net/dsa/tag_rtl4_a.c
> index 2646abe5a69e..c17d39b4a1a0 100644
> --- a/net/dsa/tag_rtl4_a.c
> +++ b/net/dsa/tag_rtl4_a.c
> @@ -12,9 +12,7 @@
>   *
>   * The 2 bytes tag form a 16 bit big endian word. The exact
>   * meaning has been guessed from packet dumps from ingress
> - * frames, as no working egress traffic has been available
> - * we do not know the format of the egress tags or if they
> - * are even supported.
> + * frames.
>   */
>  
>  #include <linux/etherdevice.h>
> @@ -36,17 +34,34 @@
>  static struct sk_buff *rtl4a_tag_xmit(struct sk_buff *skb,
>  				      struct net_device *dev)
>  {
> -	/*
> -	 * Just let it pass thru, we don't know if it is possible
> -	 * to tag a frame with the 0x8899 ethertype and direct it
> -	 * to a specific port, all attempts at reverse-engineering have
> -	 * ended up with the frames getting dropped.
> -	 *
> -	 * The VLAN set-up needs to restrict the frames to the right port.
> -	 *
> -	 * If you have documentation on the tagging format for RTL8366RB
> -	 * (tag type A) then please contribute.
> -	 */
> +	struct dsa_port *dp = dsa_slave_to_port(dev);
> +	u8 *tag;
> +	u16 *p;
> +	u16 out;
> +
> +	/* Pad out to at least 60 bytes */
> +	if (unlikely(eth_skb_pad(skb)))
> +		return NULL;
> +	if (skb_cow_head(skb, RTL4_A_HDR_LEN) < 0)
> +		return NULL;
> +
> +	netdev_dbg(dev, "add realtek tag to package to port %d\n",
> +		   dp->index);

You should probably remove any sort of printing from the hot path.

> +	skb_push(skb, RTL4_A_HDR_LEN);
> +
> +	memmove(skb->data, skb->data + RTL4_A_HDR_LEN, 2 * ETH_ALEN);
> +	tag = skb->data + 2 * ETH_ALEN;
> +
> +	/* Set Ethertype */
> +	p = (u16 *)tag;
> +	*p = htons(RTL4_A_ETHERTYPE);
> +
> +	out = (RTL4_A_PROTOCOL_RTL8366RB << 12) | (2 << 8);
> +	/* The lower bits is the port numer */
> +	out |= (u8)dp->index;
> +	p = (u16 *)(tag + 2);
> +	*p = htons(out);
> +
>  	return skb;
>  }
>  
> -- 
> 2.29.2
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ