From: Christian Borntraeger <borntraeger@de.ibm.com>
To: Marc Zyngier <maz@kernel.org>, kvm@vger.kernel.org
Cc: "Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"James Morse" <james.morse@arm.com>,
"Julien Thierry" <julien.thierry.kdev@gmail.com>,
"Suzuki K Poulose" <suzuki.poulose@arm.com>,
"James Hogan" <jhogan@kernel.org>,
"Paul Mackerras" <paulus@ozlabs.org>,
"Janosch Frank" <frankja@linux.ibm.com>,
"David Hildenbrand" <david@redhat.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Sean Christopherson" <sean.j.christopherson@intel.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>,
"Wanpeng Li" <wanpengli@tencent.com>,
"Jim Mattson" <jmattson@google.com>,
"Joerg Roedel" <joro@8bytes.org>,
"Peter Maydell" <peter.maydell@linaro.org>
Subject: Re: [PATCH] KVM: Forbid /dev/kvm being opened by a compat task when CONFIG_KVM_COMPAT=n
Date: Wed, 13 Nov 2019 19:43:55 +0100 [thread overview]
Message-ID: <2b846839-ea81-e40c-5106-90776d964e33@de.ibm.com> (raw)
In-Reply-To: <20191113160523.16130-1-maz@kernel.org>
On 13.11.19 17:05, Marc Zyngier wrote:
> On a system without KVM_COMPAT, we prevent IOCTLs from being issued
> by a compat task. Although this prevents most silly things from
> happening, it can still confuse a 32bit userspace that is able
> to open the kvm device (the qemu test suite seems to be pretty
> mad with this behaviour).
>
> Take a more radical approach and return a -ENODEV to the compat
> task.
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
> virt/kvm/kvm_main.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 543024c7a87f..1243e48dc717 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -122,7 +122,13 @@ static long kvm_vcpu_compat_ioctl(struct file *file, unsigned int ioctl,
> #else
> static long kvm_no_compat_ioctl(struct file *file, unsigned int ioctl,
> unsigned long arg) { return -EINVAL; }
> -#define KVM_COMPAT(c) .compat_ioctl = kvm_no_compat_ioctl
> +
> +static int kvm_no_compat_open(struct inode *inode, struct file *file)
> +{
> + return is_compat_task() ? -ENODEV : 0;
> +}
> +#define KVM_COMPAT(c) .compat_ioctl = kvm_no_compat_ioctl, \
Do we still need compat_ioctl if open never succeeds?
> + .open = kvm_no_compat_open
> #endif
> static int hardware_enable_all(void);
> static void hardware_disable_all(void);
>
next prev parent reply other threads:[~2019-11-13 18:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-13 16:05 [PATCH] KVM: Forbid /dev/kvm being opened by a compat task when CONFIG_KVM_COMPAT=n Marc Zyngier
2019-11-13 16:12 ` Paolo Bonzini
2019-11-13 18:43 ` Christian Borntraeger [this message]
2019-11-13 21:23 ` Peter Maydell
2019-11-14 8:15 ` Marc Zyngier
2019-11-14 8:20 ` Christian Borntraeger
2019-11-14 12:12 ` Paolo Bonzini
2019-11-14 13:22 ` Marc Zyngier
2019-11-14 13:28 ` Peter Maydell
2019-11-15 9:53 ` Paolo Bonzini
2019-11-15 9:14 ` Paolo Bonzini
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=2b846839-ea81-e40c-5106-90776d964e33@de.ibm.com \
--to=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=james.morse@arm.com \
--cc=jhogan@kernel.org \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=julien.thierry.kdev@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=maz@kernel.org \
--cc=paulus@ozlabs.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=rkrcmar@redhat.com \
--cc=sean.j.christopherson@intel.com \
--cc=suzuki.poulose@arm.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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