From: Paolo Bonzini <pbonzini@redhat.com>
To: Wanpeng Li <kernellwp@gmail.com>,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Cc: "Radim Krčmář" <rkrcmar@redhat.com>,
"Wanpeng Li" <wanpeng.li@hotmail.com>
Subject: Re: [PATCH RESEND] KVM: X86: Fix stack-out-of-bounds read in write_mmio
Date: Tue, 12 Dec 2017 17:07:54 +0100 [thread overview]
Message-ID: <e9adc7ef-37c5-d2e0-ce3d-1aa70c3432f1@redhat.com> (raw)
In-Reply-To: <1513069078-63339-1-git-send-email-wanpeng.li@hotmail.com>
On 12/12/2017 09:57, Wanpeng Li wrote:
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index bc5d853..51e7932 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -4690,7 +4690,10 @@ static int write_emulate(struct kvm_vcpu *vcpu, gpa_t gpa,
>
> static int write_mmio(struct kvm_vcpu *vcpu, gpa_t gpa, int bytes, void *val)
> {
> - trace_kvm_mmio(KVM_TRACE_MMIO_WRITE, bytes, gpa, *(u64 *)val);
> + u64 data = 0;
> +
> + memcpy(&data, val, min(8, bytes));
> + trace_kvm_mmio(KVM_TRACE_MMIO_WRITE, bytes, gpa, data);
> return vcpu_mmio_write(vcpu, gpa, bytes, val);
> }
>
>
Please do the memcpy in TRACE_EVENT(kvm_mmio)'s TP_fast_assign block.
That is done only when the trace event is active.
Thanks,
Paolo
next prev parent reply other threads:[~2017-12-12 16:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-12 8:57 Wanpeng Li
2017-12-12 16:07 ` Paolo Bonzini [this message]
2017-12-13 3:05 ` Wanpeng Li
2017-12-13 9:56 ` Paolo Bonzini
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=e9adc7ef-37c5-d2e0-ce3d-1aa70c3432f1@redhat.com \
--to=pbonzini@redhat.com \
--cc=kernellwp@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rkrcmar@redhat.com \
--cc=wanpeng.li@hotmail.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
all inboxes | Powered by JetHome®