Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp865185qtx; Mon, 31 Oct 2022 16:09:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48cbeNoXLVF8t8RJsi9LSF9yRHr7N3Z3D9ouO8Q7vPH90Zp54vRIrC67Uwb9bdH5Tns+yj X-Received: by 2002:a05:6402:1e89:b0:461:a8b5:402a with SMTP id f9-20020a0564021e8900b00461a8b5402amr16401353edf.336.1667257757732; Mon, 31 Oct 2022 16:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667257757; cv=none; d=google.com; s=arc-20160816; b=wyZd3vCjmFEuDZHUMS8sXlp2KHr9LZE1ZngE8yyTkOFT4cJaLFXenn9TenCWzWPUmy jw40CoievtSNXGwj+lWccEVJrZInxVU8oY+gInyO/pw5WAc6EyWN4Rhk5YnpRmFEENry zphJHdpm84Ns8ytupklDWHl0GSlGeuw5p+VFccOoxUlR612iFndG4eyymzAJClqOENRM xQraG/iw58Ov9ZtdKcUZcx/+vVzJrBX/I18tK4c8wNk7vPbG0E5VZOVE64z89g8q/6sA b6zYMTL85ISI7pyn7oLE7u52OmgCPuat/i8iyDPLrMP1XwEejBTFKav/XpMZK5zTDpGN j+Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=P2To8pd8U1V8Fl4iGAG6PjXd2z9/oOB21lRwtDYJXYE=; b=oG98CZAuOacRiIvwWOQyjHo+vixxyu9cuZgwYg0D9ffMm3lCK3pGY33Cr7ueFqjJLM lqzoK5oBYCOqjWHx3fxeqOprEY9cDlUz3F1dYoYag3CKsXe/fadcv9K+3e7we+pj359I YNKIcjHXPthibaMJyAQ6zgwPsszfnfA22EQVy+XlWlckRkvOO+T4gCLr1UckqpJoseq3 b++nnYo2t2W1+TOUEZTljOjrXleoATc9YA2SmoeMYGr2GPA9Rg2WPRhSlA75N2yLfugv Ce+cNCw9TeHLXHjiAB6jjChZIZ/oB0x0AWr8YEpP/ncHTPTYVkd/KiS0Mg6yfUBN1CCo aUhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=AApxNhdr; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=QovQ7ytS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hp22-20020a1709073e1600b0078e54eda758si9889809ejc.611.2022.10.31.16.08.53; Mon, 31 Oct 2022 16:09:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@shutemov.name header.s=fm2 header.b=AApxNhdr; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=QovQ7ytS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbiJaWKW (ORCPT + 98 others); Mon, 31 Oct 2022 18:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiJaWKT (ORCPT ); Mon, 31 Oct 2022 18:10:19 -0400 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EF45D46 for ; Mon, 31 Oct 2022 15:10:18 -0700 (PDT) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 0AB395C015E; Mon, 31 Oct 2022 18:10:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 31 Oct 2022 18:10:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov.name; h=cc:cc:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm2; t=1667254215; x=1667340615; bh=P2 To8pd8U1V8Fl4iGAG6PjXd2z9/oOB21lRwtDYJXYE=; b=AApxNhdrnS1G4ghZSF vMgogKKMEYRJyUXBm+X1ZAOgn4iVLYYc9DhpiDoM0gDP+VEKfjQyxjnzCOXDVoHe GhiRU0RulH1aLpOQPEgDaJofX8LuhSoLAVd0ivJ/034gDuGGW13nmAT2icnQetSf po1mTbrOR5D/6UmJ2hogFFjjDX+aLwu+k42E7VhfErSzRv3pTsekAstmdaI/NVdV 4V/R4566NXcw1uLGPqOYCPCiPzxYlVhFJnQICDSTiQ2b6MqaihtGjPgHzhI7ZVb5 a5QE2C9h5GEqSvlS71ez6geeu+ywwmXVATiNIlGaaCYsmZ3Bwtx7eBaGyJlvmbxQ S7WQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1667254215; x=1667340615; bh=P2To8pd8U1V8Fl4iGAG6PjXd2z9/ oOB21lRwtDYJXYE=; b=QovQ7ytSfiTGTMgM0KEw6Ys+gcWj21ujz/vyxzcJyyoX /8+WgRiIeLlj4RaoD49HoaUZufMUeGJ3a9k02deq4hVkVBYoi+CV5Ts1ROZ820zC 3DfIg2I5ApeRH4TQS8DieelcbJ7LXkqiiPG3QSJ5RndE2oojlQt4ZFVLZ4wzCwk4 yRFkEztYoV2BmblwMh/CG6uFFQ7QqyFJeIp0bNfZpKLOFmshAZtWiXGo6Bh3bNlE QusWlN/bA0RkvrFPB56MZ+90tpqJnBA3/WxmXI0UQkAt+UgQP3C2zu8bkdrIT1fY LDmIfDuHLRF4xsd4KDIIaRVTHN7h94MHWw3+8GqjZw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrudefgdduheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdttddttddtvdenucfhrhhomhepfdfmihhr ihhllhcutedrucfuhhhuthgvmhhovhdfuceokhhirhhilhhlsehshhhuthgvmhhovhdrnh grmhgvqeenucggtffrrghtthgvrhhnpefhieeghfdtfeehtdeftdehgfehuddtvdeuheet tddtheejueekjeegueeivdektdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmh epmhgrihhlfhhrohhmpehkihhrihhllhesshhhuhhtvghmohhvrdhnrghmvg X-ME-Proxy: Feedback-ID: ie3994620:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 31 Oct 2022 18:10:13 -0400 (EDT) Received: by box.shutemov.name (Postfix, from userid 1000) id 4DFB210444A; Tue, 1 Nov 2022 01:10:11 +0300 (+03) Date: Tue, 1 Nov 2022 01:10:11 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: Andi Kleen , "Kirill A. Shutemov" , tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, luto@kernel.org, peterz@infradead.org, sathyanarayanan.kuppuswamy@linux.intel.com, dan.j.williams@intel.com, david@redhat.com, hpa@zytor.com, seanjc@google.com, thomas.lendacky@amd.com, elena.reshetova@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] x86/tdx: Extract GET_INFO call from get_cc_mask() Message-ID: <20221031221011.maiizaqbo3x37n2b@box.shutemov.name> References: <20221028141220.29217-1-kirill.shutemov@linux.intel.com> <20221028141220.29217-2-kirill.shutemov@linux.intel.com> <20221028235951.p2vdu7drbbf3ccg7@box.shutemov.name> <20221031041252.mdcjocqn6k4k4gvy@box.shutemov.name> <8887d182-a3e3-f62a-8b8f-36db1da75b19@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 31, 2022 at 12:44:15PM -0700, Dave Hansen wrote: > On 10/31/22 12:27, Andi Kleen wrote: > >> Moving panic() after earlyprintk working is not good idea as it exposes > >> kernel more: by the time we already have full #VE handler. > > > > It should be fine to move since there is no user land at this point (the > > attack requires user land) > > Maybe I'm misunderstanding the exposure. A normal MMIO #VE goes > something like this: > > 1. %rax points to some MMIO > 2. Kernel executes: mov (%rax),%rbx, trying to read MMIO > 3. #VE handler is triggered > 4. Handler emulates the 'mov' with instruction decoding > 5. Handler asks the VMM what the value of %rax should be > 6. Handler puts VMM value in %rax > 7. Return from #VE > > I think the attack scenario subverts a normal MMIO to the following > (changes from the normal flow are marked with *): > > *1. %rax points to some private kernel memory, VMM removes > Secure-EPT entry for that memory. > 2. Kernel executes: mov (%rax),%rbx as part of normal kernel > execution, not an MMIO read. > 3. #VE handler is triggered, assuming a MMIO read > 4. Handler emulates the 'mov' with instruction decoding > 5. Handler asks the VMM what the value of %rax should be > *6. Handler puts (malicious) VMM value in %rax > 7. Return from #VE > *8. Now the guest kernel is running with an attacker-controlled > %rax > > This effectively gives the attacker the ability to override the contents > of a memory read. > > Am I misunderstanding the attack scenario? I don't see guest userspace > needing to be involved at all. Looks correct to me. I think Andi refers to attack against syscall gap that also addressed by the patch. -- Kiryl Shutsemau / Kirill A. Shutemov