public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Dan Carpenter <dan.carpenter@oracle.com>
Subject: [PATCH 2/4] KVM: x86: zero base3 of unusable segments
Date: Thu, 18 May 2017 19:37:30 +0200	[thread overview]
Message-ID: <20170518173732.12185-3-rkrcmar@redhat.com> (raw)
In-Reply-To: <20170518173732.12185-1-rkrcmar@redhat.com>

Static checker noticed that base3 could be used uninitialized if the
segment was not present (useable).  Random stack values probably would
not pass VMCS entry checks.

Reported-by:  Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 1aa366163b8b ("KVM: x86 emulator: consolidate segment accessors")
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 arch/x86/kvm/x86.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b54125b590e8..eed8272dd52e 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -5053,6 +5053,8 @@ static bool emulator_get_segment(struct x86_emulate_ctxt *ctxt, u16 *selector,
 
 	if (var.unusable) {
 		memset(desc, 0, sizeof(*desc));
+		if (base3)
+			*base3 = 0;
 		return false;
 	}
 
-- 
2.13.0

  parent reply	other threads:[~2017-05-18 17:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-18 17:37 [PATCH 0/4] KVM: x86: fix bugs reported by Dan Carpenter Radim Krčmář
2017-05-18 17:37 ` [PATCH 1/4] KVM: nVMX: fix nested_vmx_check_vmptr failure paths under debugging Radim Krčmář
2017-05-19 13:48   ` [PATCH v2] " Radim Krčmář
2017-05-30 14:34     ` Paolo Bonzini
2017-05-18 17:37 ` Radim Krčmář [this message]
2017-05-19 13:30   ` [PATCH 2/4] KVM: x86: zero base3 of unusable segments David Hildenbrand
2017-05-18 17:37 ` [PATCH 3/4] KVM: x86/vPMU: fix undefined shift in intel_pmu_refresh() Radim Krčmář
2017-05-19 13:31   ` David Hildenbrand
2017-05-18 17:37 ` [PATCH 4/4] KVM: x86: prevent uninitialized variable warning in check_svme() Radim Krčmář
2017-05-19 13:32   ` David Hildenbrand
2017-05-18 18:52 ` [PATCH 0/4] KVM: x86: fix bugs reported by Dan Carpenter Paolo Bonzini
2017-05-18 19:25   ` Radim Krčmář

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170518173732.12185-3-rkrcmar@redhat.com \
    --to=rkrcmar@redhat.com \
    --cc=dan.carpenter@oracle.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox