From nobody Wed Nov 13 10:34:31 2024 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 4XpKQv4NKxz5dSlj; Wed, 13 Nov 2024 10:34:31 +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 4XpKQv3vmtz4T9N; Wed, 13 Nov 2024 10:34:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731494071; 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=7xxRQk6y7zNtsBZq29QJ6oQP9V/H92qSUubQWG0p3pY=; b=v5kXOJQrRDy5I7kikMvEzlLpMi8uk44ixotMS8hQG+XxWrKGaQQyby2G010v9M/86GH1Xa 34vF4G7/7uDl8FSOPo9TVp++CRznSIJhUdUkj7RLWU97NvRw3W33GZ4BSkvK+7Cx+GRQcX CkhK0M/ctWfaIh9G4/P5LmezUxCaH8UtZGyOW/dIh1Ebw2bXg0BgE5kHWTeCcXpm5a2ZtF TNEqdkNTJF/wxlVi0ce8l2n+uLHXPiA6PuDKI0SrkaGp6q3/WS2Q8yVtSH3/AyL9ofYaSR G1Ir3u4lUyMkYPbxRhpnY+BFoupcI3Iwl0QYoZTjmcb/zwGpQO7sCmYjbIXUEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731494071; 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=7xxRQk6y7zNtsBZq29QJ6oQP9V/H92qSUubQWG0p3pY=; b=uJJpeMnOlvmNlo6V3CWnt144a8m0YAYUXajG9nansEC6eNVsvynoQpN6C3Rk8uUpip/mxd rS9d/m134Hf5O+2V6xj971kSjthgGKbDoDWiIZB+pSL91hSpH/MmIE1Aoh0ZxgsWDm5cqW GSVBFkwXZ3BbeQMOpex/n2EXuW2/PmEsEBvwt66t7x7j+I3eNLJNX7WXUnqwCEum1Za+fg 9+lYGEscCA5PkLzvf6LuTWrfdmxD/u6kJEXH/jJUXFBvgmeZGDyn/pCCfXQpyK3kqOG3Gj weyCLpNVO4LCCcHmitBdW47+oJFUh/XGP6eaK9KA3EDnmEhtSs5llTcdrS0VGw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731494071; a=rsa-sha256; cv=none; b=Xdd8LfeRRsVgnyoZ+x2N2S69MCpufvTUq2VBjlr46jerA57DrSq6G5cXDHA0rdk8iYneOR o2zkeLU28LBtTrg+QxztdG/b10WSLxPpC3nAe1gy5BgfzFMMeUd1Ib/mTsS1/az86cKODE LKgosLRAKUBj5zjfTLaRlZjkI3czvZBTgiukmMyr37wrreJsnvTD2Zbg3gaRfeyzt5tJwp H1MoFQWCqUSe1EAocR2jiIbqHU5tduT2FAdQjS5BrfdUwcVUQR1o0/PLpwX0H2dTJQTc6/ TXC3WpoyMFyHXax8gkMI35+jWa7TlbdRF1zsIZEI/MammFcIjtzm69EKMgxEHw== 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 4XpKQv3WX7zqg1; Wed, 13 Nov 2024 10:34: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 4ADAYVTg046430; Wed, 13 Nov 2024 10:34:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4ADAYVqL046427; Wed, 13 Nov 2024 10:34:31 GMT (envelope-from git) Date: Wed, 13 Nov 2024 10:34:31 GMT Message-Id: <202411131034.4ADAYVqL046427@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: 371bd29d4b22 - main - pf: fix potential state key leak 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: 371bd29d4b22257a7e92e1e711cca3d94cfbd00d Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=371bd29d4b22257a7e92e1e711cca3d94cfbd00d commit 371bd29d4b22257a7e92e1e711cca3d94cfbd00d Author: Kristof Provost AuthorDate: 2024-11-09 09:53:37 +0000 Commit: Kristof Provost CommitDate: 2024-11-13 09:34:08 +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 --- 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 90ec2b1ed033..691cb697a659 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1433,7 +1433,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! */