From patchwork Thu Oct 26 13:45:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 10028275 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 606C56022E for ; Thu, 26 Oct 2017 13:46:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5429C28E1B for ; Thu, 26 Oct 2017 13:46:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48E3F28E21; Thu, 26 Oct 2017 13:46:25 +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 5D92328E1B for ; Thu, 26 Oct 2017 13:46:24 +0000 (UTC) Received: (qmail 7372 invoked by uid 550); 26 Oct 2017 13:46:06 -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 7316 invoked from network); 26 Oct 2017 13:46:04 -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=RoW0RpjYciEiP2hetPmzLhZEerHm6C15Lc3KChXIP0Q=; b=OA+LSYwSkyfGDx8vsvB9Jn+XS7FCqe+3D5n5mFrVrZfsbIIYRUDUC582oazBQBC/Ar WOKg8Kh0gbUbVy9Iz9uYT3p1dJWXdvj57UC9N65XzKTK4ooBXVSJJg8y4kknxPbzZubv zqRalmdae8ln3c/eAOAd4lLqtq6m1iSdS9U4mgPm04EkaeK1/vVSiIWS2yOot6YV/4SY dq1GlpiSBBKfDVZR2rYfLbTG6AGEUEcgFva8b1x1D0q7JO7gWeez/z0J1ZRYKP3l8IP9 Mxfz7YzhndWuGTeq6e3vrLu0iqlOPLWf9/AzBwFIbiKHHDN5kzoRBJkRp2ewD0/zQeeS oYcg== 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=RoW0RpjYciEiP2hetPmzLhZEerHm6C15Lc3KChXIP0Q=; b=KgrMBqdCywigikTI6ja7t+c5vVcX1I+IlRIXC8dBCqgZ3+dQtGxt5m5U0BZe240mAZ XoI9x/lH6Tl67RbBYFb7dkNmmPwszPeSTk1JZW4V6GN3FisH/6sNnEtuAiu5y4gYRtQs UTtOjnwMMGkPYCdZfkmY+4Xq4J6yDohYb9IKvOM1nDgiue+2338L42IuKUrqlhl8prWl XqSAc4UnF2wjO70HzQzt+mnlfljATS9HoWiW/kNzULq888vAnQ0odtM88JY+p7Y9eKJu UxoSUAz/2cYknFuxwZwykhwfTRK3l74P3HpwDwweoiOtqpzf5bzbxNqpljjvwtevcrXm iBNQ== X-Gm-Message-State: AMCzsaXhH8daqozkw3tYdZzijYLKE7in3wfbHbKaCTBPoo7wHshzwkUf yLFl7TprnXBsRlLdTbv0eAA= X-Google-Smtp-Source: ABhQp+TPRZCk2vm6k1R4pK7Mukv1GuaQW4cbNA9NVfVghoz5Zzon0ssFOa3d49l8VOhoRhGh/x4wcg== X-Received: by 10.223.170.67 with SMTP id q3mr4981590wrd.193.1509025552553; Thu, 26 Oct 2017 06:45:52 -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: Thu, 26 Oct 2017 15:45:47 +0200 Message-Id: <20171026134547.23664-3-pbonzini@redhat.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171026134547.23664-1-pbonzini@redhat.com> References: <20171026134547.23664-1-pbonzini@redhat.com> MIME-Version: 1.0 Subject: [kernel-hardening] [PATCH 2/2] kvm: x86: 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 272320eb328c..f32fbfb833b3 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4187,13 +4187,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; }