netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Make udp_encap_rcv use pskb_may_pull
@ 2006-11-23  0:01 Olaf Kirch
  2006-11-23  4:11 ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Olaf Kirch @ 2006-11-23  0:01 UTC (permalink / raw)
  To: netdev; +Cc: linux-kernel


Make udp_encap_rcv use pskb_may_pull

IPsec with NAT-T breaks on some notebooks using the latest e1000 chipset,
when header split is enabled. When receiving sufficiently large packets, the
driver puts everything up to and including the UDP header into the header
portion of the skb, and the rest goes into the paged part. udp_encap_rcv
forgets to use pskb_may_pull, and fails to decapsulate it. Instead, it
passes it up it to the IKE daemon.

Signed-off-by: Olaf Kirch <okir@suse.de>
Signed-off-by: Jean Delvare <jdelvare@suse.de>

 net/ipv4/udp.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

Index: linux-2.6.19-rc6/net/ipv4/udp.c
===================================================================
--- linux-2.6.19-rc6.orig/net/ipv4/udp.c
+++ linux-2.6.19-rc6/net/ipv4/udp.c
@@ -928,24 +928,33 @@ static int udp_encap_rcv(struct sock * s
 	return 1; 
 #else
 	struct udp_sock *up = udp_sk(sk);
-  	struct udphdr *uh = skb->h.uh;
+  	struct udphdr *uh;
 	struct iphdr *iph;
 	int iphlen, len;
   
-	__u8 *udpdata = (__u8 *)uh + sizeof(struct udphdr);
-	__be32 *udpdata32 = (__be32 *)udpdata;
+	__u8 *udpdata;
+	__be32 *udpdata32;
 	__u16 encap_type = up->encap_type;
 
 	/* if we're overly short, let UDP handle it */
-	if (udpdata > skb->tail)
+	len = skb->len - sizeof(struct udphdr);
+	if (len <= 0)
 		return 1;
 
 	/* if this is not encapsulated socket, then just return now */
 	if (!encap_type)
 		return 1;
 
-	len = skb->tail - udpdata;
+	/* If this is a paged skb, make sure we pull up
+	 * whatever data we need to look at. */
+	if (!pskb_may_pull(skb, sizeof(struct udphdr) + min(len, 8)))
+		return 1;
 
+	/* Now we can get the pointers */
+	uh = skb->h.uh;
+	udpdata = (__u8 *)uh + sizeof(struct udphdr);
+	udpdata32 = (__be32 *)udpdata;
+  
 	switch (encap_type) {
 	default:
 	case UDP_ENCAP_ESPINUDP:

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make udp_encap_rcv use pskb_may_pull
  2006-11-23  0:01 [PATCH] Make udp_encap_rcv use pskb_may_pull Olaf Kirch
@ 2006-11-23  4:11 ` David Miller
  2006-11-24 10:54   ` Ingo Oeser
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2006-11-23  4:11 UTC (permalink / raw)
  To: okir; +Cc: netdev, linux-kernel

From: Olaf Kirch <okir@suse.de>
Date: Thu, 23 Nov 2006 01:01:44 +0100

> 
> Make udp_encap_rcv use pskb_may_pull
> 
> IPsec with NAT-T breaks on some notebooks using the latest e1000 chipset,
> when header split is enabled. When receiving sufficiently large packets, the
> driver puts everything up to and including the UDP header into the header
> portion of the skb, and the rest goes into the paged part. udp_encap_rcv
> forgets to use pskb_may_pull, and fails to decapsulate it. Instead, it
> passes it up it to the IKE daemon.
> 
> Signed-off-by: Olaf Kirch <okir@suse.de>
> Signed-off-by: Jean Delvare <jdelvare@suse.de>

Excellent catch, applied, thanks Olaf.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make udp_encap_rcv use pskb_may_pull
  2006-11-23  4:11 ` David Miller
@ 2006-11-24 10:54   ` Ingo Oeser
  2006-11-24 21:35     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Ingo Oeser @ 2006-11-24 10:54 UTC (permalink / raw)
  To: David Miller; +Cc: okir, netdev, linux-kernel

Hi David,

David Miller wrote:
> From: Olaf Kirch <okir@suse.de>
> Date: Thu, 23 Nov 2006 01:01:44 +0100
> 
> > 
> > Make udp_encap_rcv use pskb_may_pull
> 
> Excellent catch, applied, thanks Olaf.

Should this go to -stable, too? Or are these kernels not affected, yet?

Regards

Ingo Oeser

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Make udp_encap_rcv use pskb_may_pull
  2006-11-24 10:54   ` Ingo Oeser
@ 2006-11-24 21:35     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2006-11-24 21:35 UTC (permalink / raw)
  To: netdev; +Cc: okir, netdev, linux-kernel

From: Ingo Oeser <netdev@axxeo.de>
Date: Fri, 24 Nov 2006 11:54:15 +0100

> Hi David,
> 
> David Miller wrote:
> > From: Olaf Kirch <okir@suse.de>
> > Date: Thu, 23 Nov 2006 01:01:44 +0100
> > 
> > > 
> > > Make udp_encap_rcv use pskb_may_pull
> > 
> > Excellent catch, applied, thanks Olaf.
> 
> Should this go to -stable, too? Or are these kernels not affected, yet?

I planned to push this to -stable over the weekend, but thanks for
reminding me anyways.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-24 21:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-23  0:01 [PATCH] Make udp_encap_rcv use pskb_may_pull Olaf Kirch
2006-11-23  4:11 ` David Miller
2006-11-24 10:54   ` Ingo Oeser
2006-11-24 21:35     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).