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-next>] [day] [month] [year] [list]
Message-Id: <1630655700-798374-1-git-send-email-jiasheng@iscas.ac.cn>
Date:   Fri,  3 Sep 2021 07:55:00 +0000
From:   Jiang Jiasheng <jiasheng@...as.ac.cn>
To:     pbonzini@...hat.com, seanjc@...gle.com, vkuznets@...hat.com,
        wanpengli@...cent.com, jmattson@...gle.com, joro@...tes.org,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
        hpa@...or.com, jarkko@...nel.org, dave.hansen@...ux.intel.com
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-sgx@...r.kernel.org, Jiang Jiasheng <jiasheng@...as.ac.cn>
Subject: [PATCH 4/4] KVM: X86: Potential 'index out of range' bug

The kvm_get_vcpu() will call for the array_index_nospec()
with the value of atomic_read(&(v->kvm)->online_vcpus) as size,
and the value of constant '0' as index.
If the size is also '0', it will be unreasonabe
that the index is no less than the size.

Signed-off-by: Jiang Jiasheng <jiasheng@...as.ac.cn>
---
 arch/x86/kvm/x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e0f4a46..c59013c 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -2871,7 +2871,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
 				       offsetof(struct compat_vcpu_info, time));
 	if (vcpu->xen.vcpu_time_info_set)
 		kvm_setup_pvclock_page(v, &vcpu->xen.vcpu_time_info_cache, 0);
-	if (v == kvm_get_vcpu(v->kvm, 0))
+	if (atomic_read(&(v->kvm)->online_vcpus) > 0 && v == kvm_get_vcpu(v->kvm, 0))
 		kvm_hv_setup_tsc_page(v->kvm, &vcpu->hv_clock);
 	return 0;
 }
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ