netdev
[Top] [All Lists]

Re: ERRATA Re: [PATCH] fix for netfilter/nat/pppoe crashes (hopefully)

To: Harald Welte <laforge@xxxxxxxxxxxx>
Subject: Re: ERRATA Re: [PATCH] fix for netfilter/nat/pppoe crashes (hopefully)
From: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
Date: Fri, 03 Aug 2001 17:18:45 +1000
Cc: Marc Boucher <marc@xxxxxxx>, Alexey Kuznetsov <kuznet@xxxxxxxxxxxxx>, Dave Miller <davem@xxxxxxxxxx>, netfilter-devel@xxxxxxxxxxxxxxx, netdev@xxxxxxxxxxx
In-reply-to: Your message of "Thu, 02 Aug 2001 07:36:48 -0300." <20010802073648.G1612@obroa-skai.gnumonks.org>
Sender: owner-netdev@xxxxxxxxxxx
In message <20010802073648.G1612@xxxxxxxxxxxxxxxxxxxxxxx> you write:
> - scenario a
> Imagine the case, where we have the first 18 bytes of the tcp header, 

ACK... Your patch is correct.  Was still not thinking about ICMP
packets, and I'm supposed to be working on work stuff at the moment.
I think it's pretty clear to everyone that I don't have time or
resources to maintain this stuff any more.

Have appended my other minor fix.  Dave, please apply...
Rusty.
--
Premature optmztion is rt of all evl. --DK

diff -urN -I \$.*\$ --exclude TAGS -X 
/home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal 
linux-2.4.7-official/net/ipv4/netfilter/ip_conntrack_core.c 
working-2.4.7-marc/net/ipv4/netfilter/ip_conntrack_core.c
--- linux-2.4.7-official/net/ipv4/netfilter/ip_conntrack_core.c Sat Apr 28 
07:15:01 2001
+++ working-2.4.7-marc/net/ipv4/netfilter/ip_conntrack_core.c   Fri Aug  3 
13:29:48 2001
@@ -356,7 +356,7 @@
        inner = (struct iphdr *)(hdr + 1);
        datalen = skb->len - iph->ihl*4 - sizeof(*hdr);
 
-       if (skb->len < iph->ihl * 4 + sizeof(struct icmphdr)) {
+       if (skb->len < iph->ihl * 4 + sizeof(*hdr) + sizeof(*iph)) {
                DEBUGP("icmp_error_track: too short\n");
                return NULL;
        }
--- linux-2.4.7-mb/net/ipv4/netfilter/ip_nat_proto_tcp.c        2001/07/31 
15:37:45     1.1
+++ linux-2.4.7-mb/net/ipv4/netfilter/ip_nat_proto_tcp.c        2001/07/31 
17:35:20
@@ -92,10 +104,17 @@
                oldip = iph->daddr;
                portptr = &hdr->dest;
        }
-       hdr->check = ip_nat_cheat_check(~oldip, manip->ip,
+
+       /* this could be a inner header returned in icmp packet; in such
+          cases we cannot update the checksum field since it is outside of
+          the 8 bytes of transport layer headers we are guaranteed */
+       if(((void *)&hdr->check + sizeof(hdr->check) - (void *)iph) <= len) {
+               hdr->check = ip_nat_cheat_check(~oldip, manip->ip,
                                        ip_nat_cheat_check(*portptr ^ 0xFFFF,
                                                           manip->u.tcp.port,
                                                           hdr->check));
+       }
+
        *portptr = manip->u.tcp.port;
 }
 

<Prev in Thread] Current Thread [Next in Thread>