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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 25 Mar 2009 08:53:33 -0700
From:	Stephen Hemminger <shemminger@...tta.com>
To:	Li Yang <leoli@...escale.com>
Cc:	davem@...emloft.net, netdev@...r.kernel.org,
	Li Yang <leoli@...escale.com>
Subject: Re: [PATCH] gianfar: reallocate skb when headroom is not enough for
 fcb

On Wed, 25 Mar 2009 17:15:33 +0800
Li Yang <leoli@...escale.com> wrote:

> Gianfar uses a hardware header FCB for offloading.  However when used
> with bridging or IP forwarding, TX skb might not have enough headroom
> for the FCB.  Reallocate skb for such cases.
> 
> Signed-off-by: Li Yang <leoli@...escale.com>
> ---
>  drivers/net/gianfar.c |   31 +++++++++++++++++++++----------
>  1 files changed, 21 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
> index 9831b3f..29dc4ee 100644
> --- a/drivers/net/gianfar.c
> +++ b/drivers/net/gianfar.c
> @@ -1206,10 +1206,19 @@ static int gfar_enet_open(struct net_device *dev)
>  	return err;
>  }
>  
> -static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb)
> +static inline struct txfcb *gfar_add_fcb(struct sk_buff **skbp)
>  {
> -	struct txfcb *fcb = (struct txfcb *)skb_push (skb, GMAC_FCB_LEN);
> -
> +	struct txfcb *fcb;
> +	struct sk_buff *skb = *skbp;
> +
> +	if (unlikely(skb_headroom(skb) < GMAC_FCB_LEN)) {
> +		struct sk_buff *old_skb = skb;
> +		skb = skb_realloc_headroom(old_skb, GMAC_FCB_LEN);

> +		if (!skb)
> +			return NULL;
> +		dev_kfree_skb_any(old_skb);
> +	}
> +	fcb = (struct txfcb *)skb_push(skb, GMAC_FCB_LEN);
>  	cacheable_memzero(fcb, GMAC_FCB_LEN);
> 

Overall, this looks like the wrong code (not copying back new skb)
and in awkward place. Also your version doesn't handle case where
skb headroom is not writable.

Why not:

--- a/drivers/net/gianfar.c	2009-03-25 08:39:03.890718197 -0700
+++ b/drivers/net/gianfar.c	2009-03-25 08:51:39.733279404 -0700
@@ -1309,6 +1309,17 @@ static int gfar_start_xmit(struct sk_buf
 	unsigned long flags;
 	unsigned int nr_frags, length;
 
+	/* make sure there is space and can write FCB */
+	if (!skb_clone_writeable(skb, GMAC_FCB_LEN)) {
+		struct sk_buff *skb2;
+
+		skb2 = skb_realloc_headroom(skb, GMAC_FCB_LEN);
+		kfree_skb(skb);
+		if (!skb2)
+			return NETDEV_TX_OK;
+		skb = skb2;
+	}
+
 	base = priv->tx_bd_base;
 
 	/* total number of fragments in the SKB */

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ