diff mbox

KVM: nVMX: Trap unconditionally if msr bitmap access fails

Message ID 511D3103.2040005@siemens.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kiszka Feb. 14, 2013, 6:46 p.m. UTC
This avoids basing decisions on uninitialized variables, potentially
leaking kernel data to the L1 guest.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 arch/x86/kvm/vmx.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Comments

Gleb Natapov Feb. 17, 2013, 8:56 a.m. UTC | #1
On Thu, Feb 14, 2013 at 07:46:27PM +0100, Jan Kiszka wrote:
> This avoids basing decisions on uninitialized variables, potentially
> leaking kernel data to the L1 guest.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Reviewed-by: Gleb Natapov <gleb@redhat.com>

> ---
>  arch/x86/kvm/vmx.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index 2633199..81a25de 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -5991,7 +5991,8 @@ static bool nested_vmx_exit_handled_msr(struct kvm_vcpu *vcpu,
>  	/* Then read the msr_index'th bit from this bitmap: */
>  	if (msr_index < 1024*8) {
>  		unsigned char b;
> -		kvm_read_guest(vcpu->kvm, bitmap + msr_index/8, &b, 1);
> +		if (kvm_read_guest(vcpu->kvm, bitmap + msr_index/8, &b, 1))
> +			return 1;
>  		return 1 & (b >> (msr_index & 7));
>  	} else
>  		return 1; /* let L1 handle the wrong parameter */
> -- 
> 1.7.3.4

--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Marcelo Tosatti Feb. 19, 2013, 2:20 a.m. UTC | #2
On Sun, Feb 17, 2013 at 10:56:36AM +0200, Gleb Natapov wrote:
> On Thu, Feb 14, 2013 at 07:46:27PM +0100, Jan Kiszka wrote:
> > This avoids basing decisions on uninitialized variables, potentially
> > leaking kernel data to the L1 guest.
> > 
> > Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> Reviewed-by: Gleb Natapov <gleb@redhat.com>

Applied, thanks.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 2633199..81a25de 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5991,7 +5991,8 @@  static bool nested_vmx_exit_handled_msr(struct kvm_vcpu *vcpu,
 	/* Then read the msr_index'th bit from this bitmap: */
 	if (msr_index < 1024*8) {
 		unsigned char b;
-		kvm_read_guest(vcpu->kvm, bitmap + msr_index/8, &b, 1);
+		if (kvm_read_guest(vcpu->kvm, bitmap + msr_index/8, &b, 1))
+			return 1;
 		return 1 & (b >> (msr_index & 7));
 	} else
 		return 1; /* let L1 handle the wrong parameter */