public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vasiliy Kulikov <segoon@openwall.com>
To: Alexander Graf <agraf@suse.de>
Cc: Jan Kiszka <jan.kiszka@web.de>,
	kernel-janitors@vger.kernel.org, Avi Kivity <avi@redhat.com>,
	Marcelo Tosatti <mtosatti@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,
	linux-kernel@vger.kernel.org
Subject: Re: [patch v2] x86: kvm: x86: fix information leak to userland
Date: Tue, 26 Jul 2011 21:28:09 +0400	[thread overview]
Message-ID: <20110726172809.GA23970@albatros> (raw)
In-Reply-To: <ABD7343A-6440-4CC0-B8B0-9D27EF0291B0@suse.de>

Alexander,

On Tue, Jul 26, 2011 at 19:05 +0200, Alexander Graf wrote:
> > @@ -2623,6 +2626,7 @@ static void kvm_vcpu_ioctl_x86_get_debugregs(struct kvm_vcpu *vcpu,
> > 	dbgregs->dr6 = vcpu->arch.dr6;
> > 	dbgregs->dr7 = vcpu->arch.dr7;
> > 	dbgregs->flags = 0;
> > +	memset(&dbgregs->reserved, 0, sizeof(dbgregs->reserved));
> > }
> > 
> > static int kvm_vcpu_ioctl_x86_set_debugregs(struct kvm_vcpu *vcpu,
> > @@ -3106,6 +3110,7 @@ static int kvm_vm_ioctl_get_pit2(struct kvm *kvm, struct kvm_pit_state2 *ps)
> > 		sizeof(ps->channels));
> > 	ps->flags = kvm->arch.vpit->pit_state.flags;
> > 	mutex_unlock(&kvm->arch.vpit->pit_state.lock);
> > +	memset(&ps->reserved, 0, sizeof(ps->reserved));
> 
> struct kvm_pit_state2 {
>         struct kvm_pit_channel_state channels[3];
>         __u32 flags;
>         __u32 reserved[9];
> };
> 
> So memset(&ps->reserved) would give you the a __u32 **, no? Same goes for all the other array sets in here. Or am I understanding some C logic wrong? :)

No, the array name and an address of the array give the same address.  I
could use ps->reserved instead of &ps->reserved, but it is a question of
coding style.  I got opposite opinions on this question from different
maintainers.

Another thing is that sizeof() of the array name and the pointer to the
first array element differ.  But I used sizeof(array) here, so it should
be correct.


Thanks,

-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments

  parent reply	other threads:[~2011-07-26 17:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-30 14:11 [PATCH v2] x86: kvm: fix information leak to userland Vasiliy Kulikov
2010-10-30 14:34 ` Jan Kiszka
2010-10-30 15:31   ` Vasiliy Kulikov
2010-10-30 15:46     ` Jan Kiszka
2010-10-30 18:54       ` [patch v2] x86: kvm: x86: " Vasiliy Kulikov
2010-11-01 17:19         ` Marcelo Tosatti
2011-07-26 17:05         ` Alexander Graf
2011-07-26 17:24           ` Avi Kivity
2011-07-26 17:38             ` Alexander Graf
2011-07-26 17:28           ` Vasiliy Kulikov [this message]
2011-07-26 17:39             ` Alexander Graf

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=20110726172809.GA23970@albatros \
    --to=segoon@openwall.com \
    --cc=agraf@suse.de \
    --cc=avi@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jan.kiszka@web.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=mtosatti@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