From nobody Mon Nov 03 08:39:00 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 4d0Q3n0dc5z6F9qv; Mon, 03 Nov 2025 08:39:01 +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 4d0Q3m63YQz3kVQ; Mon, 03 Nov 2025 08:39:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762159140; 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=P+uEW8SGYLWqRsQ5Mfd8BFzrRAD4a2+1dAYZ3ll18xs=; b=FbDVydWRk71XZp4qIUMIOnY8YWIcFmkDpI8JEivGPT5oywXRPIWAcG/1uCEH08PBItOWV8 8mK7EL+2dv2eGPZudourXIUQPLWRrz1MaRh4965nfBLg2S837o4uPsta4r5P46jhpxnV07 dfjmekNpwfddiKWmlsaslbKGQyyE57vw6yOAookmxKw+Wa9SOcHWJxlxeVdKaIsQri0h0c d3cHeohBdrH+DWXTuCYVvrdWxvpHazrTa8UgGEQqu+jkhiz/uhVA3wr0TJUDtgXnd656jM pUb3NA4I1x6JOb6s7r+AGTtVRatSDlE1cf5nS0aHiC6GnzHNlVVL2EIQxWRbsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1762159140; 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=P+uEW8SGYLWqRsQ5Mfd8BFzrRAD4a2+1dAYZ3ll18xs=; b=gFm7ksL3FmYZov71dh4VjdHfAhABqZ3qQ8xhiyDyYaaGyR0AGXc5NKeqzqS/NNdd84bQgX T/H5/d66pr75xBLIh44PI2diSJ6JPto5gt9GWzLk+zhMsk+PI4VRPDBB33YQproR/JYky7 1ywGWC7iDIy23L+But0LNI1Gn2Jxq42DMYwuKXjkxIppIL8rjYjN4yiThNwIRaJuaVPGWK WgNbneuK0pT1anwl6FwFaR8/iePfVsVvGXwSnVpAZD8zHUtcH9PsdIAaxTf5nv0HarUwUg SNt6n1jMbNvoviHFLeijjvVBs01b0pEKR4WdUXwrh6sgpEV1JrqlrK5FsVe3OQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1762159140; a=rsa-sha256; cv=none; b=cFV5fNVaKGCO6rzt6/c95/fgSThGqnypVIrykTxTa3yrkLQC9DEnb5oafC0LWBQfTovifv 9dzjpNyXKlESmjQeE+35FLtJN5qfzb3UY7Rixj8/TcqbpsaXvCBhCDNn4PqP03lFQQUTsP fuo51h6gcyhAT30X3MGJ+2PzOgB2B6iq29K2RF/USUqDK4rBe/eJeMiS0YfJNKZVxap94A fM9osqalkMwWArpet/W55aNxHCpKoW2PH8Xp9w+JOfXYwyRLirHfxTDFp/fxgGMqfmbezw F4mLizfZRACcE07TTfm6kphu3jHUyMb/ALUKHKfLk9TK4h+0OYt+uKMh1lieug== 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 4d0Q3m5LK8z13tk; Mon, 03 Nov 2025 08:39:00 +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 5A38d0Xi016446; Mon, 3 Nov 2025 08:39:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 5A38d0Kq016443; Mon, 3 Nov 2025 08:39:00 GMT (envelope-from git) Date: Mon, 3 Nov 2025 08:39:00 GMT Message-Id: <202511030839.5A38d0Kq016443@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: 8f92db3cf540 - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 8f92db3cf5405e38f565591d878c7b1b409dc055 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=8f92db3cf5405e38f565591d878c7b1b409dc055 commit 8f92db3cf5405e38f565591d878c7b1b409dc055 Author: Kristof Provost AuthorDate: 2025-10-29 08:28:59 +0000 Commit: Kristof Provost CommitDate: 2025-11-03 08:34:27 +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 | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 6fe84b1be489..cdb0059a5e0e 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -3849,6 +3849,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 152a9678812b..0adfaf59bb8b 100644 --- a/tests/sys/netpfil/pf/ioctl/validation.c +++ b/tests/sys/netpfil/pf/ioctl/validation.c @@ -193,6 +193,37 @@ 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_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) { @@ -923,6 +954,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);