From nobody Tue Sep 2 21:10:56 2025 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 4cGdh05fpTz65RH4; Tue, 02 Sep 2025 21:10:56 +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 4cGdh03Vwtz42FL; Tue, 02 Sep 2025 21:10:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756847456; 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=eruA+nMfWfcKhG114iAJ9YiFcb0bOl9iEwzYrf8Jmec=; b=Q2xZI7zKFG6wbCpSZ5DWiZYbvXpQZghoz86vkurcQTGgG1pqvNz1wFEElVvba1FUs6CKYo GL3ca8WB+FinN3ilubotj/mEvxZjG/1jQqLbtlyOKSiTb8PFtI8iOHtXaOWI6hXuX8VcbI qP5LlOhVAj6unTsZw9z0sUjwMw5/A/4Dk1vgmUNckQ+MtuLxkj1O1nG1D0IyPy3dcMPEwu JNTcBVbDzDXmlW5R0uxMnfZvlOqySC6BR+uHMBz1kMXv/xOgj7TGCLfyeGB4xLVnlXim1G Y2Xtn1ymuOu2Od7k9ITqJLa4vJ5shMBg7zqfa0gQkAsqymZN/CKy0QhA4g5g6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1756847456; 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=eruA+nMfWfcKhG114iAJ9YiFcb0bOl9iEwzYrf8Jmec=; b=PurqHefp1P6ZTiMZRJ2x6kF95LJmugSRmwRV/B1lUXno68Ok6KTv0ScQaBMnrb3DTplFUb aJc8AlWgLjyMuti3atB1FJiXEPw5d4tF23oJBNC7/IQ99LpYJ8drtCibwjuE6IlrUygEV2 ObTu/Y5wa9TBSoGAp+Rxc7XXMivTuGL3kRliAUl2/lOyO0Ljz5gFbitsEy93btxQwU/1pj 6JDNT7SWR1c14otlxwBDYMJyikcbqiC9MFc2PefMG7RfUN+xbZHF0fywc9v5q5ovQUze+B pfkUdZQNl7g5AFcy74ZfkB014yeoajJ1AF7xON0ljoNKsA5Z1E4W3Nfcu3udeA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1756847456; a=rsa-sha256; cv=none; b=CAvf/rxn+QOH0RTFSTigpijcT18seNi9Z9ZU8pTGUE4hOtHmasDd4OW9c2xMG8nja40cDE CM2v93goOw4O0L+s5iP5F4YT6MM8r7oUSnjYhEvR6veM41/Ml2SR8xvlE4N8Xh6Yg2aZab iRpBIoXA4NcCZq7SpvJXmM9vTUPbqv7qxaY39DLsrm7NfA+zF7NyvtfeO0ccudLvgVrNaG j1Ml7zjO8eqakAlAu0lRnqrboE3p3QtE/hnUpL+tt7hPK5ATkmxoFghGzXW781+xeYDvG+ oQuxSCig6amtJGn4xpCbhoQIwUAGvFboFgN4dMZ1AcBWuH6egiEnRZe0QSryQg== 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 4cGdh034NZz130Y; Tue, 02 Sep 2025 21:10:56 +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 582LAutg036553; Tue, 2 Sep 2025 21:10:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 582LAuRa036550; Tue, 2 Sep 2025 21:10:56 GMT (envelope-from git) Date: Tue, 2 Sep 2025 21:10:56 GMT Message-Id: <202509022110.582LAuRa036550@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: ea15fe2e8cbc - main - pf: fix memory leak in legacy getstate calls 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: ea15fe2e8cbc3a5d3f62a9d22e0e4bef63f611eb Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=ea15fe2e8cbc3a5d3f62a9d22e0e4bef63f611eb commit ea15fe2e8cbc3a5d3f62a9d22e0e4bef63f611eb Author: Kristof Provost AuthorDate: 2025-08-29 14:27:52 +0000 Commit: Kristof Provost CommitDate: 2025-09-02 21:10:21 +0000 pf: fix memory leak in legacy getstate calls If we fail to copy the data out we didn't free the temporary allocation. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/netpfil/pf/pf_ioctl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/netpfil/pf/pf_ioctl.c b/sys/netpfil/pf/pf_ioctl.c index 7a14c0946dfc..9ca7c6759e27 100644 --- a/sys/netpfil/pf/pf_ioctl.c +++ b/sys/netpfil/pf/pf_ioctl.c @@ -4125,8 +4125,10 @@ DIOCGETSTATES_retry: PF_HASHROW_UNLOCK(ih); error = copyout(pstore, out, sizeof(struct pfsync_state_1301) * count); - if (error) + if (error) { + free(pstore, M_PF); goto fail; + } out = ps->ps_states + nr; } DIOCGETSTATES_full: @@ -4203,8 +4205,10 @@ DIOCGETSTATESV2_retry: PF_HASHROW_UNLOCK(ih); error = copyout(pstore, out, sizeof(struct pf_state_export) * count); - if (error) + if (error) { + free(pstore, M_PF); goto fail; + } out = ps->ps_states + nr; } DIOCGETSTATESV2_full: