From nobody Fri Oct 30 12:21:41 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 4jGKw54DrJz6wmBr for ; Fri, 30 Oct 2026 12:21: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 4jGKw50nmRz4VCS for ; Fri, 30 Oct 2026 12:21:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793362901; 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=p6+DreP1EJ6DaKqcQySBIMVA+Yd/IvjSgSYvFL929wE=; b=pIqvefrvOy79IO3QUKrt5tJvb/YRsjmdwqqQR6XhlqHXKUVc5iKiLirxh/XBRxMovfErBD LuU4wGBUzyCpmnjhdJpfYa6+NHydYGbN7yGBtk51K/wab76i3ROt7sBayfmCdpyi1hilhV 5rfw+5N+98xGPCL8a6tAHFmN5ptcJKjrcWkhOMquWf7XcElhNIeoio4HoLOxa81S2zavoT PVjI7I4GqufPkTeSxDc0Rz1b5qRRANeBf6BU6Ulyy+zWdAPLgr6U5fgtlcb/fuaYehoSSB CviBLAAYwRyQLsV028rgoi8zOFobfUCj7WNQ9ut3XxZc+yYioYrBC2tJ4NjjhA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793362901; b=veijGhoJPqDvjtULJfhCykUmnD4B+FVxH4KB5dNxvdn7bIGmZaUCtvkQaL1YkKjirzv1L5 mkQpLlgV8yGwfOS/gom/GlgZcerCXqxRYG3yhMdaajVLZNwF+7aHb2xIAzR9EDmz0w5VKL sawDwSrvVBH7C5adTvAIx+LlsxgtDuZIWa0Q+21sO0iBuN3waeNVsuYzOOIOc3p64y3xRT DUC7Q0U66KKGdmdFReEoCfM/LiI1B7uFVI73IcrqizDu3WWFTj9x8RbC/CrYVRoJ3xyMoS 88n7ANIUYiIWopGTDiEKY+vV22Wd/GCnWIj32ioSAN7duK9pnIYguSYpohgOAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793362901; 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=p6+DreP1EJ6DaKqcQySBIMVA+Yd/IvjSgSYvFL929wE=; b=tmmsqDBoAmYM5KKxvRe4yjoZVtmSBW/L1GRk1hcv7gWTo8HxU8lIzKWdRBv1oVEx7JoJt9 b48I2GC2liHuRrMf+xBHEORdaMd8CHwFs2TQqR/nPeFDIZmLMHxjJVSU3+Cdp0FM8VilxQ 9Hn5+rhMNOot+p1ExYmJBpUVGneViKXwpbp5NnbcPUkseQeSyimsgkoLgQLvFsm0irGwIE I9kJNPKkkmVrpFyFACTVTGS9XIiOCOy4j+MALSmcIRM+EQNSWF86i34YE5g+AeLEWUCaKo iv9DNWsaAa8YjJpz/UFW9dkvrgJQftGQNnJ8xA2W6id1+08NBVoLMUspUzMjAg== 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 4jGKw50RwqzQb5 for ; Fri, 30 Oct 2026 12:21:41 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 46495 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 30 Oct 2026 12:21:41 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 2e9ac12e9793 - main - pf: fix pf_krule_item memory leak during counters:match_fail List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: 2e9ac12e97939d536c02877a41807dee05717ea5 Auto-Submitted: auto-generated Date: Fri, 30 Oct 2026 12:21:41 +0000 Message-Id: <6ae48bd5.46495.472ad28c@gitrepo.freebsd.org> The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=2e9ac12e97939d536c02877a41807dee05717ea5 commit 2e9ac12e97939d536c02877a41807dee05717ea5 Author: Kristof Provost AuthorDate: 2026-10-28 10:35:57 +0000 Commit: Kristof Provost CommitDate: 2026-10-30 12:21:11 +0000 pf: fix pf_krule_item memory leak during counters:match_fail If pf_counters_inc() did not increment the counters because the rule failed to apply it potentially failed to free match rules (which were not bound to a state already). Do so. While here explicitly hand match_rules over from the pf_test_ctx to the state so we never list them in two places. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index db21fefd9595..2d4efbe1e3e8 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -6699,6 +6699,7 @@ pf_create_state(struct pf_krule *r, struct pf_test_ctx *ctx, s->nat_rule = ctx->nr; s->anchor = ctx->a; s->match_rules = *ctx->match_rules; + SLIST_INIT(ctx->match_rules); /* The state owns these now. */ SLIST_INIT(&s->linkage); memcpy(&s->act, &pd->act, sizeof(struct pf_rule_actions)); @@ -11519,7 +11520,7 @@ pf_counters_inc(int action, struct pf_pdesc *pd, struct pf_kstate *s, /* If the rule has failed to apply, don't increase its counters */ if (!(op_pass || r->action == PF_DROP)) { - return; + goto out; } if (s != NULL) { @@ -11617,6 +11618,7 @@ pf_counters_inc(int action, struct pf_pdesc *pd, struct pf_kstate *s, src_host, dst_host); } +out: if (s == NULL) { pf_free_match_rules(mr); }