From patchwork Mon Apr 9 00:25:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10330611 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 957AA6020F for ; Mon, 9 Apr 2018 06:10:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89738288C3 for ; Mon, 9 Apr 2018 06:10:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7D9FC28A67; Mon, 9 Apr 2018 06:10:26 +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 47FE2288C3 for ; Mon, 9 Apr 2018 06:10:25 +0000 (UTC) Received: (qmail 5847 invoked by uid 550); 9 Apr 2018 06:10:13 -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 29992 invoked from network); 9 Apr 2018 00:33:02 -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=m19RtP4K9mzNhiGu7fmdBRGsAMIhCTbOl6/n+rhR3aM=; b=WeBHn7gSnDOdiBn/5BQ+Mjgby2rwRe9hhVnerQFAT5G/o5p0Hk60TOU0PgCk9hKofCND9hwGeGomkI7Tuk7yRQh03+xIZHkaDm8NvBIEaeaFr0nFAWfbISqH3gF3/jmLbAu+G0IfjrTZl3UOujMabFhYfDpnaj+Qp9aiJiJhhLM= 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.9 215/293] kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl Thread-Topic: [PATCH AUTOSEL for 4.9 215/293] kvm: x86: fix KVM_XEN_HVM_CONFIG ioctl Thread-Index: AQHTz5lL7lbkSmQk5062M9BXOwIO/w== Date: Mon, 9 Apr 2018 00:25:42 +0000 Message-ID: <20180409002239.163177-215-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-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; DM5PR2101MB0998; 7:2dWjdTArCSHDdyY4zVQ0v4WEI1dlZ3TNqPyMRSSCY1dw/Ta0hB710soNLG6ZS7QlQk6x9vdcMaFlNYK2eVDSjlaViOmF+a8Gk1j+eYVw2fdzdrioiIcC1ESJwVLpZc2LQQGneLmFz2DOnl5WfpT1vAJtECQlfTKch7avE6XChjun48X+md+eeLjlj/kTZnbSbGqWPrt9zrEe44xzqRu3DN7EyEyGzS1iXDVw7e+HcPpy7BXRVhHX5m7mhP7fzOMP; 20:UR8uIZ1qjg24mNnqcMyEe7w5VuS+pqUOmo2L4yF9SyDJBYpqSgV7mi81x5t2NxWWWyhuZKiXUA/xFX/lsyoRd5kZkW/wXC6pq4cH/oXXzjZeB4VhV+A7CM8j4Z7LRV0LikU2IikBfom8aGeZ5rFIHwTmM5I7Y1gFJslHZxZGqr8= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: e97b7518-358b-4c92-e299-08d59db16bb2 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020); SRVR:DM5PR2101MB0998; x-ms-traffictypediagnostic: DM5PR2101MB0998: 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)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011); SRVR:DM5PR2101MB0998; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB0998; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(39380400002)(376002)(396003)(366004)(39860400002)(189003)(199004)(25786009)(59450400001)(105586002)(14454004)(76176011)(68736007)(2906002)(316002)(97736004)(8676002)(86612001)(3660700001)(3280700002)(102836004)(6116002)(4326008)(8936002)(36756003)(22452003)(81166006)(81156014)(54906003)(6506007)(10090500001)(2501003)(6512007)(186003)(6666003)(3846002)(486006)(5660300001)(26005)(7736002)(5250100002)(305945005)(99286004)(2900100001)(110136005)(1076002)(6436002)(53936002)(106356001)(107886003)(72206003)(86362001)(476003)(446003)(66066001)(11346002)(478600001)(10290500003)(2616005)(6486002)(22906009)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB0998; 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: B/x9Va+goUNIjvAiL8gmgtfywVx1HkDcqzuWK30aPtt3Jp7WC7SvSqq/TR7oSxV2cKzwbt2tCFLaGVMS6iXEdlNF85Wc5ev7ILWYDVlJePX5xCVIecVPG6yW3LFzGOTG93kD/W7+5Al9cHNx4qK60pKbwS60kLvwTxK+M5r6F0Nm4fpzcH6a+HcmexpcZfaBHPAb1prBr74KmOh+Z+m40W/iOnqQ5trlGA8zGphxliBVJ+z33nk4SHsV3KgOZzlR4vVb1UgOSVlB1l77f2ckDFO+Z1AthotgM+BQYc72jHPkVq/3MiU9yIzW2Zk48QkP4YpyxkCga6ifJYytX3jTmjajU/yK96pgk/OkAdlDls6QW0s4xMzFXEf6hPQcpEkHdR8X10lYc5+pK29LRyWaxA0xFKJT9N6i3BVNKgJCcZI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: e97b7518-358b-4c92-e299-08d59db16bb2 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:25:42.2066 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0998 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 3aaaf305420d..803bb452aac6 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4130,13 +4130,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; }