From patchwork Fri Dec 2 20:48:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 128969 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A902D1007D4 for ; Sat, 3 Dec 2011 07:48:12 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755077Ab1LBUsH (ORCPT ); Fri, 2 Dec 2011 15:48:07 -0500 Received: from mail-bw0-f46.google.com ([209.85.214.46]:46760 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754835Ab1LBUsF (ORCPT ); Fri, 2 Dec 2011 15:48:05 -0500 Received: by bkas6 with SMTP id s6so4320580bka.19 for ; Fri, 02 Dec 2011 12:48:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:subject:from:to:cc:date:in-reply-to:references :content-type:x-mailer:content-transfer-encoding:mime-version; bh=dSiFV0vC95OrqVJcWT/Ag0AzwfebnOhULhQsvGnODfI=; b=oEOoyc3frNt1izQQ/0bSAsZ5dxgfpqLKAUS0sEEcf87SxOBEgMV3LKJtKVoq1bQMyg Gd4etwHe0dTeB6lVtVTsxtinchpJrFuXjRAwEF5mwtAAoRRMoTwacPiFisTgibfpomNy tfJGlW3KTkIWPwn9BfVgljwCU+B7qYvsp1f9g= Received: by 10.205.130.1 with SMTP id hk1mr11542379bkc.68.1322858884319; Fri, 02 Dec 2011 12:48:04 -0800 (PST) Received: from [10.170.237.6] ([87.255.129.107]) by mx.google.com with ESMTPS id cc2sm18987968bkb.8.2011.12.02.12.48.02 (version=SSLv3 cipher=OTHER); Fri, 02 Dec 2011 12:48:03 -0800 (PST) Message-ID: <1322858880.2762.69.camel@edumazet-laptop> Subject: Re: Bug in computing data_len in tcp_sendmsg? From: Eric Dumazet To: David Miller Cc: subramanian.vijay@gmail.com, therbert@google.com, netdev@vger.kernel.org Date: Fri, 02 Dec 2011 21:48:00 +0100 In-Reply-To: <1322858756.2762.68.camel@edumazet-laptop> References: <1322850989.2762.47.camel@edumazet-laptop> <20111202.134040.638198723589712419.davem@davemloft.net> <1322857369.2762.63.camel@edumazet-laptop> <20111202.152426.447759025066188323.davem@davemloft.net> <1322858756.2762.68.camel@edumazet-laptop> X-Mailer: Evolution 3.2.1- Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Le vendredi 02 décembre 2011 à 21:45 +0100, Eric Dumazet a écrit : > Le vendredi 02 décembre 2011 à 15:24 -0500, David Miller a écrit : > > From: Eric Dumazet > > Date: Fri, 02 Dec 2011 21:22:49 +0100 > > > > > Le vendredi 02 décembre 2011 à 13:40 -0500, David Miller a écrit : > > > > > >> Yes, for non-SG this always was technically possible. > > >> > > > > > > Yes this can, I reproduced it very easily. > > > > > > I find this hard to believe... > > > > Grrr :-) > > > > Ok, I'll think about this some more. > > Maybe a quick fix would be to trim not len bytes but (len & ~3) bytes ? > > This avoid reallocations and complex code for a 'should never happen in > normal circumstances'... > > Retransmits could transmits 3 bytes already ACKed, is it a big deal ? > > patch on top of linux/net tree : > > diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c > index 63170e2..4e108c5 100644 > --- a/net/ipv4/tcp_output.c > +++ b/net/ipv4/tcp_output.c > @@ -1126,7 +1126,7 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) > > /* If len == headlen, we avoid __skb_pull to preserve alignment. */ > if (unlikely(len < skb_headlen(skb))) > - __skb_pull(skb, len); > + __skb_pull(skb, len & ~3); /* preserve alignement of tcp/ip headers */ > else > __pskb_trim_head(skb, len - skb_headlen(skb)); > > oops, thats the wrong version, here is it again : --- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 63170e2..492b917 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1125,11 +1125,12 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) return -ENOMEM; /* If len == headlen, we avoid __skb_pull to preserve alignment. */ - if (unlikely(len < skb_headlen(skb))) + if (unlikely(len < skb_headlen(skb))) { + len &= ~3; __skb_pull(skb, len); - else + } else { __pskb_trim_head(skb, len - skb_headlen(skb)); - + } TCP_SKB_CB(skb)->seq += len; skb->ip_summed = CHECKSUM_PARTIAL;