From patchwork Mon Apr 9 00:19:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10330609 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 5A47F6020F for ; Mon, 9 Apr 2018 06:10:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E6AC288C3 for ; Mon, 9 Apr 2018 06:10:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4314928A67; Mon, 9 Apr 2018 06:10:17 +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=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 453B0288C3 for ; Mon, 9 Apr 2018 06:10:16 +0000 (UTC) Received: (qmail 5635 invoked by uid 550); 9 Apr 2018 06:10:09 -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 Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 11590 invoked from network); 9 Apr 2018 00:22:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Jc6j803jtHdLdEZ3tGd62vAsujMIKceynTxriJL/DVU=; b=osAR+CXuAvckhkG+mQlH4wO9pFugBq1x02U7RTHH6bjPdDG+EGO5CkkvzsMlg1L95GtvqpqhwHVe/5rHV8ySnFlfUOWWZLUdau1fLoQ1fMfntqAdxw9+PyNQvO+Y7iGXxfzyXGfGKSU/T8gXwLHWxN+XxmhAo099KyHgwuiIiBM= From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Paolo Bonzini , "kernel-hardening@lists.openwall.com" , Kees Cook , =?utf-8?B?UmFkaW0gS3LEjW3DocWZ?= , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 007/161] kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl Thread-Topic: [PATCH AUTOSEL for 4.14 007/161] kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl Thread-Index: AQHTz5h3OEccfGEqck+DbQntLmIxJA== Date: Mon, 9 Apr 2018 00:19:46 +0000 Message-ID: <20180409001936.162706-7-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DM5PR2101MB0936; 7:6g/tZIqlwbQhkoWVUkGfBW5PfkrCFg6XrE3pChj2HPiVQLyMDECFDXFo2VgQas7MmVy5uIU/hN8OLocXkV9/MaNknlIKjWE2PqXazvXilUE3z7d7DOktWsOUTBgKvHWupm/SQDrOQvjEJcHrvM81sujUJzJ255QQh1Jc431xbdCEXt62B8K2hL7Bntx3ZjWjkjcI5z3j418dvkMuviB8O5Prxj2Mcgom47m0KH+uPhnqJAWk6em03ZL/3HPW0v7E; 20:f7Dt9jEM2Ic1QWBJ63/hIYj49KPh9tkf8KEL7DuxKXBzQvO9nXf5oOzYG4hGcG0QHuDcqQzic/ac0xptcz5tnB+4Azi7w8TMORTls/lBIXuxK8MnMZncT6kMncWhSdOZLtY3AqkhNIrt8vo9TWen3CJ1YpipRg1ajkp+uHTieB4= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 3e702149-fb89-4029-e9b8-08d59dafe7df x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB0936; x-ms-traffictypediagnostic: DM5PR2101MB0936: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011); SRVR:DM5PR2101MB0936; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0936; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39380400002)(39860400002)(396003)(376002)(366004)(199004)(189003)(3660700001)(36756003)(2501003)(76176011)(10290500003)(2616005)(5250100002)(3280700002)(478600001)(1076002)(72206003)(6436002)(53936002)(486006)(476003)(4326008)(6486002)(107886003)(5660300001)(54906003)(110136005)(102836004)(2906002)(6116002)(3846002)(86612001)(81156014)(81166006)(6666003)(8936002)(305945005)(8676002)(2900100001)(6506007)(68736007)(14454004)(106356001)(105586002)(25786009)(6512007)(86362001)(99286004)(446003)(59450400001)(10090500001)(11346002)(316002)(26005)(7736002)(66066001)(186003)(22452003)(97736004)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0936; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: teXxyBudHD0HPpKF6AQJcHz4cd0h55RWl2CBi6NeTMtwOcIQDHwBTGUjxr5Os7SYwx9vhqc8cX8GDODKpKeUJ0mA+aiauG5/8gavhdlX1AWU8iwmmQ8/TZXzZXpSyzF106rQlAMR6jfb+MLYUJzTnhwvripJ8fm/rxsmNdBkwY1PgNJCKjEixPRuuqklF/ZmQME8Tg2EG9rdEgpHzYcQy5fDli2JrZtV6Y+LmPFa3R4OoHq0puyPALySgWVszTKYuzAx4vpXIpJ+MwgYCMRImnDIolToFFjCWKUdqOCSPXDkaVHquXsgrhtCfOGi54A50x/bNgAxlpceWWD/yGtn1YHG+MqJBDE2FEQfygiqY2vHtFqOelc+TfF+mb4JvDFq68N5GOoXo6gPWvkBbM0GOPwm+CfQ0+XHBZyzd9Fe6iA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: <16FAA9AC9E2A324FA5E4BC2FC9E59BCC@namprd21.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e702149-fb89-4029-e9b8-08d59dafe7df X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:19:46.6921 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0936 X-Virus-Scanned: ClamAV using ClamSMTP From: Paolo Bonzini [ Upstream commit 51776043afa415435c7e4636204fbe4f7edc4501 ] 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 Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- arch/x86/kvm/x86.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) -- 2.15.1 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index b9afb4784d12..d7728bcd9a3c 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4225,13 +4225,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; }