From nobody Fri May 5 13:34:31 2023 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 4QCWr757kQz49LYM; Fri, 5 May 2023 13: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QCWr74fFWz3PWH; Fri, 5 May 2023 13: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=1683293671; 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=lA2vWnUIwhQ07c02UNSvBlZSE2pgP0SiPoxJe+TvT1g=; b=YKnpNHBN1bt0AsHLbUCnOlrcQFnfc8dCin6vh3/ITPbohl95KHVPy9edyoT8Uf03kvvONZ C2uBPsaumgIBqGoxt5xmZerFXU+Yabe/eHQmLI7ugPAd2q7mlZzkHUe32lmEev2xVOu3AJ TNentWmoBtL4/fGg1H0bZDHQxoLabfbATR8iGIu6Gb/idnxLgAmK+8+70W6NHbUeNlmopP jje1HEcmSQNoo+ymUs/ac0qCJdMqQTMxqKDZ9o2U8276MYI5bnD77vhv4Gh9xlM/dDXxAD knhNob/4X2r78JR59pxZ1qXWaUhNPd9Gp1/uATGeGbM/LUYnnF+NuRDBmfzDxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683293671; 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=lA2vWnUIwhQ07c02UNSvBlZSE2pgP0SiPoxJe+TvT1g=; b=CRZ71/Wd44b8TcKp9lq5HBOZCh2028TXaON8fwHQaQT1wWFxrcAJAFWcbzFACs+RoBZtDF AKz5+ufe7OdeeuAxh/VnCaYrHQfDYCBY21Pkrpr2QE+jptGgi2wkUnny+ZeT1hSzfjeLhk hmpZvChTQ9NiP7YVw5c/2Mb7HpE+T8+sPWGeAGXv0XtS+jXOVEyF4H7dLj1yPpv3MNbYWp 62MmZybaBnqt4WLuNxdjfV3Fj+mNgbLR7OLSXnMOOhAhtoVSm1pZBhvwHts6hjfZxA/3xZ t2MbdTaegs++PALrrFHrhJ6MhRqeoMp7FPQrQ55OPaBGlCcbFCr7BzuXojH8Bw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683293671; a=rsa-sha256; cv=none; b=arVRix3nC1ZizRkoDN13DuZYCqstV527DKA5CuthrJNPccYVv+brKGHb1tCX0efdv0hVtG xtK29z8rnS/pvC84ccvIK6pNvvH/6pGY/l3L3Z0ZtE+Y1OeJo8XBTdxrAKHYO92SMBiQ/h fktEyMkZElMF9+1cCaXsyY8bj3qKT+xrAJB/Sdkl/vdiAhDhKJIj0Kq5z3PXZyTeA9+aIU JcKs56vXEY+ZmKKN4NOLwdIzCuBL+ZIvwno5RzGgTmLymhUMzVPhkfnHa8ZebKWBc894NB fCP/2PkLTvXsGCytJPtN1vNkK3+PfWlOmbWj8isL5/LpKOXdy9CE6E8RExQndQ== 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 4QCWr73j5zzwLn; Fri, 5 May 2023 13:34:31 +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 345DYVPH031201; Fri, 5 May 2023 13:34:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 345DYVG1031200; Fri, 5 May 2023 13:34:31 GMT (envelope-from git) Date: Fri, 5 May 2023 13:34:31 GMT Message-Id: <202305051334.345DYVG1031200@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: b10e100d1696 - main - vmm: don't free unallocated memory 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: corvink X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b10e100d1696782cfebef09b5870dfc6d1b3217b Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=b10e100d1696782cfebef09b5870dfc6d1b3217b commit b10e100d1696782cfebef09b5870dfc6d1b3217b Author: Corvin Köhne AuthorDate: 2023-05-05 06:36:20 +0000 Commit: Corvin Köhne CommitDate: 2023-05-05 13:34:00 +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 --- 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); }