From nobody Wed Nov 18 16:28:40 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 4jV6VK21Gvz6w4V7 for ; Wed, 18 Nov 2026 16:28:41 +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 4jV6VJ6tlfz4PV9 for ; Wed, 18 Nov 2026 16:28:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795019321; 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=fPsdbs1hb1nvoc6VdqyWlZD7KvwPDyqzVpwvEpzPzE4=; b=opB2/8ztzo+7+hCxesV4h3b9Gup+CVawuyxhTeKCz0vZ/hXE6n+xa/kaiIkMALdl79szfu b8yfzQlxnJRy83cHjrsZhnMghplYfeX+2X/AmxiXX6vkvXWDyup5YQuvxSHroLJc3qy6uN R3UXQJwXdOmd6DHc5040yVsUDxkS6wE5ti8G9/vKihQESc6a2aQygKCjvNUfB1qHl+yGyF 4gyVfT5xIx3qGTLWrrpIGTc9bh6iBAZnVpcTdXsVScs6KboFMfX7+qxZkYSaqKI8qCK2gW Eq/iwpbZut5WoKhnpyP3BkYgN7gHhb05y06OHe0VPivw7kz9rCQwIRbHcX6VNw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795019321; b=yLH0TDMjaBrgSGWuW+kltbi749TVp/+CbNM0SGt3p5ChNLLLpw9YRMO+P/VdUIYp3YoQB/ KJBLQkPw6bpoRDxN3IU0G/NNlxVqGAxHuqoVauki+z82YswFYD+NYXXVLNRFBzt26E3Xo+ JYNUslWmrgGcSU7uaZyj03A3pyx68s9HB2jSQll9uJTMHG1kPERMqEQSnLZg9dZLh9AQeS ECTzg3uHky6OKqTResUqHpZCJIcPm4eF9tz+vHYFUtuUpHV4jXwO46DwLnDgGEg3tvnySf S2jTNxw3KiPpB8kWw+wx/cPkd0T9e7xYzolQwgdcCdQ97/ry3Sc9I64+OTO+TA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795019321; 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=fPsdbs1hb1nvoc6VdqyWlZD7KvwPDyqzVpwvEpzPzE4=; b=HV+O+5qaGKJRpvKfhJ/iQIEcnh17c0yNHAiy3eiFsQrym9sU/48PvJxM+woQQPcDZZ0I/q n9KnbUrQeerj3eOdaQWP+5QxOCGXk8GVwZHv49UgVHzOGnwE2TQWR4bYpB8ja2sQEwCgEA IRKuQ7PYL7Ec5bstMh0LrpxWrYLR6pggb2OwBbFrOBqIZpQ/GOXU6jumNB/37i5dYc5KBt dBVe1yqGdZZJULCuWP7A3SV3XP5UZ5fDUTdOOU/er3xxdxz5tE/KxqBZ14H4k5DF8Y0TS4 2gLVGgVKElb5gOAyNgPP/v739s59Lw8WX5CPfNJtpNaDQ0kOz4QZre8AhkyIww== 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 4jV6VJ6Gx4zLL7 for ; Wed, 18 Nov 2026 16:28:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 303d by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 18 Nov 2026 16:28:40 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: a396a0218cc5 - main - pf: improve anchor string validation 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: a396a0218cc59cff48547fdf97d9e1a8c306f090 Auto-Submitted: auto-generated Date: Wed, 18 Nov 2026 16:28:40 +0000 Message-Id: <6afdd238.303d.7dbf9e43@gitrepo.freebsd.org> The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=a396a0218cc59cff48547fdf97d9e1a8c306f090 commit a396a0218cc59cff48547fdf97d9e1a8c306f090 Author: Kristof Provost AuthorDate: 2026-11-10 14:54:37 +0000 Commit: Kristof Provost CommitDate: 2026-11-18 16:28:21 +0000 pf: improve anchor string validation Ensure that these are not overly long. Add a test case. Reported by: Kevin Day MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf_table.c | 5 +++-- tests/sys/netpfil/pf/ioctl/validation.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_table.c b/sys/netpfil/pf/pf_table.c index b0bbd3a9f67a..8a97428faafa 100644 --- a/sys/netpfil/pf/pf_table.c +++ b/sys/netpfil/pf/pf_table.c @@ -1878,6 +1878,9 @@ pfr_fix_anchor(char *anchor) size_t siz = MAXPATHLEN; int i; + if (strnlen(anchor, MAXPATHLEN) >= MAXPATHLEN) + return (-1); + if (anchor[0] == '/') { char *path; int off; @@ -1889,8 +1892,6 @@ pfr_fix_anchor(char *anchor) bcopy(path, anchor, siz - off); memset(anchor + siz - off, 0, off); } - if (anchor[siz - 1]) - return (-1); for (i = strlen(anchor); i < siz; i++) if (anchor[i]) return (-1); diff --git a/tests/sys/netpfil/pf/ioctl/validation.c b/tests/sys/netpfil/pf/ioctl/validation.c index bb060e22f3a0..8de07d6506c4 100644 --- a/tests/sys/netpfil/pf/ioctl/validation.c +++ b/tests/sys/netpfil/pf/ioctl/validation.c @@ -1005,6 +1005,38 @@ ATF_TC_CLEANUP(addstate, tc) COMMON_CLEANUP(); } +ATF_TC_WITH_CLEANUP(anchor); +ATF_TC_HEAD(anchor, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); + atf_tc_set_md_var(tc, "require.kmods", "pf"); +} + +ATF_TC_BODY(anchor, tc) +{ + struct pfioc_table io; + struct pfr_table tbl; + + COMMON_HEAD(); + + memset(&tbl, 0, sizeof(tbl)); + memset(&io, '/', sizeof(io)); /* anchor + name all slashes */ + io.pfrio_esize = sizeof(struct pfr_table); + io.pfrio_size = 1000; + io.pfrio_flags = PFR_FLAG_ALLRSETS; + io.pfrio_buffer = &tbl; + + ATF_CHECK_ERRNO(EINVAL, ioctl(dev, DIOCRGETTABLES, &io) == -1); + + io.pfrio_table.pfrt_anchor[MAXPATHLEN - 1] = 0; + ATF_CHECK(ioctl(dev, DIOCRGETTABLES, &io) == 0); +} + +ATF_TC_CLEANUP(anchor, tc) +{ + COMMON_CLEANUP(); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, addtables); @@ -1032,6 +1064,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, rpool_mtx2); ATF_TP_ADD_TC(tp, natlook); ATF_TP_ADD_TC(tp, addstate); + ATF_TP_ADD_TC(tp, anchor); return (atf_no_error()); }