From: Avi Kivity <avi@redhat.com>
To: Glauber Costa <glommer@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org, Naphtali Sprei <nsprei@redhat.com>
Subject: Re: [PATCH] KVM: Fix wallclock version writing race
Date: Tue, 04 May 2010 19:21:32 +0300 [thread overview]
Message-ID: <4BE0498C.9040703@redhat.com> (raw)
In-Reply-To: <1272974544-19452-1-git-send-email-avi@redhat.com>
On 05/04/2010 03:02 PM, Avi Kivity wrote:
> Wallclock writing uses an unprotected global variable to hold the version;
> this can cause one guest to interfere with another if both write their
> wallclock at the same time.
>
> Signed-off-by: Avi Kivity<avi@redhat.com>
>
This was pointed out by Naphtali.
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index f6f8dad..c3152d7 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -754,14 +754,22 @@ static int do_set_msr(struct kvm_vcpu *vcpu, unsigned index, u64 *data)
>
> static void kvm_write_wall_clock(struct kvm *kvm, gpa_t wall_clock)
> {
> - static int version;
> + int version;
> + int r;
> struct pvclock_wall_clock wc;
> struct timespec boot;
>
> if (!wall_clock)
> return;
>
> - version++;
> + r = kvm_read_guest(kvm, wall_clock,&version, sizeof(version));
> + if (r)
> + return;
> +
> + if (version& 1)
> + ++version; /* first time write, random junk */
> +
> + ++version;
>
> kvm_write_guest(kvm, wall_clock,&version, sizeof(version));
>
>
--
error compiling committee.c: too many arguments to function
next prev parent reply other threads:[~2010-05-04 16:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-04 12:02 [PATCH] KVM: Fix wallclock version writing race Avi Kivity
2010-05-04 16:21 ` Avi Kivity [this message]
2010-05-04 16:23 ` Glauber Costa
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=4BE0498C.9040703@redhat.com \
--to=avi@redhat.com \
--cc=glommer@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=nsprei@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