Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3924427pxj; Mon, 21 Jun 2021 09:29:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeBAYnnsWwytX8cGyOETWM0K8sXlL+KWxrpAC/yXHFmsALazL+8ViX6YMOlhZsB7LNjnju X-Received: by 2002:a17:907:788d:: with SMTP id ku13mr7969771ejc.245.1624292950211; Mon, 21 Jun 2021 09:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292950; cv=none; d=google.com; s=arc-20160816; b=GACrbHQavIfJrpFASjDRiGGfdqbirTXsXtYUFrQBQNk6hOhCalCKuVqd9Nnqu1HqF1 IfVv7NjaHxC6y8APCsAba8vFSixgfpF1fmEiny5ufK4oobxfFh3H4U4QbWaF8OhOBmUr vvrYH0FVh9NKuHjmESJusOiDoexRnfzd/cV5wPc+aKOEwSTK7byOCk6IFpqIUL9o3u01 JEyXmcvsgTNX11vm7cecCGuqPUwQSlVAi7R2PfIdV4rq34mc3SY1toJeejdISP9Iwca8 0LWY8bi5AVo8QUEl0AstBRc8g3k1vjwCNKrcZA0ZTta+NoYyRIO3BEcPV6qJsELckFOm Lv0g== 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=t7ymVL9JQIagbFUkXMSIFRzmT2e0dir2bXY/8WhWJDE=; b=PMi+XdA86BoTg1LUBT9u4Y0q7PKTBlsZBt+WUX/xppPRtUfn40bKhdzhHJFOvcgNh7 D663PrCBbZXrXNBypon/hAS9L/qRRxCnI22JRHbFlkpdjFCLd8h8p1bgpP4IT1hcKaPF yFe6L1Eiji5zfGwWh48sOC2L7qhijUEvYf0WuiNnj97LtC4y5Tgt42cMhqOrbW0Zy7qm oQ+/cOrDRrf9YaYxqF+D7IbBa2JrBnLUzekHMKXvdyODuJiI/DqdSEKPryaLhVmt6SF2 INTSFFJ3ESsTHlE4szSfExOh4NcZkEzc/6fE579AtUlykb8tppws40xlDyJkIFLW65lH wRcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k90br6+G; 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 i11si1848408eds.153.2021.06.21.09.28.48; Mon, 21 Jun 2021 09:29:10 -0700 (PDT) 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=k90br6+G; 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 S231985AbhFUQ2I (ORCPT + 99 others); Mon, 21 Jun 2021 12:28:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:48560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231162AbhFUQ0X (ORCPT ); Mon, 21 Jun 2021 12:26:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D38C761164; Mon, 21 Jun 2021 16:22:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292540; bh=hiPF+RosvCLDuD/Y/PuMlF+/+Zt7YBkW3724fIap3sk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k90br6+Gk3ROt8hUfxZnL4kEwaLMvxqmEX8xSqkNgFnazNKsYOIqmbc2VgPAM6GzN s4fdcjrpDBlCRDNdrrihcSkGSkVhttCo3pI7eMMhnfGvlRHTlspF6VytHHC20me+XG rN08I5ulY/JmzvSCZh5B9VcM4jGbCY7r+Im6+Z7A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jim Mattson , syzbot , Paolo Bonzini , Sasha Levin Subject: [PATCH 5.10 010/146] kvm: LAPIC: Restore guard to prevent illegal APIC register access Date: Mon, 21 Jun 2021 18:14:00 +0200 Message-Id: <20210621154911.603988175@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154911.244649123@linuxfoundation.org> References: <20210621154911.244649123@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: Jim Mattson [ Upstream commit 218bf772bddd221489c38dde6ef8e917131161f6 ] Per the SDM, "any access that touches bytes 4 through 15 of an APIC register may cause undefined behavior and must not be executed." Worse, such an access in kvm_lapic_reg_read can result in a leak of kernel stack contents. Prior to commit 01402cf81051 ("kvm: LAPIC: write down valid APIC registers"), such an access was explicitly disallowed. Restore the guard that was removed in that commit. Fixes: 01402cf81051 ("kvm: LAPIC: write down valid APIC registers") Signed-off-by: Jim Mattson Reported-by: syzbot Message-Id: <20210602205224.3189316-1-jmattson@google.com> Signed-off-by: Paolo Bonzini Signed-off-by: Sasha Levin --- arch/x86/kvm/lapic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c index 5759eb075d2f..677d21082454 100644 --- a/arch/x86/kvm/lapic.c +++ b/arch/x86/kvm/lapic.c @@ -1405,6 +1405,9 @@ int kvm_lapic_reg_read(struct kvm_lapic *apic, u32 offset, int len, if (!apic_x2apic_mode(apic)) valid_reg_mask |= APIC_REG_MASK(APIC_ARBPRI); + if (alignment + len > 4) + return 1; + if (offset > 0x3f0 || !(valid_reg_mask & APIC_REG_MASK(offset))) return 1; -- 2.30.2