From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH v2] x86: kvm: fix information leak to userland Date: Sat, 30 Oct 2010 16:34:57 +0200 Message-ID: <4CCC2D11.7090109@web.de> References: <1288447871-7715-1-git-send-email-segooon@gmail.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigE46FB154DC145DF8A04926C2" Cc: kernel-janitors@vger.kernel.org, Avi Kivity , Marcelo Tosatti , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org To: Vasiliy Kulikov Return-path: In-Reply-To: <1288447871-7715-1-git-send-email-segooon@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigE46FB154DC145DF8A04926C2 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Am 30.10.2010 16:11, Vasiliy Kulikov wrote: > Structure kvm_ppc_pvinfo is copied to userland with pad field > unitialized. Structure kvm_clock_data is copied to userland with > flags and pad fields unitialized. It leads to leaking of contents > of kernel stack memory. This description only partially matches your patch, please fix. >=20 > Signed-off-by: Vasiliy Kulikov > --- > I cannot compile this driver, so it is not tested at all. Why? It should be compilable (provided you have a x86 toolchain). >=20 > As it is not compilable, I've missed and typed wrong var name in v1, s= orry. >=20 > arch/x86/kvm/x86.c | 3 ++- > 1 files changed, 2 insertions(+), 1 deletions(-) >=20 > diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c > index b0818f6..261f3d0 100644 > --- a/arch/x86/kvm/x86.c > +++ b/arch/x86/kvm/x86.c > @@ -2896,6 +2896,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp, > case KVM_GET_DEBUGREGS: { > struct kvm_debugregs dbgregs; > =20 > + memset(&dbgregs, 0, sizeof(dbgregs)); > kvm_vcpu_ioctl_x86_get_debugregs(vcpu, &dbgregs); > =20 > r =3D -EFAULT; > @@ -3481,11 +3482,11 @@ long kvm_arch_vm_ioctl(struct file *filp, > struct kvm_clock_data user_ns; > u64 now_ns; > =20 > + memset(&user_ns, 0, sizeof(user_ns)); > local_irq_disable(); > now_ns =3D get_kernel_ns(); > user_ns.clock =3D kvm->arch.kvmclock_offset + now_ns; > local_irq_enable(); > - user_ns.flags =3D 0; > =20 > r =3D -EFAULT; > if (copy_to_user(argp, &user_ns, sizeof(user_ns))) I would rather clear the padding/reserved fields (in both cases). No need to double-initialize properly set fields. There are more interfaces in KVM for obtaining data from the kernel via padded structures. Did you check them all (kvm_vcpu_events come to my min= d)? Nevertheless, looks like a worthwhile hardening of the KVM interfaces. Thanks, Jan --------------enigE46FB154DC145DF8A04926C2 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org/ iEYEARECAAYFAkzMLRQACgkQitSsb3rl5xTSeQCfT9X2QF3u+91mMr54HQRvvIZM TWsAoKgc0mHqtc9gooX3aB2AxFmymSFs =qQMV -----END PGP SIGNATURE----- --------------enigE46FB154DC145DF8A04926C2--