From owner-freebsd-bugs@FreeBSD.ORG Thu Aug 26 11:40:06 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 430DF1065695 for ; Thu, 26 Aug 2010 11:40:06 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 125D68FC16 for ; Thu, 26 Aug 2010 11:40:06 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o7QBe5vU061092 for ; Thu, 26 Aug 2010 11:40:05 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o7QBe5WF061091; Thu, 26 Aug 2010 11:40:05 GMT (envelope-from gnats) Date: Thu, 26 Aug 2010 11:40:05 GMT Message-Id: <201008261140.o7QBe5WF061091@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: "Jens" Cc: Subject: Re: kern/149937: kernel panic in ipfilter IP fragments with TCP paylaod in reverse order X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jens List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2010 11:40:06 -0000 The following reply was made to PR kern/149937; it has been noted by GNATS. From: "Jens" To: Cc: Subject: Re: kern/149937: kernel panic in ipfilter IP fragments with TCP paylaod in reverse order Date: Thu, 26 Aug 2010 13:23:07 +0200 This is a multi-part message in MIME format. ------=_NextPart_000_004B_01CB4521.D27F8180 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Use this patch instead --- ip_nat.c.orig 2009-04-15 05:14:26.000000000 +0200 +++ ip_nat.c 2010-08-26 13:14:32.000000000 +0200 @@ -3783,7 +3783,16 @@ else if ((nat = nat_outlookup(fin, nflags|NAT_SEARCH, (u_int)fin->fin_p, fin->fin_src, fin->fin_dst))) { nflags = nat->nat_flags; - } else { + } + else if ((fin->fin_p == IPPROTO_TCP) && + ((fin->fin_off != 0) || (fin->fin_flx & FI_SHORT))) + { + /* Discard TCP IP fragmentes without matching NAT rule + (or if fragment lock is set) if offset is nonezero */ + nat = NULL; + nat_stats.ns_badnat++; + } + else { u_32_t hv, msk, nmsk; /* @@ -4078,7 +4087,16 @@ else if ((nat = nat_inlookup(fin, nflags|NAT_SEARCH, (u_int)fin->fin_p, fin->fin_src, in))) { nflags = nat->nat_flags; - } else { + } + else if ((fin->fin_p == IPPROTO_TCP) && + ((fin->fin_off != 0) || (fin->fin_flx & FI_SHORT))) + { + /* Discard TCP IP fragmentes without matching NAT rule + (or if fragment lock is set) if offset is nonezero */ + nat = NULL; + nat_stats.ns_badnat++; + } + else { u_32_t hv, msk, rmsk; RWLOCK_EXIT(&ipf_nat); ------=_NextPart_000_004B_01CB4521.D27F8180 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Use this patch instead

 

--- = ip_nat.c.orig       2009-04-15 = 05:14:26.000000000 +0200

+++ ip_nat.c    2010-08-26 = 13:14:32.000000000 +0200

@@ -3783,7 +3783,16 = @@

        else if ((nat = =3D nat_outlookup(fin, nflags|NAT_SEARCH, (u_int)fin->fin_p,

          =             &= nbsp;           &n= bsp;   fin->fin_src, fin->fin_dst))) {

         &= nbsp;      nflags =3D = nat->nat_flags;

-       } else = {

+       = }

+       else if = ((fin->fin_p =3D=3D IPPROTO_TCP) &&

+          = ;     ((fin->fin_off !=3D 0) || (fin->fin_flx & FI_SHORT)))

+ =       {

+          = ;     /* Discard TCP IP fragmentes without matching NAT rule

+          = ;     (or if fragment lock is set) if offset is nonezero */

+         =       nat =3D NULL;

+         =       nat_stats.ns_badnat++;

+       = }

+       else = {

         &= nbsp;      u_32_t hv, msk, nmsk;

 

         &= nbsp;      /*

@@ -4078,7 +4087,16 @@

        else if = ((nat =3D nat_inlookup(fin, nflags|NAT_SEARCH, (u_int)fin->fin_p,

         &= nbsp;           &n= bsp;           &nb= sp;   fin->fin_src, in))) {

         &= nbsp;      nflags =3D = nat->nat_flags;

-       } else = {

+       = }

+       else if = ((fin->fin_p =3D=3D IPPROTO_TCP) &&

+          = ;     ((fin->fin_off !=3D 0) || (fin->fin_flx & FI_SHORT)))

+       = {

+          = ;     /* Discard TCP IP fragmentes without matching NAT rule

+          = ;     (or if fragment lock is set) if offset is nonezero */

+         =       nat =3D NULL;

+         =       nat_stats.ns_badnat++;

+       = }

+       else = {

         &= nbsp;      u_32_t hv, msk, rmsk;

 

         &= nbsp;      = RWLOCK_EXIT(&ipf_nat);

------=_NextPart_000_004B_01CB4521.D27F8180--