Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3010420ybi; Mon, 17 Jun 2019 14:37:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqxxuciFyUWjAxtWHT+dRcLSlG7sjdJewwF8vhDTXdX8wGVmQiwnQostOakaRUN0VbRdC5bS X-Received: by 2002:a17:902:9f93:: with SMTP id g19mr94506731plq.223.1560807438614; Mon, 17 Jun 2019 14:37:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807438; cv=none; d=google.com; s=arc-20160816; b=jtqsGISMb3gEFXcfGb7LmXtp5VJVK4ydfeJykG7lFsY0gsy/BhtH8LZ7DpGc6FC1WL vneWxbwGsB164VcY9oX5qUdhQR2BFfRndIFm03FTHP0iE33ec3k1UeMtKC+GrCVu9OeE mnyCWmUlXr+D1B5Z80wemhLS8DmSvx9ZmxcJ54p9Rm9S74NpfhjC/Y+rAFUAPnxP61wY USVlVf72neESHPLS/OGJQmhm5NP/Yzv86D2rowcK8QWcr904OCsSHFR4PYJEtE3WTBN3 ktcVzmX/Ic9zhWjUWRniO2zDRrjS/VQtFYg00FZ+aseXxEwyU9YvYOQXp+yW56mspX6D t3CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PFmN20NX0/kMAaUlCmZmzht6SSwdTnZxWVP5yDIfcck=; b=S4ZMIXJbSwUZw5T0FHxu4w7AuTtb/U0fV22EXpHaYsdAPw9rp55sFIIBt1RRUL1d0n 9loM5gF63+JT0j2RbfbyVS3uERgrMLSIfznloGPFKXAWqhPZzDNro+NPcXT3/p/kenS+ HoyYzPGZpSoY07xuG+fbTrF18+1e/7XV7mgwD6xchO8HDqmHpzzSBJCrtdfngrICmG1p Zo/4kb0izF/5kRWZd/2vq16zlzZnfd0Pq+8avoai7dWAHjbEcqBDx0QXSqhz+wAOADwL 1jsiSxbNay1FGB0iAIv3xME939Rys4T/7/0/vEDe5j84MsQ+X0+le/kvXxlXQBEF6HeD ziyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VJ70kvQ9; 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 y11si11073370plr.381.2019.06.17.14.36.55; Mon, 17 Jun 2019 14:37:18 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=VJ70kvQ9; 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 S1729556AbfFQVf6 (ORCPT + 99 others); Mon, 17 Jun 2019 17:35:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:46842 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729501AbfFQVWR (ORCPT ); Mon, 17 Jun 2019 17:22:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E7D420861; Mon, 17 Jun 2019 21:22:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806536; bh=s5fDWmwWmrDxUH/d22JDRo/fiF3jlxW6KHX6xmItwZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VJ70kvQ9HZsZPD/SBJQcudOSEDEY8fza83VGjDO2pS5xr1WkOuR2t03tw68Zv6bKz pG/mGd0R2iI21eA9OvSkDgzdMZMsv3WsI7lZPENvuEYcUOiaOTeMNLm2m4zyan1Ssn 3bGvOPNOzCvsUUPgHe9KS3Q3Sks8wFLrVX2fYebA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Bonzini , Sasha Levin Subject: [PATCH 5.1 084/115] KVM: nVMX: really fix the size checks on KVM_SET_NESTED_STATE Date: Mon, 17 Jun 2019 23:09:44 +0200 Message-Id: <20190617210804.287554747@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210759.929316339@linuxfoundation.org> References: <20190617210759.929316339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit db80927ea1977a845230a161df643b48fd1e1ea4 ] The offset for reading the shadow VMCS is sizeof(*kvm_state)+VMCS12_SIZE, so the correct size must be that plus sizeof(*vmcs12). This could lead to KVM reading garbage data from userspace and not reporting an error, but is otherwise not sensitive. Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/vmx/nested.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c index 8f6f69c26c35..5fa0c17d0b41 100644 --- a/arch/x86/kvm/vmx/nested.c +++ b/arch/x86/kvm/vmx/nested.c @@ -5467,7 +5467,7 @@ static int vmx_set_nested_state(struct kvm_vcpu *vcpu, vmcs12->vmcs_link_pointer != -1ull) { struct vmcs12 *shadow_vmcs12 = get_shadow_vmcs12(vcpu); - if (kvm_state->size < sizeof(*kvm_state) + 2 * sizeof(*vmcs12)) + if (kvm_state->size < sizeof(*kvm_state) + VMCS12_SIZE + sizeof(*vmcs12)) return -EINVAL; if (copy_from_user(shadow_vmcs12, -- 2.20.1