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]
Message-ID: <1336031334.3503.23.camel@edumazet-glaptop>
Date:	Thu, 03 May 2012 09:48:54 +0200
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	Alexander Duyck <alexander.h.duyck@...el.com>
Cc:	netdev@...r.kernel.org, davem@...emloft.net,
	jeffrey.t.kirsher@...el.com, edumazet@...gle.com
Subject: Re: [v2 PATCH 1/4] tcp: Fix truesize accounting in tcp_try_coalesce

On Thu, 2012-05-03 at 00:18 -0700, Alexander Duyck wrote:
> This patch addresses several issues in the way we were tracking the
> truesize in tcp_try_coalesce.
> 
> First it was using ksize which prevents us from having a 0 sized head frag
> and getting a usable result.  To resolve that this patch uses the end
> pointer which is set based off either ksize, or the frag_size supplied in
> build_skb.  This allows us to compute the original truesize of the entire
> buffer and remove that value leaving us with just what was added as pages.
> 
> The second issue was the use of skb->len if there is a mergeable head frag.
> We should only need to remove the size of an data aligned sk_buff from our
> current skb->truesize to compute the delta for a buffer with a reused head.
> By using skb->len the value of truesize was being artificially reduced
> which means that head frags could use more memory than buffers using
> standard allocations.
> 
> Signed-off-by: Alexander Duyck <alexander.h.duyck@...el.com>
> Cc: Eric Dumazet <edumazet@...gle.com>
> Cc: Jeff Kirsher <jeffrey.t.kirsher@...el.com>
> ---
> 
>  net/ipv4/tcp_input.c |   10 ++++------
>  1 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index c6f78e2..3cb273a 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -4565,12 +4565,10 @@ merge:
>  	if (skb_headlen(from) == 0 &&
>  	    (skb_shinfo(to)->nr_frags +
>  	     skb_shinfo(from)->nr_frags <= MAX_SKB_FRAGS)) {
> -		WARN_ON_ONCE(from->head_frag);
> -		delta = from->truesize - ksize(from->head) -
> -			SKB_DATA_ALIGN(sizeof(struct sk_buff));
> -
> -		WARN_ON_ONCE(delta < len);
> +		delta = from->truesize -
> +			SKB_TRUESIZE(skb_end_pointer(from) - from->head);
>  copyfrags:
> +		WARN_ON_ONCE(delta < len);
>  		memcpy(skb_shinfo(to)->frags + skb_shinfo(to)->nr_frags,
>  		       skb_shinfo(from)->frags,
>  		       skb_shinfo(from)->nr_frags * sizeof(skb_frag_t));
> @@ -4600,7 +4598,7 @@ copyfrags:
>  		skb_fill_page_desc(to, skb_shinfo(to)->nr_frags,
>  				   page, offset, skb_headlen(from));
>  		*fragstolen = true;
> -		delta = len; /* we dont know real truesize... */
> +		delta = from->truesize - SKB_DATA_ALIGN(sizeof(struct sk_buff));
>  		goto copyfrags;
>  	}
>  	return false;
> 
> --

Acked-by: Eric Dumazet <edumazet@...gle.com>



--
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