Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1266917pxb; Sat, 15 Jan 2022 07:22:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5gE0qaB2jAaNl7wVo9+ld7CG+RUumAyija0eDr2AveWpu7t+q8N2O4JzNblAkuCBwJFAU X-Received: by 2002:a17:907:7e99:: with SMTP id qb25mr11009079ejc.18.1642260173187; Sat, 15 Jan 2022 07:22:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642260173; cv=none; d=google.com; s=arc-20160816; b=y3FzqhgU2reexQGWU59N9nv5a1LfZ6oeytx2mP/+u3BK2cHBsWnRjH99kRJzMSH8/6 FmlER+YxvcNugof85kmbV2hXKgSUxxap+AQG6hCFSGhhgP49OzEsMkZ+94K+zrd3yFW6 RZUDPT41KCAuHib0HKODISnAKhmHyc986mjyByh5jA66hJm7BBa9wyO887weWB2PEiwJ melnOYj4n+Sx5TLdTBa1jsDh55OOMhuVUa7eYcCccqLz3Q9MqaJYZgEBMlG/wYZI0Hc/ 3kdPAoDMr0/gkTvmBme0f7X+beL3q9QOFaHjikXhca4bOAn6eRvtvBy71BvpcMg6/tXX rxfQ== 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:dkim-signature; bh=+j5pnXuzi9c+ZqSBpV9r5rPAewuPcYTxpqq3heBNvJw=; b=JIX7XRhCw6AsoqRpH2zNk+aTtj2SCWr7D5JXqoRo7/0xim7WB04CnxeHoVI85z8f+N jfpEzTK5TVg9ZIFkrmCLOvLNry4YuZJ7v9XnFQo+M+VYbtXlzIIH49MpKGf2W9YyFUp8 gnbhNR8I3OKwZzVZY1bMqYbhHmG8/u9/8NmEZTQSbRaoCRngEejQutKNgdCm12wVmXv5 RF/OR5CCKi3EmbvnzmVH6dzs/khvmJQCM0Fv8j4v+ZwEDwsAZwVJOuGTRldeF8cC1eVG nAXmzoCVjr35NCaugmSgEXjFY09dQ+T6ILS5tYSlcdsdnOqgBBMjR82e2Yn1oiny7Ib8 RnxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DWDCninB; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v9si600783edc.193.2022.01.15.07.22.02; Sat, 15 Jan 2022 07:22:53 -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=@kernel.org header.s=k20201202 header.b=DWDCninB; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231910AbiAOBST (ORCPT + 99 others); Fri, 14 Jan 2022 20:18:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231905AbiAOBSS (ORCPT ); Fri, 14 Jan 2022 20:18:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1A61C06173E; Fri, 14 Jan 2022 17:18:17 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7154E620CD; Sat, 15 Jan 2022 01:18:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5603EC36AE7; Sat, 15 Jan 2022 01:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642209496; bh=brmYZ4xsVJ9RXGnMsvg9QqXh7sxIldild9tW5Lgpe0E=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DWDCninBjNgm0moqa+yAl6prAEwa+NU8DPl9Eywp98UqLKkfYMkaUMGMJ5fGL47UV zhnU3GceFNsbVnJHyCPAbcR9wwP1KwxovDqog6RsI16fYebjyC828eoM92vR0eNQm2 yMbueFP5OGsUp/rgyZRkmpQ6ZpXrMi1Vt/XlkJ5ww5sJzxNook3/QHlPWeHve87hqg 6Pp/qbzPf06l3j3DYAB8oYOKFxjHIL/6uYEP4Fj/lgc2mddk6dENyCbB4qrZiZH+xT QU7yOsVvXY1UwmX1Sk29amhpbYPKnJcDMoKTStGonwSZh8MAeX+yeRwYlyZhcEcM80 2pSJoDqNXXb9A== Date: Sat, 15 Jan 2022 03:18:04 +0200 From: Jarkko Sakkinen To: Reinette Chatre Cc: Nathaniel McCallum , Haitao Huang , Andy Lutomirski , dave.hansen@linux.intel.com, tglx@linutronix.de, bp@alien8.de, mingo@redhat.com, linux-sgx@vger.kernel.org, x86@kernel.org, seanjc@google.com, kai.huang@intel.com, cathy.zhang@intel.com, cedric.xing@intel.com, haitao.huang@intel.com, mark.shanahan@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 05/25] x86/sgx: Introduce runtime protection bits Message-ID: References: <168fb2c9-de3f-384a-bb17-ab84db2cf533@intel.com> <6e1cb295-b86e-ae09-2cf0-cfefd1a10e65@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 14, 2022 at 04:41:59PM -0800, Reinette Chatre wrote: > Hi Jarkko, > > On 1/14/2022 4:27 PM, Jarkko Sakkinen wrote: > > On Fri, Jan 14, 2022 at 04:01:33PM -0800, Reinette Chatre wrote: > >> Hi Jarkko, > >> > >> On 1/14/2022 3:15 PM, Jarkko Sakkinen wrote: > >>> On Fri, Jan 14, 2022 at 03:05:21PM -0800, Reinette Chatre wrote: > >>>> Hi Jarkko, > >>> > >>> How enclave can check a page range that EPCM has the expected permissions? > >> > >> Only way to change EPCM permissions from outside enclave is to run ENCLS[EMODPR] > >> that needs to be accepted from within the enclave via ENCLU[EACCEPT]. At that > >> time the enclave provides the expected permissions and that will fail > >> if there is a mismatch with the EPCM permissions (SGX_PAGE_ATTRIBUTES_MISMATCH). > > > > This is a very valid point but that does make the introspection possible > > only at the time of EACCEPT. > > > > It does not give tools for enclave to make sure that EMODPR-ETRACK dance > > was ever exercised. > > Could you please elaborate? EACCEPT is available to the enclave as a tool > and it would fail if ETRACK was not completed (error SGX_NOT_TRACKED). > > Here is the relevant snippet from the SDM from the section where it > describes EACCEPT: > > IF (Tracking not correct) > THEN > RFLAGS.ZF := 1; > RAX := SGX_NOT_TRACKED; > GOTO DONE; > FI; > > Reinette Yes, if enclave calls EACCEPT it does the necessary introspection and makes sure that ETRACK is completed. I have trouble understanding how enclave makes sure that EACCEPT was called. /Jarkko