From nobody Thu May 11 13:32:59 2023 X-Original-To: dev-commits-src-branches@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 4QHCWc0LDQz4BFV2; Thu, 11 May 2023 13:33:00 +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 4QHCWb6dPSz4GXx; Thu, 11 May 2023 13:32:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683811979; 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=76EVMUi8HpCYJs0jLnc39b1k1uqjp/dqoLzXbJuQDek=; b=ZppnNv26PRmRTi7qZuo7eFiiBr3MrA05XYI5F3zcvYa6IKgLopqluLTb/IWdGCMToPbiL6 JoxFzSgeTgRx7eLXbHBuJiIbrPtnKwIjvitW+qyu6qezGwhUaKb+vP/Agh+gWi2VNb00ja NGfZe6p7fleyp3p2AwmILgZFSGkrSD8vGSAlKOy5YtEDA1wTnvDk3FaYZQKpw2bfvLyF4r yyqSfawArvDwBW+MqyJ9qOx7f4xnaywqiiTo2Lj/K1ZdlBXB1GRv6ReoSxbcXy3vsdl2Km NHk05+pSgpUGgWC3y57xj0WGAVNqkdV0oEvnoch63h7BunvV1DXyvccWzlOByA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683811979; 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=76EVMUi8HpCYJs0jLnc39b1k1uqjp/dqoLzXbJuQDek=; b=gJpVO9oa63rNTrqYaNuhhtn2Dx3erEKWZAQUdNy5ECMrZ4W6boRtWTpH5Z1qwGsKC3M3Lq Ny7IgWNzXWovh7ngv8IfY227Kzwo/wsB3pmmhulp3M/5tEP85ShDB67tnEoesj/9Dq5DIi Itv72OTHc0gitaHm9cNjQUvAhncgvRf3QZXwvNRxfzSjyaoDC+Q/c/ZaXp/FycPQX0oRgv z/ARYsCXDkJtRn1bmfcync9jY99grs6hManOyT5JMdffb+KfNePBDNjfsjDrgVfKjmjGGN EXsFniH70kgmU7XKM20pSbQcoeSZMcVrYzjun6K/L71nCf2XcrkcWA3PaWUopQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683811979; a=rsa-sha256; cv=none; b=fl7uS2U3qYWXuebTK+MomFR4+CHKomzJjBpGmEQOKn8NXjMz6rwHU6MHGDAb40gf72/E5o 3y4r87PILYpTJn+YFYXdrzjVO7VM/Ievu62A1bxaEad+O4SO/OuJCtaIALbUFqLWom9Hvr +b9F21tl4LmH636mJF6WwKSri4MtsE1ZcfrQJgR73rFqxaTXb6BmwGO9O7nG0wiZw/4/n5 1NXRIQt3uAJQJ3zFRz/0gmPomlurx+wmgA+XqVWDaoSgR/f7sE1lcM5+kav/iz37uoTmck OgArkBNoOnaaLexRyFe1d+5pdtYEY4YQ+RoqZzTWOYUmM+qrp6NW/2GHmXDXqA== 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 4QHCWb5ZMGzvZ3; Thu, 11 May 2023 13:32:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34BDWxLq076771; Thu, 11 May 2023 13:32:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34BDWxd1076770; Thu, 11 May 2023 13:32:59 GMT (envelope-from git) Date: Thu, 11 May 2023 13:32:59 GMT Message-Id: <202305111332.34BDWxd1076770@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: be14baa34b82 - stable/13 - vmm: don't free unallocated memory List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: be14baa34b82e3ca50d0a2b61ddb05b355616c93 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=be14baa34b82e3ca50d0a2b61ddb05b355616c93 commit be14baa34b82e3ca50d0a2b61ddb05b355616c93 Author: Corvin Köhne AuthorDate: 2023-05-10 13:19:25 +0000 Commit: Mark Johnston CommitDate: 2023-05-11 13:32:32 +0000 vmm: don't free unallocated memory If vmx or svm is disabled in BIOS or the device isn't supported by vmm, modinit won't allocate these state save areas. As kmem_free panics when passing a NULL pointer to it, loading the vmm kernel module causes a panic too. PR: 271251 Reviewed by: markj Fixes: 74ac712f72cfd6d7b3db3c9d3b72ccf2824aa183 ("vmm: Dynamically allocate a couple of per-CPU state save areas") MFC after: 1 week Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D39974 (cherry picked from commit b10e100d1696782cfebef09b5870dfc6d1b3217b) --- sys/amd64/vmm/amd/svm.c | 5 ++++- sys/amd64/vmm/intel/vmx.c | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/amd64/vmm/amd/svm.c b/sys/amd64/vmm/amd/svm.c index 0af7342128f2..d295401a9043 100644 --- a/sys/amd64/vmm/amd/svm.c +++ b/sys/amd64/vmm/amd/svm.c @@ -166,7 +166,10 @@ svm_modcleanup(void) { smp_rendezvous(NULL, svm_disable, NULL, NULL); - kmem_free(hsave, (mp_maxid + 1) * PAGE_SIZE); + + if (hsave != NULL) + kmem_free(hsave, (mp_maxid + 1) * PAGE_SIZE); + return (0); } diff --git a/sys/amd64/vmm/intel/vmx.c b/sys/amd64/vmm/intel/vmx.c index 55ed5fdf1a00..8b8f8fe6cb25 100644 --- a/sys/amd64/vmm/intel/vmx.c +++ b/sys/amd64/vmm/intel/vmx.c @@ -619,7 +619,9 @@ vmx_modcleanup(void) nmi_flush_l1d_sw = 0; smp_rendezvous(NULL, vmx_disable, NULL, NULL); - kmem_free(vmxon_region, (mp_maxid + 1) * PAGE_SIZE); + + if (vmxon_region != NULL) + kmem_free(vmxon_region, (mp_maxid + 1) * PAGE_SIZE); return (0); }