Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEB1B3FBBD for ; Fri, 17 May 2024 12:25:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715948739; cv=none; b=ts7z4NxfUhMRRsasECASqXBzFdrMPpfdbDcFbHcZDsmUsK75ATlMzmOKUhc2UuR7btbjB3XIx9W+jcr36e25Oz3TD3WlJE4jTrfDxXAxvHless9ludPNGxUSsWT8UIWvObICh3AzQfWJf2z+ACKhWAV3oaix1EruwS4N7WN1Ewc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715948739; c=relaxed/simple; bh=YOHI7iCgxOKYFIxlkowuKNKO3FeKGgwbuNpm828dDOw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=q+cFUOjSPYfhzLci1GHOIZlABCmpjfE2O7N8FgV6anshdV6W1e2YOTgR2dBAnR23rQOyUS1TEGwvjHveyKgpkYfOOSjQvWprexI5oiVGXhNq3ii+fU8slG7HoBDCTpdjcdLH0y8k68wAhgosL6pk4XsdTGK8dz3gMUOVrXXoicQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qvYr+Sv8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qvYr+Sv8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16033C2BD10; Fri, 17 May 2024 12:25:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1715948738; bh=YOHI7iCgxOKYFIxlkowuKNKO3FeKGgwbuNpm828dDOw=; h=From:To:Cc:Subject:Date:Reply-to:From; b=qvYr+Sv8vTUOvzTBcFVVQx8Qzv09/a53oGBC64PQErBC/zg0N8gR0N61i092FtgO6 O2Kfh1/40VkWTHaEFfEBJbaeDBfUuk8WUMhZFk6T5SOuI6WhCx4X9NOaOfnRSZFpV1 BSNGUXqY03iOy2xawK13koZ0aErn5htjdLGnDWtU= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-35791: KVM: SVM: Flush pages under kvm->lock to fix UAF in svm_register_enc_region() Date: Fri, 17 May 2024 14:25:12 +0200 Message-ID: <2024051708-CVE-2024-35791-65ad@gregkh> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3175; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=YOHI7iCgxOKYFIxlkowuKNKO3FeKGgwbuNpm828dDOw=; b=owGbwMvMwCRo6H6F97bub03G02pJDGnuPksOr2LW2Fw968nr0BIrvkTGDzN1JDr5vnQmMr/mc y1sfLGwI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACayjZ9hnq5JwTcPU46XwpaW K003zD0Tp5Odw7Bge+a/t/uSts9ZuSPozqQLbdKc7xfuBgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: KVM: SVM: Flush pages under kvm->lock to fix UAF in svm_register_enc_region() Do the cache flush of converted pages in svm_register_enc_region() before dropping kvm->lock to fix use-after-free issues where region and/or its array of pages could be freed by a different task, e.g. if userspace has __unregister_enc_region_locked() already queued up for the region. Note, the "obvious" alternative of using local variables doesn't fully resolve the bug, as region->pages is also dynamically allocated. I.e. the region structure itself would be fine, but region->pages could be freed. Flushing multiple pages under kvm->lock is unfortunate, but the entire flow is a rare slow path, and the manual flush is only needed on CPUs that lack coherency for encrypted memory. The Linux kernel CVE team has assigned CVE-2024-35791 to this issue. Affected and fixed versions =========================== Issue introduced in 5.10.15 with commit 4f627ecde732 and fixed in 5.10.215 with commit 2d13b79640b1 Issue introduced in 5.11 with commit 19a23da53932 and fixed in 5.15.154 with commit e126b508ed2e Issue introduced in 5.11 with commit 19a23da53932 and fixed in 6.1.84 with commit 4868c0ecdb6c Issue introduced in 5.11 with commit 19a23da53932 and fixed in 6.6.24 with commit 12f8e32a5a38 Issue introduced in 5.11 with commit 19a23da53932 and fixed in 6.7.12 with commit f6d53d8a2617 Issue introduced in 5.11 with commit 19a23da53932 and fixed in 6.8 with commit 5ef1d8c1ddbf Issue introduced in 4.19.176 with commit f1ecde00ce16 Issue introduced in 5.4.98 with commit 848bcb0a1d96 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2024-35791 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: arch/x86/kvm/svm/sev.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/2d13b79640b147bd77c34a5998533b2021a4122d https://git.kernel.org/stable/c/e126b508ed2e616d679d85fca2fbe77bb48bbdd7 https://git.kernel.org/stable/c/4868c0ecdb6cfde7c70cf478c46e06bb9c7e5865 https://git.kernel.org/stable/c/12f8e32a5a389a5d58afc67728c76e61beee1ad4 https://git.kernel.org/stable/c/f6d53d8a2617dd58c89171a6b9610c470ebda38a https://git.kernel.org/stable/c/5ef1d8c1ddbf696e47b226e11888eaf8d9e8e807