Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 20 Aug 2011 13:17:47 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r225032 - head/sys/netinet/ipfw
Message-ID:  <201108201317.p7KDHlUx053378@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bz
Date: Sat Aug 20 13:17:47 2011
New Revision: 225032
URL: http://svn.freebsd.org/changeset/base/225032

Log:
  ipfw internally checks for offset == 0 to determine whether the
  packet is a/the first fragment or not.  For IPv6 we have added the
  "more fragments" flag as well to be able to determine on whether
  there will be more as we do not have the fragment header avaialble
  for logging, while for IPv4 this information can be derived directly
  from the IPv4 header.  This allowed fragmented packets to bypass
  normal rules as proper masking was not done when checking offset.
  Split variables to not need masking for IPv6 to avoid further errors.
  
  PR:		kern/145733
  Submitted by:	Matthew Luckie (mjl luckie.org.nz)
  MFC after:	2 weeks
  Approved by:	re (kib)

Modified:
  head/sys/netinet/ipfw/ip_fw2.c

Modified: head/sys/netinet/ipfw/ip_fw2.c
==============================================================================
--- head/sys/netinet/ipfw/ip_fw2.c	Sat Aug 20 13:07:29 2011	(r225031)
+++ head/sys/netinet/ipfw/ip_fw2.c	Sat Aug 20 13:17:47 2011	(r225032)
@@ -877,17 +877,14 @@ ipfw_chk(struct ip_fw_args *args)
 	 *	we have a fragment at this offset of an IPv4 packet.
 	 *	offset == 0 means that (if this is an IPv4 packet)
 	 *	this is the first or only fragment.
-	 *	For IPv6 offset == 0 means there is no Fragment Header or there
-	 *	is a single packet fragement (fragement header added without
-	 *	needed).  We will treat a single packet fragment as if there
-	 *	was no fragment header (or log/block depending on the
+	 *	For IPv6 offset|ip6f_mf == 0 means there is no Fragment Header
+	 *	or there is a single packet fragement (fragement header added
+	 *	without needed).  We will treat a single packet fragment as if
+	 *	there was no fragment header (or log/block depending on the
 	 *	V_fw_permit_single_frag6 sysctl setting).
-	 *	If offset != 0 for IPv6 always use correct mask to
-	 *	get the correct offset because we add IP6F_MORE_FRAG to be able
-	 *	to dectect the first of multiple fragments which would
-	 *	otherwise have offset = 0.
 	 */
 	u_short offset = 0;
+	u_short ip6f_mf = 0;
 
 	/*
 	 * Local copies of addresses. They are only valid if we have
@@ -1046,12 +1043,10 @@ do {								\
 				proto = ((struct ip6_frag *)ulp)->ip6f_nxt;
 				offset = ((struct ip6_frag *)ulp)->ip6f_offlg &
 					IP6F_OFF_MASK;
-				/* Add IP6F_MORE_FRAG for offset of first
-				 * fragment to be != 0 if there shall be more. */
-				offset |= ((struct ip6_frag *)ulp)->ip6f_offlg &
+				ip6f_mf = ((struct ip6_frag *)ulp)->ip6f_offlg &
 					IP6F_MORE_FRAG;
 				if (V_fw_permit_single_frag6 == 0 &&
-				    offset == 0) {
+				    offset == 0 && ip6f_mf == 0) {
 					printf("IPFW2: IPV6 - Invalid Fragment "
 					    "Header\n");
 					if (V_fw_deny_unknown_exthdrs)
@@ -1687,7 +1682,7 @@ do {								\
 
 			case O_LOG:
 				ipfw_log(f, hlen, args, m,
-					    oif, offset, tablearg, ip);
+				    oif, offset | ip6f_mf, tablearg, ip);
 				match = 1;
 				break;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201108201317.p7KDHlUx053378>