lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 14 Sep 2020 17:16:32 -0000
From:   "tip-bot2 for Vitaly Kuznetsov" <tip-bot2@...utronix.de>
To:     linux-tip-commits@...r.kernel.org
Cc:     Dan Carpenter <dan.carpenter@...cle.com>,
        Joerg Roedel <jroedel@...e.de>,
        Colin King <colin.king@...onical.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Borislav Petkov <bp@...e.de>,
        Sean Christopherson <sean.j.christopherson@...el.com>,
        Tom Lendacky <thomas.lendacky@....com>, x86 <x86@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: [tip: x86/seves] KVM: nSVM: Avoid freeing uninitialized pointers in
 svm_set_nested_state()

The following commit has been merged into the x86/seves branch of tip:

Commit-ID:     e6eb15c9ba3165698488ae5c34920eea20eaa38e
Gitweb:        https://git.kernel.org/tip/e6eb15c9ba3165698488ae5c34920eea20eaa38e
Author:        Vitaly Kuznetsov <vkuznets@...hat.com>
AuthorDate:    Mon, 14 Sep 2020 15:37:25 +02:00
Committer:     Borislav Petkov <bp@...e.de>
CommitterDate: Mon, 14 Sep 2020 18:08:54 +02:00

KVM: nSVM: Avoid freeing uninitialized pointers in svm_set_nested_state()

The save and ctl pointers are passed uninitialized to kfree() when
svm_set_nested_state() follows the 'goto out_set_gif' path. While the
issue could've been fixed by initializing these on-stack varialbles to
NULL, it seems preferable to eliminate 'out_set_gif' label completely as
it is not actually a failure path and duplicating a single svm_set_gif()
call doesn't look too bad.

 [ bp: Drop obscure Addresses-Coverity: tag. ]

Fixes: 6ccbd29ade0d ("KVM: SVM: nested: Don't allocate VMCB structures on stack")
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
Reported-by: Joerg Roedel <jroedel@...e.de>
Reported-by: Colin King <colin.king@...onical.com>
Signed-off-by: Vitaly Kuznetsov <vkuznets@...hat.com>
Signed-off-by: Borislav Petkov <bp@...e.de>
Reviewed-by: Sean Christopherson <sean.j.christopherson@...el.com>
Acked-by: Joerg Roedel <jroedel@...e.de>
Tested-by: Tom Lendacky <thomas.lendacky@....com>
Link: https://lkml.kernel.org/r/20200914133725.650221-1-vkuznets@redhat.com
---
 arch/x86/kvm/svm/nested.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index 2803662..d1ae94f 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -1092,7 +1092,8 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
 
 	if (!(kvm_state->flags & KVM_STATE_NESTED_GUEST_MODE)) {
 		svm_leave_nested(svm);
-		goto out_set_gif;
+		svm_set_gif(svm, !!(kvm_state->flags & KVM_STATE_NESTED_GIF_SET));
+		return 0;
 	}
 
 	if (!page_address_valid(vcpu, kvm_state->hdr.svm.vmcb_pa))
@@ -1145,7 +1146,6 @@ static int svm_set_nested_state(struct kvm_vcpu *vcpu,
 	load_nested_vmcb_control(svm, ctl);
 	nested_prepare_vmcb_control(svm);
 
-out_set_gif:
 	svm_set_gif(svm, !!(kvm_state->flags & KVM_STATE_NESTED_GIF_SET));
 
 	ret = 0;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ