From patchwork Fri Oct 20 23:25:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 10021131 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8134460234 for ; Fri, 20 Oct 2017 23:25:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74A9928D05 for ; Fri, 20 Oct 2017 23:25:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6962C28D17; Fri, 20 Oct 2017 23:25:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 8FD1B28D1E for ; Fri, 20 Oct 2017 23:25:57 +0000 (UTC) Received: (qmail 3415 invoked by uid 550); 20 Oct 2017 23:25:45 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 3277 invoked from network); 20 Oct 2017 23:25:43 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=nguM7A99hcI+hODkpllJeclCNIjC9Ylpw3IEd4Eie6o=; b=Zj/5LTHZEf7Dp18ad5fge+6v18X7XAkD0wccjqszJbBtDazraa/54NHit6dYtixhUZ gzYPoWSmBu3rTSbNTvzJXivCEPTxYq0bRiZDFJrxqvHnQiJV2Wv8y+N14yUQrjq64SHS 3FISfveMTIz3okfw6yIcofX9M9Yaq64tLyhXNu52yPVXq8HxOqbzcWLf5c49i8r9Ks/m lwtPFs0VBZfkuvU7Vo9M0gHLsl0mNk81hfYcSZSGWWF/OZD19s9vTQPg3rsZwPmoljZZ IR6SIdC2P6yNcx2c4csrsm0nmog9Meavt5vaw85ekoCw5auB407xgz/iGSCWD/dP4Qqz xzqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=nguM7A99hcI+hODkpllJeclCNIjC9Ylpw3IEd4Eie6o=; b=qQsYgMJDSiVsVnIr3bU8iX7Ig2e4/4V8ZGFjLlIZSMdEVUHOVqJYFkGPpArllXX9vH idI4UglNKSyx3zo85xpSoSiNluwx+wfPh2494MeL0yMG2jDysULqh2J+XbYJIy4jN+zJ Wunry6ubK7rapQbhPDdDGNPoAM//COOStNgJ1Dc6gj89yBNPusbIOgo3+jnjXof15TEs FA0fKHH1QfZr0ax2LN2CBi7wrDdAJ9Do9ok6aEHw2gNeFoRjvaHVsb0sXY06mb+QX5WI qQvyj8hCcK9I16sC7uME0HFf/ZvolnuGSrEPUV8nuJC3JnybLso3IHLGylbFQ5OeY8iS UlDg== X-Gm-Message-State: AMCzsaULhXJqK2LRaqDkCPhXjRgxb5PdvA8pGpRs9/E4RSMHNNSEoAql 0O4/JNaAVHsppE6taAY64Hw= X-Google-Smtp-Source: ABhQp+RRQA+vKNcDTPN5veHHiOSf7QuSN7WY9FMO7ot2r/ZoYXSCTeYqbkE3dJGm+UAdigrXAJgwxQ== X-Received: by 10.223.184.140 with SMTP id i12mr5358505wrf.31.1508541932314; Fri, 20 Oct 2017 16:25:32 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Christoffer Dall , Marc Zyngier , Christian Borntraeger , Cornelia Huck , James Hogan , Paul Mackerras , kernel-hardening@lists.openwall.com, Kees Cook , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Date: Sat, 21 Oct 2017 01:25:25 +0200 Message-Id: <20171020232525.7387-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171020232525.7387-1-pbonzini@redhat.com> References: <20171020232525.7387-1-pbonzini@redhat.com> MIME-Version: 1.0 Subject: [kernel-hardening] [PATCH 2/2] KVM: fix KVM_XEN_HVM_CONFIG ioctl X-Virus-Scanned: ClamAV using ClamSMTP This ioctl is obsolete (it was used by Xenner as far as I know) but still let's not break it gratuitously... Its handler is copying directly into struct kvm. Go through a bounce buffer instead, with the added benefit that we can actually do something useful with the flags argument---the previous code was exiting with -EINVAL but still doing the copy. This technically is a userspace ABI breakage, but since no one should be using the ioctl, it's a good occasion to see if someone actually complains. Cc: kernel-hardening@lists.openwall.com Cc: Kees Cook Cc: Radim Krčmář Signed-off-by: Paolo Bonzini --- arch/x86/kvm/x86.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 415529a78c37..c76d7afa30be 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4218,13 +4218,14 @@ long kvm_arch_vm_ioctl(struct file *filp, mutex_unlock(&kvm->lock); break; case KVM_XEN_HVM_CONFIG: { + struct kvm_xen_hvm_config xhc; r = -EFAULT; - if (copy_from_user(&kvm->arch.xen_hvm_config, argp, - sizeof(struct kvm_xen_hvm_config))) + if (copy_from_user(&xhc, argp, sizeof(xhc))) goto out; r = -EINVAL; - if (kvm->arch.xen_hvm_config.flags) + if (xhc.flags) goto out; + memcpy(&kvm->arch.xen_hvm_config, &xhc, sizeof(xhc)); r = 0; break; }