From nobody Mon Nov 03 08:39:04 2025 X-Original-To: dev-commits-src-branches@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 4d0Q3r5vTQz6F9jL; Mon, 03 Nov 2025 08:39:04 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d0Q3r3jwLz3kkF; Mon, 03 Nov 2025 08:39:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762159144; 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=lWA4oM+rXCWFICGdwP+/ovhP0VHsgqdbM1BXdWZx++E=; b=oBkXkgKQakToHAR9kRXe20zFHMZushMwzcNasxyfaZbfaV0fG779wHEtkrxdXkjXigoM8B 12n7CnfmND+Y0Tvy3ATC45wYC1bhG0+t0kAYE5oq1dS/VybIfZv/su3IxeRMRuoluEp5vm 5QhBWzubkn4b+ZIIOTmtOxQMncBfgrZ1VxME6KNp11F/jKrp18tILJmVX1Q8nwRwcjtb/6 LspmSF60skWX9PnVVaj+lHQxwx8Xfmu7WrvtuVuzdv6ylqYqm4NUKVRpG7h3GG8+KnIkVH NC/c68CM2hOeOa5XzDSsv3KF21zGN31hatgQfT6p8uXbV/AnkJQZY4EAhfyOGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762159144; 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=lWA4oM+rXCWFICGdwP+/ovhP0VHsgqdbM1BXdWZx++E=; b=meF007foVr7BJ8gVJa9MJyFQuqRRZDFss+iza1WpoM9fQ3E3ZM1AU3d8og6IF6HTjy1X9p JopSVd31u2SVmXwKqoNIbk9JNHzC3laM98S3efwNSm9d3YTOVMT7NDhINwM6U1pIKER79x 00ZVs9tZMzVzyauW1YOstfSr6v0kxcQCPm3Ix6WWdoZclv7hPlVmQZfocLIMFLRqGaaGtz IHT3k7ZFGwunaH2N9NHKBfLnnAo5R/vRYdexo+61mpZmkvGGwzGo1wCQUwM+IhujWXpU12 1uYZ6OnI4pk83x9y7g4XXS83nfQZau4s2ST0aO9TzeGfctDU+mCCMfuOYMgdTw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762159144; a=rsa-sha256; cv=none; b=u3CYYx3/l24knfRdTM9/rlks4N3Hkoy1T6Oygu81+LWJjPqBufteE/XsEgeWVXLzc7NYwg ABRbfaeKndgkQzIhHhZOFsUtHsZTf08gBjC4YrGfzOULK2lvIhBrg+N6z19tPv2SBc2chw dRBWXCFXGdvIUkOpC+yY4NeMqFoS9tTDHweSbvw7tZpcMoXfthKu34zNDXq/Wj+OLqr+qC ZICPG156Ntb+XL6IzYNPolP3tn/TykH/l1fAACC9eLCbSpJCVGx/F4ZoY5i3tpFoKQlyWt 01JIfA7eKTNjdrth3pwhz/OCCnxwFVXNm7hEmOpfCzexfae1qLPY7vWCH7ASsQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4d0Q3r2Z19z13Jj; Mon, 03 Nov 2025 08:39:04 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 5A38d4Q1016646; Mon, 3 Nov 2025 08:39:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5A38d4wd016643; Mon, 3 Nov 2025 08:39:04 GMT (envelope-from git) Date: Mon, 3 Nov 2025 08:39:04 GMT Message-Id: <202511030839.5A38d4wd016643@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: d481c3db42dc - stable/14 - pf: improve DIOCRCLRTABLES validation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org 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/stable/14 X-Git-Reftype: branch X-Git-Commit: d481c3db42dc59bbe679ecc5aead161a8739466b Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=d481c3db42dc59bbe679ecc5aead161a8739466b commit d481c3db42dc59bbe679ecc5aead161a8739466b Author: Kristof Provost AuthorDate: 2025-10-29 08:28:59 +0000 Commit: Kristof Provost CommitDate: 2025-11-02 14:06:45 +0000 pf: improve DIOCRCLRTABLES validation Unterminated strings in the anchor or name could cause crashes. Validate them, and add a test case. Reported by: Ilja Van Sprundel MFC after: 3 days Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 1da3c0ca5b1decaa9cf55859cd134bdcd1218116) --- sys/netpfil/pf/pf_ioctl.c | 11 +++++++++++ tests/sys/netpfil/pf/ioctl/validation.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index d95f36d06ee3..cf53ea638095 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -4645,6 +4645,17 @@ DIOCCHANGEADDR_error: error = ENODEV; break; } + if (strnlen(io->pfrio_table.pfrt_anchor, MAXPATHLEN) + == MAXPATHLEN) { + error = EINVAL; + goto fail; + } + if (strnlen(io->pfrio_table.pfrt_name, PF_TABLE_NAME_SIZE) + == PF_TABLE_NAME_SIZE) { + error = EINVAL; + goto fail; + } + PF_RULES_WLOCK(); error = pfr_clr_tables(&io->pfrio_table, &io->pfrio_ndel, io->pfrio_flags | PFR_FLAG_USERIOCTL); diff --git a/tests/sys/netpfil/pf/ioctl/validation.c b/tests/sys/netpfil/pf/ioctl/validation.c index b18e30e5e6af..651e6837acd7 100644 --- a/tests/sys/netpfil/pf/ioctl/validation.c +++ b/tests/sys/netpfil/pf/ioctl/validation.c @@ -193,6 +193,38 @@ ATF_TC_CLEANUP(gettables, tc) COMMON_CLEANUP(); } +ATF_TC_WITH_CLEANUP(clrtables); +ATF_TC_HEAD(clrtables, tc) +{ + atf_tc_set_md_var(tc, "require.user", "root"); + atf_tc_set_md_var(tc, "require.kmods", "pf"); +} + +ATF_TC_BODY(clrtables, tc) +{ + struct pfioc_table io; + struct pfr_table tbl; + int flags; + + COMMON_HEAD(); + + flags = 0; + + memset(&io, '/', sizeof(io)); + io.pfrio_flags = flags; + io.pfrio_buffer = &tbl; + io.pfrio_esize = 0; + io.pfrio_size = 1; + + if (ioctl(dev, DIOCRCLRTABLES, &io) == 0) + atf_tc_fail("Request with unterminated anchor name succeeded"); +} + +ATF_TC_CLEANUP(clrtables, tc) +{ + COMMON_CLEANUP(); +} + ATF_TC_WITH_CLEANUP(gettstats); ATF_TC_HEAD(gettstats, tc) { @@ -924,6 +956,7 @@ ATF_TP_ADD_TCS(tp) ATF_TP_ADD_TC(tp, addtables); ATF_TP_ADD_TC(tp, deltables); ATF_TP_ADD_TC(tp, gettables); + ATF_TP_ADD_TC(tp, clrtables); ATF_TP_ADD_TC(tp, getastats); ATF_TP_ADD_TC(tp, gettstats); ATF_TP_ADD_TC(tp, clrtstats);