[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <9BD442B1-A1A2-4C78-9508-4E7C59C6030D@suse.de>
Date: Tue, 26 Jul 2011 19:39:16 +0200
From: Alexander Graf <agraf@...e.de>
To: Vasiliy Kulikov <segoon@...nwall.com>
Cc: Jan Kiszka <jan.kiszka@....de>, kernel-janitors@...r.kernel.org,
Avi Kivity <avi@...hat.com>,
Marcelo Tosatti <mtosatti@...hat.com>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
kvm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [patch v2] x86: kvm: x86: fix information leak to userland
On 26.07.2011, at 19:28, Vasiliy Kulikov wrote:
> 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.
Yup, the sizeof looks fine. I was really only puzzled about the &array part. But if it's standardized to return the same as array, then that's great and I can call myself more educated now :)
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists