Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4171819pxb; Mon, 8 Feb 2021 09:33:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxG4QyuU62oY2aqT4UIJjIlfEmtaKTKG0Yijlf6AltiG8+khRpXo3vWxzHtHFCK4pTYqWoH X-Received: by 2002:a2e:834e:: with SMTP id l14mr12123605ljh.394.1612805594378; Mon, 08 Feb 2021 09:33:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612805594; cv=none; d=google.com; s=arc-20160816; b=bZOsAEUxbWkrpGx88E3uQ5FjOGovR0A8QgCTyDYTcVV42mF5VRYZd81CH3PIY1jcd6 D2r39k7sIlDo93/KG3NzzfDxOYnpjENqeDg5NGfJSuPE+6Qv/gXX1Hona4ICP7ljraaO ONzPBRT4839KSU/n4Z6pfZpinW1Dndrt6DY2/JxP9qcvydlA8985hjOuGWXjGYSGkl7K 3n7J59IAnl4m9nQ44k7jKlzeKskufv6WMSyylIxQR70cbLs7fS6W7+70bzGjICfe5CyI vLfT4913dhDNkdmaa1H91a1lrdzk9AaP+/yzAnn9uANuJOn37uj9Jx+kubIoyD5UZVM2 j8qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ICFpTCY1pM2ISBNekkVhlHcJrN1vb0gY2QfMosPOYas=; b=0QUDIH+ZEmr+5pLuU3eM0y7zmil15Q7e7qt5Wxx4PP6JV4BsgNrXd5AAhoIBA4L47w vYwxOZLL8elRWTWVgI0lcJ16jbKZaZjTFSTkc7cvruCf1vuqYqPfFH07kdmmgydWhjRe dMMzw4wDlu3wM+mOMVr2ziKH4WgBxPfNlHs8Wi7DhbKGTIgGtCVmGBtIMaf+Kq3Eu03f jIiR9WYaN1uzRvihAnwYbo8WHPzAgy4cFdSMOQGukaaqsuDj+JQ43Bttkhn5t0ZY073c QLK5noKc+yG6P1LZ5qHK1jKlUNmbnH8pCqKtyGxvDEyabjNtLLc/m6BaUvSvwkj50D+I epUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=okd9l0tM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si11864849edv.129.2021.02.08.09.32.49; Mon, 08 Feb 2021 09:33:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=okd9l0tM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234803AbhBHR3b (ORCPT + 99 others); Mon, 8 Feb 2021 12:29:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:37328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233940AbhBHP2m (ORCPT ); Mon, 8 Feb 2021 10:28:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1441264DFF; Mon, 8 Feb 2021 15:16:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612797388; bh=YccDqjeajWkEGxaKkOyAcu5JCWanzuFJHF2TtT2eRg8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=okd9l0tMkMpj2CVjJKdDmpafm13ByfD4cGsm/ek6bcbhyoabILrwt4yJ/zSL7He1a RRxih9JUNSKZiYViNtFFsrG5m+2BwWWd/Pt8M8/eq2YH5VsL6edXnF+LwhlLWAFbSO am913Qnx26ipm2iIhZaBgXZvCbB4gMYaz5WSmF48= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Michael Roth , Paolo Bonzini Subject: [PATCH 5.10 091/120] KVM: x86: fix CPUID entries returned by KVM_GET_CPUID2 ioctl Date: Mon, 8 Feb 2021 16:01:18 +0100 Message-Id: <20210208145822.032288504@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208145818.395353822@linuxfoundation.org> References: <20210208145818.395353822@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Roth commit 181f494888d5b178ffda41bed965f187d5e5c432 upstream. Recent commit 255cbecfe0 modified struct kvm_vcpu_arch to make 'cpuid_entries' a pointer to an array of kvm_cpuid_entry2 entries rather than embedding the array in the struct. KVM_SET_CPUID and KVM_SET_CPUID2 were updated accordingly, but KVM_GET_CPUID2 was missed. As a result, KVM_GET_CPUID2 currently returns random fields from struct kvm_vcpu_arch to userspace rather than the expected CPUID values. Fix this by treating 'cpuid_entries' as a pointer when copying its contents to userspace buffer. Fixes: 255cbecfe0c9 ("KVM: x86: allocate vcpu->arch.cpuid_entries dynamically") Cc: Vitaly Kuznetsov Signed-off-by: Michael Roth Message-Id: <20210128024451.1816770-1-michael.roth@amd.com> Cc: stable@vger.kernel.org Signed-off-by: Paolo Bonzini Signed-off-by: Greg Kroah-Hartman --- arch/x86/kvm/cpuid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c @@ -320,7 +320,7 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm if (cpuid->nent < vcpu->arch.cpuid_nent) goto out; r = -EFAULT; - if (copy_to_user(entries, &vcpu->arch.cpuid_entries, + if (copy_to_user(entries, vcpu->arch.cpuid_entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2))) goto out; return 0;