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 4Xz0Xb2B6rz5fBcS; Wed, 27 Nov 2024 13:24: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 4Xz0Xb1h77z4Mp1; Wed, 27 Nov 2024 13:24:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732713871; 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=vDd+7JQ20Q4YImsP5CXO1Gi+/Wc+RTdcGQDkd/XkB/0=; b=dCFbofxklWyY9DTFgBUK0ooYHSQGXBmdxdA54TG3a4JMEn0iSu8l81xhCNxbTvy+qwITFC oiY5RHJqNTORRqfIjjGQmjVBmMACFsenyQOK1z3FaxSDU6gBdoe+99a20pRps9NtI1nv4G FNRndYqQgPWyZJcQXRiV4quxRoa7ObCFfoxPZrp6YkLSBNVPm7CnuX4INEiVxTY+qB5IO8 2mJujlnKBJfjTfgN5W1t/7foXWN5x+Rks4gEeI4ngbABbw7btLVcws5Gay+DqFrg6G3puO oGfqP+RYZ1uSDF9MUM1pTYxXPOAFJpjmSrctmMJrJsBK9FIjz9+fAVNB+AMUmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1732713871; 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=vDd+7JQ20Q4YImsP5CXO1Gi+/Wc+RTdcGQDkd/XkB/0=; b=lt7ELFgtzrepBJuERNGogSybCrjxFxjAK+C7UUJVgxLn+AQdAtMaY9ggmK4+g44fj24uY9 Xs0szDKxbIe8tytO2naTv0dwXuKyO1DvZCCUOUxN9puvjhgvULNR7DJIzI3yV6+4kHhs7l UMrHE/ejvwQnb0YDW1lDFz3KiBqsT1idI6Vm4LbBrFqOmym26Jnq91VPEkF8p6HBnPvM/0 I0sduzj8l7rCQl1S7annbBxstYVU5KomUc9o/HL4Wmn7SoA1ZgeF9bQeAD+vO44lQMONYh BqS1TOkwbTFmxY9WaNTN8SyG7xMDftc3NcKh44kuMwrwvxtB1+xIT6HKq3GEYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1732713871; a=rsa-sha256; cv=none; b=vLM7EOGfZwayxp1bacgwnFaHBw22MRiGXcEMwlkawJqu4d+kSicIAp/6PH6dCwIj1YYKcl S6/ITL0ZfrGY521wZyBht6z2rPVLhWpEccZ+/y/RFRq08bAv4njTfd4u/pa+BDkM7s8Y9Y 1bOJ6vxdqseXmVLx0ulc0C3y65KPNmRnXllOJ4YKilmsMm/BMREePlIpzXJhFKLmo8gONO RaGApngZm0ovSi9ZO9HVFm+9AL4FLQHhN1m+Nz4E8fabZBHTUxdz3AZRRh9Jxk94bcbzCA ++aZWc5qQOKHftmLadMBYi139q42RItd3rDz2nPC/pIjYy1fHA0HdvfS0uIdfQ== 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 4Xz0Xb1HH9z1B2N; 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 4ARDOVKF019960; 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 4ARDOVt3019957; Wed, 27 Nov 2024 13:24:31 GMT (envelope-from git) Date: Wed, 27 Nov 2024 13:24:31 GMT Message-Id: <202411271324.4ARDOVt3019957@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: 93c80b79ad65 - stable/14 - 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/14 X-Git-Reftype: branch X-Git-Commit: 93c80b79ad6564a17553fc1df41d57dc9da4cdec Auto-Submitted: auto-generated The branch stable/14 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=93c80b79ad6564a17553fc1df41d57dc9da4cdec commit 93c80b79ad6564a17553fc1df41d57dc9da4cdec Author: Kristof Provost AuthorDate: 2024-11-09 09:53:37 +0000 Commit: Kristof Provost CommitDate: 2024-11-27 13:19:53 +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 4fd884852d90..80f3fdae1861 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -1345,7 +1345,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! */