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:   Fri, 16 Oct 2020 19:35:58 -0700
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Christian Eggers <ceggers@...i.de>, Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Kurt Kanzenbach <kurt@...utronix.de>
Cc:     "David S . Miller" <davem@...emloft.net>,
        Woojung Huh <woojung.huh@...rochip.com>,
        Microchip Linux Driver Support <UNGLinuxDriver@...rochip.com>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 1/3] net: dsa: don't pass cloned skb's to drivers
 xmit function



On 10/16/2020 1:02 PM, Christian Eggers wrote:
> Ensure that the skb is not cloned and has enough tail room for the tail
> tag. This code will be removed from the drivers in the next commits.
> 
> Signed-off-by: Christian Eggers <ceggers@...i.de>
> ---

[snip]

> +	/* We have to pad he packet to the minimum Ethernet frame size,
> +	 * if necessary, before adding the trailer (tail tagging only).
> +	 */
> +	padlen = (skb->len >= ETH_ZLEN) ? 0 : ETH_ZLEN - skb->len;
> +
> +	/* To keep the slave's xmit() methods simple, don't pass cloned skbs to
> +	 * them. Additionally ensure, that suitable room for tail tagging is
> +	 * available.
> +	 */
> +	if (skb_cloned(skb) ||
> +	    (p->tail_tag && skb_tailroom(skb) < (padlen + p->overhead))) {
> +		struct sk_buff *nskb;
> +
> +		nskb = alloc_skb(NET_IP_ALIGN + skb->len +
> +				 padlen + p->overhead, GFP_ATOMIC);
> +		if (!nskb) {
> +			kfree_skb(skb);
> +			return NETDEV_TX_OK;
> +		}
> +		skb_reserve(nskb, NET_IP_ALIGN);
> +
> +		skb_reset_mac_header(nskb);
> +		skb_set_network_header(nskb,
> +				       skb_network_header(skb) - skb->head);
> +		skb_set_transport_header(nskb,
> +					 skb_transport_header(skb) - skb->head);
> +		skb_copy_and_csum_dev(skb, skb_put(nskb, skb->len));
> +		consume_skb(skb);
> +
> +		if (padlen)
> +			skb_put_zero(nskb, padlen);
> +
> +		skb = nskb;
> +	}

Given the low number of tail taggers, maybe this should be a helper 
function that is used by them where applicable? If nothing else you may 
want to sprinkle unlikely() conditions to sort of hing the processor 
that these are unlikely conditions.
-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ