From: Bandan Das <bsd@redhat.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, kvm@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] kvm: nVMX: off by one in vmx_write_pml_buffer()
Date: Wed, 10 May 2017 20:18:52 +0000 [thread overview]
Message-ID: <jpgr2zw4g9f.fsf@linux.bootlegged.copy> (raw)
In-Reply-To: <20170510194317.uh72h3ez7hnvn62v@mwanda> (Dan Carpenter's message of "Wed, 10 May 2017 22:43:17 +0300")
Dan Carpenter <dan.carpenter@oracle.com> writes:
> There are PML_ENTITY_NUM elements in the pml_address[] array so the >
> should be >= or we write beyond the end of the array when we do:
>
> pml_address[vmcs12->guest_pml_index--] = gpa;
>
> Fixes: c5f983f6e845 ("nVMX: Implement emulated Page Modification Logging")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index c6f4ad44aa95..7698e8f321bf 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -11213,7 +11213,7 @@ static int vmx_write_pml_buffer(struct kvm_vcpu *vcpu)
> if (!nested_cpu_has_pml(vmcs12))
> return 0;
>
> - if (vmcs12->guest_pml_index > PML_ENTITY_NUM) {
> + if (vmcs12->guest_pml_index >= PML_ENTITY_NUM) {
This is actually an overflow check and as the counter decrements, we hit
0xffff which will satisfy guest_pml_index > PML_ENTITY_NUM.
However, a buggy guest hypervisor can write 512 to guest_pml_index and in that
case, we need to inject a pml full event which won't happen if we don't use >=.
So, your patch is correct, I would only suggest that the commit message be
modified to reflect this condition.
Bandan
> vmx->nested.pml_full = true;
> return 1;
> }
next prev parent reply other threads:[~2017-05-10 20:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-10 19:43 [PATCH] kvm: nVMX: off by one in vmx_write_pml_buffer() Dan Carpenter
2017-05-10 20:18 ` Bandan Das [this message]
2017-05-10 20:43 ` [PATCH v2] " Dan Carpenter
2017-05-11 7:31 ` Paolo Bonzini
2017-05-11 7:42 ` Dan Carpenter
2017-05-11 7:52 ` Paolo Bonzini
2017-05-11 13:56 ` Bandan Das
2017-05-11 15:23 ` Paolo Bonzini
2017-05-11 17:06 ` Bandan Das
2017-05-16 13:56 ` [PATCH] " 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=jpgr2zw4g9f.fsf@linux.bootlegged.copy \
--to=bsd@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=hpa@zytor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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