From nobody Wed Nov 27 13:24:31 2024 X-Original-To: dev-commits-src-all@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 4Xz0Xc2BxXz5fBcT; Wed, 27 Nov 2024 13:24:32 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xz0Xc0JsNz4Mp2; Wed, 27 Nov 2024 13:24:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732713872; 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=opPKkBSmcPuYS1NPksOOHHaihwfWbmYtNuXqOXDbOwY=; b=oT9/5TVB/0s3alzmLx1WRBBplLFDYROiu/8eg+uc4kxWPW11CkL0H9Iymq/XvmfhdMmRUe 1ghYkbt/XXieD3NrwJav8rhPH8ZBeV32MzWD9A8rNHhjMh+FxO+i3TRUvj2yvDHm7R1tTR c9mB3/QWgzp3OcHWZECLZf5HPXDlWUK0NO6sCDzRVHhi34eC/Uc7e3fZno+RWjm/COSYKw FsZW51Tk5XYx7Ys0ATD706ltY4zWHkj8tCuW10P22HXONDhJU8y+nBRGuiOXhWBBuMyqvR 1cMPiPzWZ2EE2/ApRAJ5+qMJYbcvrtOMS+TIge1lDoQemqbqtEuWwLaWdGvAiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732713872; 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=opPKkBSmcPuYS1NPksOOHHaihwfWbmYtNuXqOXDbOwY=; b=rBH6K/+09r/xXmxN/MsgLKTNLAtwrRKqvpQi03GNzbnY6OvO2rSXsAsVgSiA4dCyZw7wCb G1iQKoVhnb8e62KzfRmFKGIPfo5FQVJeBBnLFWsL9N7fJwGbvQW+Ugxk1g05/Z6Gf3dVLO 8Pl/9d7KMlN8qVmkQwd2tO/wauR5BELiro7PXUEGU7kAEm7hfa0tt6Hin9B85Rf3SoN5Ku W+61Atsk6Px02TgzxKMBzCUifLlcRa/qphlU3Po3BfosmTmxSilNmrPJ14TCXK4ykppWIP 2i8GR/xkDRNNHBEot9GmF9yTJdaFhkUqxN9yVGDnT+3q1CJBxfq0xmQalLQATg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732713872; a=rsa-sha256; cv=none; b=rOtdGd3gfhaE1qTr43cFE5ETa+dFtA8adtw/Ku872AvW+3KrRnlOO8mHB+i2pRELnjFU+p qrMUf8SXL5BakQCTmdr02A9r+HNJ7fxxFlynduUfzXpT04wx07iPRpRGGDvitefQPbX+58 Uy32lX0JIrxXRq8Ob4oWTISzw++4G2gr5/K+M3lycLEcXZ2RJS0pKEUviQJ90VyLOWZboJ vEjdjtS4jq64rKKT57ASAVHHciZXEuRHqbVmq9DpjoBlN3a3Z/s3qcd3obTAaoOz4rwPlV JR6X3H/PBTOgqA42lCsweFpVepA8w/OxuoRwQflBpAsLEc45jE1F4yLIPfZc0w== 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 4Xz0Xb72mSz1BCh; Wed, 27 Nov 2024 13:24:31 +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 4ARDOVGc020067; Wed, 27 Nov 2024 13:24:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ARDOVA5020064; Wed, 27 Nov 2024 13:24:31 GMT (envelope-from git) Date: Wed, 27 Nov 2024 13:24:31 GMT Message-Id: <202411271324.4ARDOVA5020064@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: b4b2e420195a - stable/13 - pf: fix potential state key leak List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: b4b2e420195affca5251ad40e268aeaff9fc5623 Auto-Submitted: auto-generated The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=b4b2e420195affca5251ad40e268aeaff9fc5623 commit b4b2e420195affca5251ad40e268aeaff9fc5623 Author: Kristof Provost AuthorDate: 2024-11-09 09:53:37 +0000 Commit: Kristof Provost CommitDate: 2024-11-27 07:28:01 +0000 pf: fix potential state key leak If we fail to attach the new state keys in pf_state_key_attach() we are expected to free both keys. Do so. Note that in some scenarios both key are the same, so check for that before freeing. MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D47495 (cherry picked from commit 371bd29d4b22257a7e92e1e711cca3d94cfbd00d) --- 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 810966f88a89..8dc7a153c3ce 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1302,7 +1302,9 @@ keyattach: s->timeout = PFTM_UNLINKED; PF_HASHROW_UNLOCK(ih); KEYS_UNLOCK(); - uma_zfree(V_pf_state_key_z, sk); + uma_zfree(V_pf_state_key_z, skw); + if (skw != sks) + uma_zfree(V_pf_state_key_z, sks); if (idx == PF_SK_STACK) pf_detach_state(s); return (EEXIST); /* collision! */