Received: by 10.223.185.116 with SMTP id b49csp6406515wrg; Wed, 28 Feb 2018 08:54:34 -0800 (PST) X-Google-Smtp-Source: AH8x224Gs+Q/syk5ejqKFkURYzluy4nYMlJkRkw5fRD2/CVgwlOvYkbzg3JBKVODHbiAXHZ/3dj/ X-Received: by 2002:a17:902:710f:: with SMTP id a15-v6mr18208455pll.87.1519836873966; Wed, 28 Feb 2018 08:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519836873; cv=none; d=google.com; s=arc-20160816; b=y3S452Di6TqOjw8qWlFLwFFlRRBDsvBocYCscbA29vXqQNKB3s4b/mec+5bq89nLIY 84QaYSUSn5jEz4v+Gzb9ioPQI8EOXbIAoXwZANXW377h/JOwgfX1iDnMtEU073qIj4Mv OygPs7oXy4n4f7BmZHjHQHe3zEiHlWTpUxU52IYmTrmlpysUCYsX7oXlJTDf9euoC8SU zzfJ6ElhpRnJitcFdja+ruOEqI8twhhKHZAJNpQk7l9fS+bscdiZJ4xDnCJVKdFAf9WF 6x71Ywb3+yMwmdRcDxoREItAafeOMWDN8ZV+uA9RYFKyopw+CcYuhY3wbOb4UXgy7w38 dpvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=g+ug6HtKSgdbdy7B324B560Qdm9vjYpgv9+aQEagm/E=; b=bRXGm6GfKl+soZx8LNSI9rEAlNtqk6DZ5DgjHS6CavhuIC3fPzCeNI600dKSe//ANY efCjtblOp7uNp6tMxUnRbj8bO3CWDapJdJ3R22I6a+h06gqq7ubHbyjq1Qb+P+nbKHFE x6cUPtgnFOlHoyDcPkKvpU583QNl2ECKnoNmv2f9hG2y4EeuLi4mUWRkpCCbkV4QMZBJ GwPIsx+zrqt6VcGuHDW+ftwAZQW5InROLIyepMwEkrfkn1dfBDDnYkBjae2XSD6lNxXv EeBGhUdVcrqdZXeDd46HQE8aZm6LcwRYzlc3g1zobF37I3ceEAaI4SS0CQLujN+1ouGA GkQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u25si1219802pge.222.2018.02.28.08.54.19; Wed, 28 Feb 2018 08:54:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932872AbeB1Qxk (ORCPT + 99 others); Wed, 28 Feb 2018 11:53:40 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34537 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933746AbeB1P57 (ORCPT ); Wed, 28 Feb 2018 10:57:59 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Ys-0006Xd-HQ; Wed, 28 Feb 2018 15:22:30 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yg-00005s-Ld; Wed, 28 Feb 2018 15:22:18 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Radim =?UTF-8?Q?Kr=C4=8Dm=C3=A1=C5=99?=" , "David Hildenbrand" , "Wanpeng Li" , "Paolo Bonzini" , "Quan Xu" , "Jim Mattson" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 112/254] KVM: X86: Fix load RFLAGS w/o the fixed bit In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Wanpeng Li commit d73235d17ba63b53dc0e1051dbc10a1f1be91b71 upstream. *** Guest State *** CR0: actual=0x0000000000000030, shadow=0x0000000060000010, gh_mask=fffffffffffffff7 CR4: actual=0x0000000000002050, shadow=0x0000000000000000, gh_mask=ffffffffffffe871 CR3 = 0x00000000fffbc000 RSP = 0x0000000000000000 RIP = 0x0000000000000000 RFLAGS=0x00000000 DR7 = 0x0000000000000400 ^^^^^^^^^^ The failed vmentry is triggered by the following testcase when ept=Y: #include #include #include #include #include #include #include long r[5]; int main() { r[2] = open("/dev/kvm", O_RDONLY); r[3] = ioctl(r[2], KVM_CREATE_VM, 0); r[4] = ioctl(r[3], KVM_CREATE_VCPU, 7); struct kvm_regs regs = { .rflags = 0, }; ioctl(r[4], KVM_SET_REGS, ®s); ioctl(r[4], KVM_RUN, 0); } X86 RFLAGS bit 1 is fixed set, userspace can simply clearing bit 1 of RFLAGS with KVM_SET_REGS ioctl which results in vmentry fails. This patch fixes it by oring X86_EFLAGS_FIXED during ioctl. Suggested-by: Jim Mattson Reviewed-by: David Hildenbrand Reviewed-by: Quan Xu Cc: Paolo Bonzini Cc: Radim Krčmář Cc: Jim Mattson Signed-off-by: Wanpeng Li Signed-off-by: Paolo Bonzini Signed-off-by: Ben Hutchings --- arch/x86/kvm/x86.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -6471,7 +6471,7 @@ int kvm_arch_vcpu_ioctl_set_regs(struct #endif kvm_rip_write(vcpu, regs->rip); - kvm_set_rflags(vcpu, regs->rflags); + kvm_set_rflags(vcpu, regs->rflags | X86_EFLAGS_FIXED); vcpu->arch.exception.pending = false;