Please try the patch in the mail below.

Frank

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Frank Volf wrote:
> 
> Darren,
> 
> I have got two reports related to return-icmp crashing a FreeBSD machine. In
> both cases a recent IP Filter version (3.4.32 and higher) has been used. It
> appears that triggering:
> 
>       block return-icmp in quick on xl1 from any to 1.2.3.4
> 
> should be sufficient to crash it.
> 
> I haven't had to investigate, but of course I will find the time. But before
> I do that, I was wondering if you already have investigated and/or fixed this 
> issue?

Darren,

The crash was due to a freeing of an already freed mbuf. I think I have
solved it, with the patch below (fix in send_ip). There were also some
issues with host and byte order problems in the icmp packet that was
returned these are solved as well.

Please carefully check my patch, because I'm not an mbuf expert, so maybe I
have done something wrong in the house keeping.

Merry xmas to you and your family!

Frank


Index: ip_fil.c
===================================================================
RCS file: /home/cvs/firewall/firewall/usrlocal/ipfilter34/ipfilter3433/ip_fil.c,v
retrieving revision 1.3
diff -u -r1.3 ip_fil.c
--- ip_fil.c    17 Dec 2003 12:33:56 -0000      1.3
+++ ip_fil.c    22 Dec 2003 11:23:28 -0000
@@ -1285,7 +1285,7 @@
        frn.fin_ifp = fin->fin_ifp;
        frn.fin_v = fin->fin_v;
        frn.fin_out = fin->fin_out;
-       frn.fin_mp = fin->fin_mp;
+       frn.fin_mp = mp;
 
        ip = mtod(m, ip_t *);
        hlen = sizeof(*ip);
@@ -1465,7 +1465,13 @@
 #endif
 
        if (avail) {
+               slen = oip->ip_len;
+               oip->ip_len = htons(oip->ip_len);
+               soff = oip->ip_off;
+               oip->ip_off = htons(oip->ip_off);
                bcopy((char *)oip, (char *)&icmp->icmp_ip, MIN(ohlen, avail));
+               oip->ip_len = slen;
+               oip->ip_off = soff;
                avail -= MIN(ohlen, avail);
        }
 
@@ -1486,10 +1492,6 @@
        } else
 #endif
        {
-               slen = oip->ip_len;
-               oip->ip_len = htons(oip->ip_len);
-               soff = oip->ip_off;
-               oip->ip_off = htons(ip->ip_off);
 
                ip->ip_src.s_addr = dst4.s_addr;
                ip->ip_dst.s_addr = oip->ip_src.s_addr;
@@ -1509,13 +1511,7 @@
        fin->fin_hlen = hlen;
        err = send_ip(oip, fin, &m);
        fin->fin_hlen = shlen;
-#ifdef USE_INET6
-       if (fin->fin_v == 4)
-#endif
-       {
-               oip->ip_len = slen;
-               oip->ip_off = soff;
-       }
+
        return err;
 }
 




Reply via email to