From nobody Wed Nov 18 16:28:39 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jV6VJ3NRZz6w4SJ for ; Wed, 18 Nov 2026 16:28:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jV6VH6blNz4PXL for ; Wed, 18 Nov 2026 16:28:39 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795019319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tivPA3TpUJ22RE9u/YzI8IOt8XKtYwKBV7tsuchBva8=; b=V9DDNRxlK6KwSzc++f/ywTEaNugLssk5qBj8+xW3cZ+jufIjvNR0XnA5O4xZ6NDEYFYyf+ W+AgWas3B7T2x6DsfZeI4djK5RccYS7aXPmi8JhuwHJYacI4/fvektf+/6ksul3Oemz1aG 4zRBqqMPcttLTDpbFkT/p5DehgF83xTkOPBb6UR7f9sHAg+KxLy3JS+lEByVNta3CdxmX4 p6qr9baKw+VDXh6ldQ/hcfFPxUeSd+Qc2IuTUNI7g5MTVI0mAFfQ334+4eDPIhOtzE5+rH z4P39mXpFEVbjpXi6nV0FnBlCFiI3IawQxIPK6nejMZTc3bh7GM3e0y27yk7Ng== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795019319; b=thu8Nvg7q+u/23fXnrFBsud4FF1vTLNY3eOF8w0COMsZEXGhRcVUjTrPLm3RaL5+3wYDNx QXY5+O/mfKbSUaFLWQ9LH+6nbKxMlY5raHgxxYZwvwPqo3eaQSGF21NYJogHi06XgQ5gY0 2cApAH7mmuILbWk49xyzSDSplDwZyHuOvGteU+PCXAjISEBEAaUpAgpkLQQ+wi1A7eDXz8 ZsrR6SO1zgm+uXuZT3AByOrhuO6sseG3f/L7CPdvpy20tlTtO0Mid8UdLd6IOyX0imIorH HzsIPmy9k2F+NEdWOE1zflaTg/EV4Dz1edkRtN7KpfFg+k53O9iIyXw38/Yh4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795019319; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tivPA3TpUJ22RE9u/YzI8IOt8XKtYwKBV7tsuchBva8=; b=u3Vfel4GcuzQQIWuqONW6JhtPrVnOepxPuwqQsD/dR0K3B50DRXethvHNPqlypeHFTieoy ctQS5/JZHk9nLwG7tRcuc7w/wrP3DZVEKM68zrrlHFdkFodlt008ebwuYaNtWm7QY3MtMg DS08sWdWcQeTs730hBQejmYd060dXantxy1veAfGymP0aeIlC+mo/6458SOAQXB54Q4MYR pVhQw9Vp7PZQfTgDczN5B9dqUw6Fa3FNHqDRfg6w+xnLOIIHnC4vNzQI/Gf5PPoPRZQe6r YO2taHn2D/tsc9eZtqPWEsTJJtBaMQCDNtsIAGYf7/iJJKKFN7ql5lcCPkVRaw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jV6VH60nkzLXB for ; Wed, 18 Nov 2026 16:28:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2770 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 18 Nov 2026 16:28:39 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 42bf1d9e83c8 - main - pf: implement RFC 7112 Section 5 List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 42bf1d9e83c85c3f3bc1bf85dc7f655676b1f35a Auto-Submitted: auto-generated Date: Wed, 18 Nov 2026 16:28:39 +0000 Message-Id: <6afdd237.2770.4b3a7598@gitrepo.freebsd.org> The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=42bf1d9e83c85c3f3bc1bf85dc7f655676b1f35a commit 42bf1d9e83c85c3f3bc1bf85dc7f655676b1f35a Author: Kristof Provost AuthorDate: 2026-11-10 12:26:12 +0000 Commit: Kristof Provost CommitDate: 2026-11-18 16:28:21 +0000 pf: implement RFC 7112 Section 5 RFC 7112 Section 5 and RFC 8200 Section 4.5 require IPv6 fragmented packets to contain all headers in the first fragment. If this is not the case we now discard the packet. We do not send the ICMPv6 Parameter Problem error RFC 8200 requires (but 7112 lists this as "MAY"). This makes bypassing the firewall, in cases where fragment reassembly is disabled, harder. RelNotes: yes Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 36 ++++++++----------------------- tests/sys/netpfil/pf/frag6.py | 50 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 2d4efbe1e3e8..6601763d4b51 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -11014,12 +11014,6 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason) REASON_SET(reason, PFRES_IPOPTIONS); return (PF_DROP); } - /* fragments may be short */ - if (pd->fragoff != 0 && end < pd->off + sizeof(rthdr)) { - pd->off = pd->fragoff; - pd->proto = IPPROTO_FRAGMENT; - return (PF_PASS); - } if (!pf_pull_hdr(pd->m, pd->off, &rthdr, sizeof(rthdr), reason, AF_INET6)) { DPFPRINTF(PF_DEBUG_MISC, "IPv6 short rthdr"); @@ -11046,12 +11040,6 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason) DPFPRINTF(PF_DEBUG_MISC, "IPv6 short exthdr"); return (PF_DROP); } - /* fragments may be short */ - if (pd->fragoff != 0 && end < pd->off + sizeof(ext)) { - pd->off = pd->fragoff; - pd->proto = IPPROTO_FRAGMENT; - return (PF_PASS); - } /* reassembly needs the ext header before the frag */ if (pd->fragoff == 0) pd->extoff = pd->off; @@ -11066,11 +11054,6 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason) else extlen = (ext.ip6e_len + 1) * 8; if (end < pd->off + extlen) { - if (pd->fragoff != 0) { - pd->off = pd->fragoff; - pd->proto = IPPROTO_FRAGMENT; - return (PF_PASS); - } DPFPRINTF(PF_DEBUG_MISC, "IPv6 long exthdr"); REASON_SET(reason, PFRES_SHORT); return (PF_DROP); @@ -11079,12 +11062,6 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason) pd->proto = ext.ip6e_nxt; break; case IPPROTO_ICMPV6: - /* fragments may be short, ignore inner header then */ - if (pd->fragoff != 0 && end < pd->off + sizeof(icmp6)) { - pd->off = pd->fragoff; - pd->proto = IPPROTO_FRAGMENT; - return (PF_PASS); - } if (!pf_pull_hdr(pd->m, pd->off, &icmp6, sizeof(icmp6), reason, AF_INET6)) { DPFPRINTF(PF_DEBUG_MISC, @@ -11125,14 +11102,19 @@ pf_walk_header6(struct pf_pdesc *pd, struct ip6_hdr *h, u_short *reason) case IPPROTO_TCP: case IPPROTO_UDP: case IPPROTO_SCTP: - /* fragments may be short, ignore inner header then */ - if (pd->fragoff != 0 && end < pd->off + + /* If we don't have a full header */ + if (end < pd->off + (pd->proto == IPPROTO_TCP ? sizeof(struct tcphdr) : pd->proto == IPPROTO_UDP ? sizeof(struct udphdr) : pd->proto == IPPROTO_SCTP ? sizeof(struct sctphdr) : sizeof(struct icmp6_hdr))) { - pd->off = pd->fragoff; - pd->proto = IPPROTO_FRAGMENT; + /* + * The first fragment must contain a full header.. + * See RFC 7112 Section 5 and + * RFC 8200 Section 4.5 + */ + REASON_SET(reason, PFRES_SHORT); + return (PF_DROP); } /* FALLTHROUGH */ default: diff --git a/tests/sys/netpfil/pf/frag6.py b/tests/sys/netpfil/pf/frag6.py index ca2d231edccb..abcc0135e3b0 100644 --- a/tests/sys/netpfil/pf/frag6.py +++ b/tests/sys/netpfil/pf/frag6.py @@ -1,6 +1,7 @@ import pytest import logging import random +import socket logging.getLogger("scapy").setLevel(logging.CRITICAL) from utils import DelayedSend from atf_python.sys.net.tools import ToolsHelper @@ -273,3 +274,52 @@ class TestFrag6_RouteTo(VnetTestTemplate): assert err_ip6 assert err_ip6.src == "2001:db8::1" assert err_ip6.dst == "2001:db8:666::1" + +class TestFrag6NoReassembly(VnetTestTemplate): + REQUIRED_MODULES = ["pf"] + TOPOLOGY = { + "vnet1": {"ifaces": ["if1"]}, + "vnet2": {"ifaces": ["if1"]}, + "if1": {"prefixes6": [("2001:db8::1/64", "2001:db8::2/64")]}, + } + + def vnet2_handler(self, vnet): + ifname = vnet.iface_alias_map["if1"].name + ToolsHelper.print_output("/sbin/pfctl -e") + ToolsHelper.pf_rules([ + "scrub in on lo0 from 2001:db8::99 to any", # just to put pf into scrub compat mode + "pass", + "block in inet6 proto tcp from any to port 1234", + ]) + + @pytest.mark.require_user("root") + @pytest.mark.require_progs(["scapy"]) + def test_tcp(self): + import scapy.all as sp + + # This gets dropped by pf, because it blocks port 1234 + packet = sp.IPv6(src="2001:db8::1", dst="2001:db8::2") \ + / sp.TCP(dport=1234, flags="S") + reply = sp.sr1(packet, timeout=3) + assert reply is None + + # However, if we fragment the SYN... + frags = sp.fragment6(packet, 60) + frags[0].show() + frags[1].show() + assert len(frags) == 2 + + s = DelayedSend(frags) + + replies = sp.sniff(iface=self.vnet.iface_alias_map["if1"].name, + timeout=3) + for p in replies: + if not sp.IPv6 in p: + continue + ip6 = p[sp.IPv6] + if ip6.dst != "2001:db8::1": + continue + + # We should not get a TCP RST here + p.show() + assert ip6.nh != socket.IPPROTO_TCP