From patchwork Mon Apr 9 00:16:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10330607 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 19A5260236 for ; Mon, 9 Apr 2018 06:10:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0F9B288C3 for ; Mon, 9 Apr 2018 06:10:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E26CD28A67; Mon, 9 Apr 2018 06:10:12 +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 5439B288C3 for ; Mon, 9 Apr 2018 06:10:08 +0000 (UTC) Received: (qmail 5313 invoked by uid 550); 9 Apr 2018 06:10: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 Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 1976 invoked from network); 9 Apr 2018 00:17:05 -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=nmLZ6PICmnkQ7Ak96hMNM8tUc6ILXuATc3JDN89ycc0=; b=mG9l/XYhWA+42T6Qk8semsvYL9WYtiQFxCKiTNV5khJVPu05kSZLdCg9u7IRbzH/OlJGQgik6yMtm7RFILxI7hSfgp+byySxLj4xYNldFMDd3Jl2LFOTwW4TT0btODNHdhQ5v79ecbJbkZCqNYZXlZoYnEsNCZXDMI1aIaXDIXI= 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.15 010/189] kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl Thread-Topic: [PATCH AUTOSEL for 4.15 010/189] kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl Thread-Index: AQHTz5gOnBzLsCCmoEC2C9zv4twziQ== Date: Mon, 9 Apr 2018 00:16:51 +0000 Message-ID: <20180409001637.162453-10-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-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; DM5PR2101MB0968; 7:faCsU/p/hQzS4ysCGnfy3bh8qDT4fh+FVRJ9fJnnKDNhvlO4NmhDxNnaffmthUAheziaoVLhiXE+/47ZBOCh9AshjsaVQzhD4hnQaYlKTvdqIrQrwsaHzbnME90kHBQHu6EHEaOZTMiqZl4992HXOv48CTjFtuYEWg1GQSyapxK+DxIY/cA3y4gXwvlNLEtge6T6UrJ2UQccrxOTZenymvJs41kHJ6uy69//vCz67zyTSRRxPPlrCmTtbeieChNh; 20:YxsM4/EffLtiF76stdR7kzlhqBteUJrOczK7faaPKaDUdxY2/uSgojnRJkw2XN0XUrMGsipzZOA0UnMgF+w++n+ITKL1B5FCe3cbSARuEV2vGpxL2SZnqENibkp/rKj98FKehHqKx9pAm8w7NLdviss0Rlfn28WmZ9djuYgkBPk= x-ms-exchange-antispam-srfa-diagnostics: SOS; X-MS-Office365-Filtering-Correlation-Id: b6a33908-4ddd-40cf-8c30-08d59daf3190 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(48565401081)(2017052603328)(7193020); SRVR:DM5PR2101MB0968; x-ms-traffictypediagnostic: DM5PR2101MB0968: 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)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:DM5PR2101MB0968; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0968; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(366004)(346002)(39380400002)(396003)(189003)(199004)(6486002)(53936002)(107886003)(81156014)(36756003)(10290500003)(6436002)(81166006)(5660300001)(478600001)(8936002)(8676002)(6512007)(106356001)(105586002)(5250100002)(2900100001)(7736002)(305945005)(2501003)(10090500001)(66066001)(25786009)(476003)(3846002)(6116002)(186003)(2616005)(59450400001)(68736007)(6506007)(486006)(14454004)(86362001)(99286004)(26005)(102836004)(22452003)(76176011)(11346002)(2906002)(316002)(3660700001)(110136005)(97736004)(86612001)(3280700002)(1076002)(4326008)(446003)(54906003)(72206003)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0968; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: LYVhuHQiBHUuUs8jZsNHT3+iCEqc/EmesPCH7uhXQNGEXZTtwco6Djbcw9VzZ17Xu2ZlVMAR6YeFCtoH+v3cWcOZl640Rui5Q5Ho+XPBMnt7H54kqugih6y0rU71/4rKs/24x0YWRBCP3rYfxZ+3bvUaKd8DFX1Q2VGKehyTkNp7nGBRG/+YzSJCmfIt8nUbpdqUvBfRpZNTdDZbK1Rh0V5P28PNuviMe+oAx5YWunGEb8Lz7LzzW2/24WtmiD1Iq8n7R62717qVvKVTwhytsKAOVtpX5p3klFDLi8xGC1EkFyakOByFqe1WiHK/5e9fzfnDmbVX+1emEmt4WKXmeMIYfAI52+AthCzH0wGE+fKgxP+jhhoqv1D0zfllMtAjCgboExItCngPO26H6FWwn+cR1FltxWTDADhn2d9WVok= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6a33908-4ddd-40cf-8c30-08d59daf3190 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:16:51.7937 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0968 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 a10da5052072..41a8ac44d5cc 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4244,13 +4244,14 @@ set_identity_unlock: 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; }