From nobody Wed Nov 18 16:28:41 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 4jV6VL29kqz6w4XL for ; Wed, 18 Nov 2026 16:28:42 +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 4jV6VL0RnSz4PkV for ; Wed, 18 Nov 2026 16:28:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795019322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=u/vbUkpukhNBpsMrxTmN18pVJ7iVGfs/Q90su8EZqvU=; b=vpWOBesF2M1eJoPPRXYhIfEzz1nmdnT4sclMQzLCFxa7Zg9HV5+qxrILtrPruu0ppb/eIv Fmpv4QLX/1qXzbP886VzVtBL+86IpkGO+XWmzbamQmM+vx4tmiRRGWBP0Ubmw3Zh9IpkgR cTFMIACEXz71CqCZj1u/9YOVHz5aO/XZpA18Hr4rUBoJ1Buj0Lgzv9D/wL5f4v+OoZN7kW Ho4/8oxfetTl5KkP76uCbM6OSG8jtjjyPh0lyin5Bwyt+3acP3L88XcSQ/hlC9JRlEo7WT KkwRjr1I99FcEBQrP24SjpoTnXMROBbgxzZr013Cub2mWs683V9MKbmgU2ahnw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795019322; b=oI1S71MLsxMKyWh13dOJmyp4FBgydPi+CfwPQMbHNPkW4ifS/ipi/I3QxrU8CdMuMgDkeI pn931hG6Sp9D/MQsxYwcXlphB5Pi7V7PkcRyikaXIo0jLvXGx2nXs2ZlMXGWbHVBXyzOEO UgurZl8a9yNSiT58+WUpVZGUv21L+hWfeNMBX4+eRBTXrDkGWefQMNPqEY5VqojUJOoUpn 53mnUVWkwpD4EzoWMw1kJc0jIYQEH/JbdGhMV3FM0BV9toUj29PIhkptX08/C1ih4w2T1U 3JL14WPC66iDrm36PSNRlKVbLfrGXsorquw/379+aBEZ4JcUUTNGfil5H/DdAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795019322; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=u/vbUkpukhNBpsMrxTmN18pVJ7iVGfs/Q90su8EZqvU=; b=AQb2EYmLVqyczgl0NQ77HW7VmzSy/dpxAHPqJhf6ycMAICRrG7BmMdk+pCakYXd1v60ctD dhFlRfPDWXtNFmDB4IB9oeuzYpL7Sqd3RRyb4llDw0Nst6JE+hgs8e7CoPer30oGRXYisP fhSVxrPnRmyRtSyTN1oXDt9uBkovKH6GdMMrTQqTqbur79PgmyLAsDN41O9tOs8FyMSMHu 215O6MLKZhWyOWAJ4DfCKYU1U7NJor1wMxyvkLvD4/OcPHdkVKRk8S4ev6XBHhJoXWxDAs HKTKLuy/UZ/VjQD1iL/kAy1MZtaDM50yDEdtIAMY8JPX22yiwJpe/eRjJCzugQ== 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 4jV6VK6bkwzLZh for ; Wed, 18 Nov 2026 16:28:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 2776 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 18 Nov 2026 16:28:41 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Cc: Osvaldo Janeri Filho From: Kristof Provost Subject: git: 53e0d3fb3bcd - main - pf: reject table anchors with empty path components 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: 53e0d3fb3bcd980ba919106abaaf55ac901ecc58 Auto-Submitted: auto-generated Date: Wed, 18 Nov 2026 16:28:41 +0000 Message-Id: <6afdd239.2776.565c3fba@gitrepo.freebsd.org> The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=53e0d3fb3bcd980ba919106abaaf55ac901ecc58 commit 53e0d3fb3bcd980ba919106abaaf55ac901ecc58 Author: Osvaldo Janeri Filho AuthorDate: 2026-11-18 10:25:39 +0000 Commit: Kristof Provost CommitDate: 2026-11-18 16:28:21 +0000 pf: reject table anchors with empty path components pfr_fix_anchor() strips leading slashes from table anchors but not trailing or repeated ones. pf_find_or_create_kruleset() ignores those, so a table added as "foo/bar/" lands in ruleset "foo/bar" but keeps "foo/bar/" as its anchor. pfr_table_count() and pfr_skip_table() then disagree, and with INVARIANTS: ``` panic: pfr_get_tables: corruption detected (1) ``` "foo//bar" does the same once "foo" exists, and pfctl -vsT hits the same check in pfr_get_tstats(). Loading rules into such an anchor already fails with EINVAL, since pf_find_kruleset() doesn't find it. Reject it for tables as well. Reviewed by: kp MFC after: 1 week Sponsored by: Advanced Micro Devices, Inc. Signed-off-by: Osvaldo Janeri Filho Differential Revision: https://reviews.freebsd.org/D61409 --- sys/netpfil/pf/pf_table.c | 7 +++++++ tests/sys/netpfil/pf/table.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/sys/netpfil/pf/pf_table.c b/sys/netpfil/pf/pf_table.c index 8a97428faafa..84df199ecb65 100644 --- a/sys/netpfil/pf/pf_table.c +++ b/sys/netpfil/pf/pf_table.c @@ -1895,6 +1895,13 @@ pfr_fix_anchor(char *anchor) for (i = strlen(anchor); i < siz; i++) if (anchor[i]) return (-1); + /* + * Ruleset paths have no empty components. A table anchor with one + * would not match the path of the ruleset the table is attached to. + */ + if (strstr(anchor, "//") != NULL || + (anchor[0] != '\0' && anchor[strlen(anchor) - 1] == '/')) + return (-1); return (0); } diff --git a/tests/sys/netpfil/pf/table.sh b/tests/sys/netpfil/pf/table.sh index 2b7c84032d41..aa1620627aee 100644 --- a/tests/sys/netpfil/pf/table.sh +++ b/tests/sys/netpfil/pf/table.sh @@ -619,6 +619,37 @@ anchor_cleanup() pft_cleanup } +atf_test_case "anchor_slash" "cleanup" +anchor_slash_head() +{ + atf_set descr 'Test tables in anchors with empty path components' + atf_set require.user root +} + +anchor_slash_body() +{ + pft_init + + atf_check -s exit:0 -e ignore \ + pfctl -a foo/bar -t t1 -T add 192.0.2.1 + atf_check -s exit:0 -e ignore -o match:"192.0.2.1" \ + pfctl -a /foo/bar -t t1 -T show + + atf_check -s not-exit:0 -e ignore \ + pfctl -a foo/bar/ -t t2 -T add 192.0.2.2 + atf_check -s not-exit:0 -e ignore \ + pfctl -a foo//bar -t t3 -T add 192.0.2.3 + + # Used to trip the corruption check in pfr_get_tables() + atf_check -s exit:0 -e ignore -o inline:"t1@foo/bar\n" \ + pfctl -a foo/bar -sT +} + +anchor_slash_cleanup() +{ + pft_cleanup +} + atf_test_case "flush" "cleanup" flush_head() { @@ -1156,6 +1187,7 @@ atf_init_test_cases() atf_add_test_case "pr259689" atf_add_test_case "precreate" atf_add_test_case "anchor" + atf_add_test_case "anchor_slash" atf_add_test_case "flush" atf_add_test_case "large" atf_add_test_case "show_recursive"