netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Fix checksum bug for multicast/broadcast packets on postrouting hook
@ 2004-02-14 18:37 James Morris
  2004-02-14 18:37 ` Harald Welte
  2004-02-14 19:07 ` Mika Penttilä
  0 siblings, 2 replies; 18+ messages in thread
From: James Morris @ 2004-02-14 18:37 UTC (permalink / raw)
  To: David S. Miller, Harald Welte; +Cc: netdev, Stephen Smalley

This patch fixes a bug with with multicast/broadcast packets,
Netfilter, and NICs which do hardware checksums.

Outgoing multicast and broadcast packets are cloned prior to being fed
into the postrouting hook and looped back.  A problem is caused when the
shared packet data is modified by the netfilter core code when updating
the checksum, but the skb->ip_summed field in the header of the original
skb is not updated.  The NIC then tries to do a hardware checksum on an
already correct checksum, and we end up transmitting the wrong thing.

This bug stops things like DHCP from working, and was noted under SELinux
which uses the postrouting hook alone.

The proposed solution below is to copy the skb rather than clone it, to 
ensure that the original and looped back packets are independent.

Please review.

(A similar problem seems to exist in the IPv6 code, although not 
verified yet).


- James
-- 
James Morris
<jmorris@redhat.com>


diff -urN -X dontdiff linux-2.6.3-rc2-mm1.o/net/ipv4/ip_output.c linux-2.6.3-rc2-mm1.w2/net/ipv4/ip_output.c
--- linux-2.6.3-rc2-mm1.o/net/ipv4/ip_output.c	2004-02-03 22:45:00.000000000 -0500
+++ linux-2.6.3-rc2-mm1.w2/net/ipv4/ip_output.c	2004-02-14 13:04:20.880941816 -0500
@@ -254,7 +254,7 @@
 		    && ((rt->rt_flags&RTCF_LOCAL) || !(IPCB(skb)->flags&IPSKB_FORWARDED))
 #endif
 		) {
-			struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
+			struct sk_buff *newskb = skb_copy(skb, GFP_ATOMIC);
 			if (newskb)
 				NF_HOOK(PF_INET, NF_IP_POST_ROUTING, newskb, NULL,
 					newskb->dev, 
@@ -270,7 +270,7 @@
 	}
 
 	if (rt->rt_flags&RTCF_BROADCAST) {
-		struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC);
+		struct sk_buff *newskb = skb_copy(skb, GFP_ATOMIC);
 		if (newskb)
 			NF_HOOK(PF_INET, NF_IP_POST_ROUTING, newskb, NULL,
 				newskb->dev, ip_dev_loopback_xmit);

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

end of thread, other threads:[~2004-02-29  5:50 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-14 18:37 [PATCH] Fix checksum bug for multicast/broadcast packets on postrouting hook James Morris
2004-02-14 18:37 ` Harald Welte
2004-02-14 19:07 ` Mika Penttilä
2004-02-14 23:00   ` David S. Miller
2004-02-15  6:09   ` James Morris
2004-02-15  9:34     ` Mika Penttilä
2004-02-15 13:03       ` James Morris
2004-02-15 13:40         ` Mika Penttilä
2004-02-15 14:03           ` James Morris
2004-02-15 16:00             ` Mika Penttilä
2004-02-16  1:50               ` James Morris
2004-02-16  6:43                 ` Mika Penttilä
2004-02-16 13:45                   ` James Morris
2004-02-19  1:24                     ` David S. Miller
2004-02-23 22:19                       ` James Morris
2004-02-29  5:50                         ` David S. Miller
2004-02-17 15:54     ` Harald Welte
2004-02-17 20:35       ` James Morris

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