[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1322858880.2762.69.camel@edumazet-laptop>
Date: Fri, 02 Dec 2011 21:48:00 +0100
From: Eric Dumazet <eric.dumazet@...il.com>
To: David Miller <davem@...emloft.net>
Cc: subramanian.vijay@...il.com, therbert@...gle.com,
netdev@...r.kernel.org
Subject: Re: Bug in computing data_len in tcp_sendmsg?
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 <eric.dumazet@...il.com>
> > 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 :
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;
--
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