From: Jan Kiszka <jan.kiszka@web.de>
To: Vasiliy Kulikov <segooon@gmail.com>
Cc: 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: fix information leak to userland
Date: Sat, 30 Oct 2010 14:34:57 +0000 [thread overview]
Message-ID: <4CCC2D11.7090109@web.de> (raw)
In-Reply-To: <1288447871-7715-1-git-send-email-segooon@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]
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.
>
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
> ---
> I cannot compile this driver, so it is not tested at all.
Why? It should be compilable (provided you have a x86 toolchain).
>
> As it is not compilable, I've missed and typed wrong var name in v1, sorry.
>
> arch/x86/kvm/x86.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> 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;
>
> + memset(&dbgregs, 0, sizeof(dbgregs));
> kvm_vcpu_ioctl_x86_get_debugregs(vcpu, &dbgregs);
>
> r = -EFAULT;
> @@ -3481,11 +3482,11 @@ long kvm_arch_vm_ioctl(struct file *filp,
> struct kvm_clock_data user_ns;
> u64 now_ns;
>
> + memset(&user_ns, 0, sizeof(user_ns));
> local_irq_disable();
> now_ns = get_kernel_ns();
> user_ns.clock = kvm->arch.kvmclock_offset + now_ns;
> local_irq_enable();
> - user_ns.flags = 0;
>
> r = -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 mind)?
Nevertheless, looks like a worthwhile hardening of the KVM interfaces.
Thanks,
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Jan Kiszka <jan.kiszka@web.de>
To: Vasiliy Kulikov <segooon@gmail.com>
Cc: 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: fix information leak to userland
Date: Sat, 30 Oct 2010 16:34:57 +0200 [thread overview]
Message-ID: <4CCC2D11.7090109@web.de> (raw)
In-Reply-To: <1288447871-7715-1-git-send-email-segooon@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1919 bytes --]
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.
>
> Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
> ---
> I cannot compile this driver, so it is not tested at all.
Why? It should be compilable (provided you have a x86 toolchain).
>
> As it is not compilable, I've missed and typed wrong var name in v1, sorry.
>
> arch/x86/kvm/x86.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> 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;
>
> + memset(&dbgregs, 0, sizeof(dbgregs));
> kvm_vcpu_ioctl_x86_get_debugregs(vcpu, &dbgregs);
>
> r = -EFAULT;
> @@ -3481,11 +3482,11 @@ long kvm_arch_vm_ioctl(struct file *filp,
> struct kvm_clock_data user_ns;
> u64 now_ns;
>
> + memset(&user_ns, 0, sizeof(user_ns));
> local_irq_disable();
> now_ns = get_kernel_ns();
> user_ns.clock = kvm->arch.kvmclock_offset + now_ns;
> local_irq_enable();
> - user_ns.flags = 0;
>
> r = -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 mind)?
Nevertheless, looks like a worthwhile hardening of the KVM interfaces.
Thanks,
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
next prev parent reply other threads:[~2010-10-30 14:34 UTC|newest]
Thread overview: 22+ 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:11 ` Vasiliy Kulikov
2010-10-30 14:34 ` Jan Kiszka [this message]
2010-10-30 14:34 ` Jan Kiszka
2010-10-30 15:31 ` Vasiliy Kulikov
2010-10-30 15:31 ` Vasiliy Kulikov
2010-10-30 15:46 ` Jan Kiszka
2010-10-30 15:46 ` Jan Kiszka
2010-10-30 18:54 ` [patch v2] x86: kvm: x86: " Vasiliy Kulikov
2010-10-30 18:54 ` Vasiliy Kulikov
2010-11-01 17:19 ` Marcelo Tosatti
2010-11-01 17:19 ` Marcelo Tosatti
2011-07-26 17:05 ` Alexander Graf
2011-07-26 17:05 ` Alexander Graf
2011-07-26 17:24 ` Avi Kivity
2011-07-26 17:24 ` Avi Kivity
2011-07-26 17:38 ` Alexander Graf
2011-07-26 17:38 ` Alexander Graf
2011-07-26 17:28 ` Vasiliy Kulikov
2011-07-26 17:28 ` Vasiliy Kulikov
2011-07-26 17:39 ` Alexander Graf
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=4CCC2D11.7090109@web.de \
--to=jan.kiszka@web.de \
--cc=avi@redhat.com \
--cc=hpa@zytor.com \
--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=segooon@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.