From nobody Wed Nov 18 16:28:39 2026 X-Original-To: dev-commits-src-main@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 4jV6VJ3N3Nz6w4Zp 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 4jV6VH6tb5z4Ppy 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=1795019320; 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=jfLz/sAXuoQR5mxW9qnlmeoXWeeTDyzUr3BDzVVmHoE1RvipQTUki37Z7F4q+oQ+40tMI8 6OM2VJ1RFwAP5000dLOZDPp0gAV4DFQSRgE/6idcqIil1uYtabztYwsFMGUJLiNaTET6Ns hxmuemUkR6fPI55JjlNoxh+ogb6Udv/iwpKEjiyEgXrd90AX1/os79mX7hp1rJOurR9ygn dCLsWFT+Ic9iwLAlwnJIOH7N5EBPh0bHINdsL3TUe6y2oFYHA2GuPEzitOdd7XhnHhKVVZ dRFmMEa4XhQNu/p18cWHOeN51Pf3I3SYPQhsMqLnR/4HJRFLtWx1Ho4mQYvfgw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795019320; b=J36MwafKRUHbnWejqX5hsKwfkFJrhsBqW84PlEHOyvhgrUEOtvOS5NFhTCF+xfL7GbKIbt h/ZcRdYAw4lGiPLOB/zU4PHzKtTwBAYZByzz+hsRxe57cuJ4O26wzygV6eWxFjVc6wSWe4 1lRMcHghvBT9TnzICGo/iEet3+Rcy/abaytRnW+X9eN6Uu1eN0Jdg4JxSJ6t98uTRCrAwI xJJZ0gOO44KDHQXOXvnlTIyFY7nGAV2YSSvXSyAD64iO/l3UsPj4dQZOySkqVXSSJxYt0d Tc1KBdsfDb424MJ6oKIpu0fli6wRgkhwGO91tE6uUUmPW9ejtnn1nc/V7XrLkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795019320; 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=HOlQdvp1zjpd4Ig5EnnS0YQUynIiVkmgGTeD51cGnRT7YvHCM1Ze6cFQsMnSa95PvPiNkK n9pUj0e8gGlGypC9fFT24l95cS3bfeRnuEV/Z36Obg6pSUhrUER0IU8+q4Bdrxu4ZGP29E UtS6WlBEyzBlSChSRsdU1vMNwfjuEXlY6Di0kj/bb9PYdgmaBVEckA4G34AHgKsdWbqLfX FS1JWPVWzujjQr9QIZsqBPOLK/+n6A2HfKO+8zjS6EIUiP9VlD/r+YTacj104MVW90BU2u b0Ze8KqHQPJyRnT6FiKheNbL9voL6NpOxDwfhXnNv+7ko9QX9vSSYYeXLcVNAw== 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 4jV6VH61yqzL6w 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-main X-BeenThere: dev-commits-src-main@freebsd.org List-Id: Commit messages for the main branch 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