From nobody Thu Oct 12 19:18:33 2023 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 4S5zvF2mjxz4wnVv; Thu, 12 Oct 2023 19:18:33 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4S5zvF2FsTz3Xc8; Thu, 12 Oct 2023 19:18:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697138313; 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=AVwFojtZArQ1zoGoTbWDyTz1u6G/GxB0NRkKcpP6L7g=; b=vFD3LK6GCVqk5fTtsBjSXIkeKpAnzc6rf4JM3wKaCyB8Y4xzS/a3bREWMX0S5SWiqjmaLp uwPNHej77S2If92kKDjok76lxW0G67afvv2POlFh4TiJrq23/hSisVnwMcosi1by2n1jaT GuZ3LOZ/myEp99vVAts+BleZk+eEzoH/Sge+33CzQX//hRs4nMIaApEPYnryhAHXYzE7AQ 0wnTecP5Rz9hmbm1bxCF04V51XxRf41FkM/zcym3yrBw8DC62WRZS5RH27qbJvdtk/oM9B rTAsWlcdqbvE8R9a5f9Qpc1uNk9/FxiHfI5lQu+hd9wdTD73Xu2Nxl7E1VcOgw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697138313; a=rsa-sha256; cv=none; b=oA0ya8jYlmVJupyhx46KS+wy7xlJe3mZeSymm6J5X/b4m+dDcyJva30CkLRBCEmzYAt80W tU2U52M0KJ8W9nHP0FWJkrkZD4MxuoxPEGfXJvUCcl9NiLoQPc/EV5Z8SZ7OWeK7/XTQx2 Ink8XOf0NF+BETGU3ZYINF1BzazOUvXqoNtmuIR+RBkhGw94ybUDmQPYwXDoL09Q257xsy zwQQuWwf9RcI+ETxYzvj4GnDtdH79bhUx4S7epb8hxe2U+NDZuslLz/bUbVc1tOtHl1XlB zJi2zEOoQjiHiT1SdOiwxHY6QQzHAwAPh9/iLyK62bxX1Ty2tH24kejINoUleQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697138313; 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=AVwFojtZArQ1zoGoTbWDyTz1u6G/GxB0NRkKcpP6L7g=; b=uM15WgitaVUrs1CdqbYmz23luIr57kpkiD/OG4iBDwvZHpK5zlK+s63SjJfH9JERAGNVsu V4m+wk23RnbV8q04wKINiqQL8WLp/nNTcRdZIijuOyo5BJtzwA/7KPtqa3nxBT/bY92Z+z 4bxI1dRZswhj1oIfxYRmldg/dSh/txFGo7RiWdooLktsC/8j2jWeTGE4AtWepAa7NwsZox Q6ezVCK+3gT7Q8raq8GcYMgI0ZyqwNt+dFbKipxGlc43ggiUWZeCQHUEnOGy9QEcA6cLGr nAvCuL+39WC750Pghe/Yln5w8QYc4IpXlVy5xya17hUo5zzrpcb5DUy11WA0Pg== 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 4S5zvF1JLXz2Df; Thu, 12 Oct 2023 19:18:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39CJIXM0073781; Thu, 12 Oct 2023 19:18:33 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39CJIXSX073778; Thu, 12 Oct 2023 19:18:33 GMT (envelope-from git) Date: Thu, 12 Oct 2023 19:18:33 GMT Message-Id: <202310121918.39CJIXSX073778@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 4d19eceaefb7 - main - pf: Free pf_rule_items when state is not created List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 4d19eceaefb7106d761bc9504bb0da737ae0d674 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4d19eceaefb7106d761bc9504bb0da737ae0d674 commit 4d19eceaefb7106d761bc9504bb0da737ae0d674 Author: Kajetan Staszkiewicz AuthorDate: 2023-10-12 17:43:04 +0000 Commit: Kristof Provost CommitDate: 2023-10-12 19:18:06 +0000 pf: Free pf_rule_items when state is not created This addresses the issues of pf_rule_times leaking in case of stateless rules and in case of state creation failures, like hitting the state limit. Reviewed by: kp MFC after: 1 week Sponsored by: InnoGames GmbH Differential Revision: https://reviews.freebsd.org/D42169 --- sys/netpfil/pf/pf.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 3dddfdd0b1a4..39d240f49dbd 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -4731,6 +4731,11 @@ pf_test_rule(struct pf_krule **rm, struct pf_kstate **sm, struct pfi_kkif *kif, return (action); } } else { + while ((ri = SLIST_FIRST(&match_rules))) { + SLIST_REMOVE_HEAD(&match_rules, entry); + free(ri, M_PF_RULE_ITEM); + } + uma_zfree(V_pf_state_key_z, sk); uma_zfree(V_pf_state_key_z, nk); } @@ -4776,6 +4781,7 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a, struct tcphdr *th = &pd->hdr.tcp; u_int16_t mss = V_tcp_mssdflt; u_short reason, sn_reason; + struct pf_krule_item *ri; /* check maximums */ if (r->max_states && @@ -4986,6 +4992,11 @@ pf_create_state(struct pf_krule *r, struct pf_krule *nr, struct pf_krule *a, return (PF_PASS); csfailed: + while ((ri = SLIST_FIRST(match_rules))) { + SLIST_REMOVE_HEAD(match_rules, entry); + free(ri, M_PF_RULE_ITEM); + } + uma_zfree(V_pf_state_key_z, sk); uma_zfree(V_pf_state_key_z, nk);