Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3302118pxk; Mon, 28 Sep 2020 13:46:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdhg2uPaON2Wnwf3VBguVVZ+zS3hMs3iX3BvvjTOpdlKXhDeaZfIvamXoPdYLCvc2jZo/Z X-Received: by 2002:a50:8e17:: with SMTP id 23mr3811868edw.31.1601326009821; Mon, 28 Sep 2020 13:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601326009; cv=none; d=google.com; s=arc-20160816; b=grMFWtOMM5KS5x8KxxuMY07hD6V1uDhKn0x3I5mwJym3EtlX4RZCDz4R11zmHLekob Dtjbbtn6QArJ8o8vaTHgEIF8m8Mk7aIbOSzr8WNjlfxDjYFYQS402ZsS86NQ9XdzuvN2 HvmeQCuZaWU+gBvLGc9j30bocQjNeM/XJGv0rgEkwjS+QqAcRmHeMJwnWojdnHAPGPPA ioIP/0LcOlMwlFjTQWL5ft0FxIElj8qIQ8Fn/iVGQsbwy7TMpQCSmjcDbNbpsTtBJm5q ExDXIA+IWpTreuhFr3J+h1EAXDvGcEadVXEl2WxtZv1wmZo/CkrpMndLg1UIhHliF/hX K2Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:ironport-sdr :ironport-sdr; bh=3LTLVimwfSI/7QxHf93NOHIhTflOmTv0W5+PHrbgGag=; b=ODOgVIk58/D1F/7eF+g6q/sQMJ+RqNMbwhxf3PP8d8U1w0UE+H9++iz/b2mDCcr552 BjCpiquPikNBalWZulm2yLPQDZ/nMKztj8mP/JK/zg3r1HWnYZCraaRYMN7uqhgYOjbk qtVOcnBdIA9fTpXBPLqE21FRiPkEUlsuTuD+jxjSbYNKpnfKdrCkdBIyvnTonkT5NFUo bv2OZjvbqs5MhSYCulE2UpVWsXZrgOzlRpmRe1Xjvi0zc98oWwplrdL7XHg7DXfzaPr1 d8kx1WbKLWiA/yF6tFHRYPSlLlodWCDgXAGv6BzqiwlkuOjvVvnnBHzrCqvR/WfB+vcB A0Qw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si1302063ejd.663.2020.09.28.13.46.26; Mon, 28 Sep 2020 13:46:49 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726865AbgI1UnI (ORCPT + 99 others); Mon, 28 Sep 2020 16:43:08 -0400 Received: from mga05.intel.com ([192.55.52.43]:25730 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726328AbgI1UnH (ORCPT ); Mon, 28 Sep 2020 16:43:07 -0400 IronPort-SDR: lBRFckoc5tXzYSaaaYb3tsVvRqH41vQZIytqCOHYRsC+mNEWd280BRhgJL+UCbGWUGV0qCoMiP fJQh2PsqrsNw== X-IronPort-AV: E=McAfee;i="6000,8403,9758"; a="246800758" X-IronPort-AV: E=Sophos;i="5.77,315,1596524400"; d="scan'208";a="246800758" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2020 13:43:07 -0700 IronPort-SDR: Sn2YZ2oNxMSD99dlfbKPM/ePJK6RmI0Ws9dcTkEPnnts1QdwTwgrU64fbSmOcjquRy6PK6US1f TSTwK74M+sUg== X-IronPort-AV: E=Sophos;i="5.77,315,1596524400"; d="scan'208";a="456987367" Received: from jlasecki-mobl2.ger.corp.intel.com (HELO localhost) ([10.252.49.78]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Sep 2020 13:43:00 -0700 Date: Mon, 28 Sep 2020 23:42:58 +0300 From: Jarkko Sakkinen To: Andrew Cooper Cc: x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , Andy Lutomirski , Jethro Beekman , Cedric Xing , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, bp@alien8.de, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com, "H.J. Lu" , Yu-cheng Yu Subject: Re: [PATCH v38 21/24] x86/vdso: Implement a vDSO for Intel SGX enclave call Message-ID: <20200928204258.GA2705@linux.intel.com> References: <20200915112842.897265-1-jarkko.sakkinen@linux.intel.com> <20200915112842.897265-22-jarkko.sakkinen@linux.intel.com> <721ca14e-21df-3df1-7bef-0b00d0ff90c3@citrix.com> <20200928005842.GC6704@linux.intel.com> <85bc15d5-93cd-e332-ae9a-1e1e66e1181d@citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <85bc15d5-93cd-e332-ae9a-1e1e66e1181d@citrix.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 28, 2020 at 05:44:35PM +0100, Andrew Cooper wrote: > On 28/09/2020 01:58, Jarkko Sakkinen wrote: > > On Fri, Sep 25, 2020 at 07:23:59PM +0100, Andrew Cooper wrote: > >> On 15/09/2020 12:28, Jarkko Sakkinen wrote: > >>> diff --git a/arch/x86/entry/vdso/vsgx_enter_enclave.S b/arch/x86/entry/vdso/vsgx_enter_enclave.S > >>> new file mode 100644 > >>> index 000000000000..adbd59d41517 > >>> --- /dev/null > >>> +++ b/arch/x86/entry/vdso/vsgx_enter_enclave.S > >>> @@ -0,0 +1,157 @@ > >>> +SYM_FUNC_START(__vdso_sgx_enter_enclave) > >>> > >>> +.Lretpoline: > >>> + call 2f > >>> +1: pause > >>> + lfence > >>> + jmp 1b > >>> +2: mov %rax, (%rsp) > >>> + ret > >> I hate to throw further spanners in the work, but this is not compatible > >> with CET, and the user shadow stack work in progress. > > CET goes beyond my expertise. Can you describe, at least rudimentary, > > how this code is not compatible? > > CET Shadow Stacks detect attacks which modify the return address on the > stack. > > Retpoline *is* a ROP gadget.? It really does modify the return address > on the stack, even if its purpose is defensive (vs Spectre v2) rather > than malicious. Aah. I get that, yes. Kernel is full of retpoline but I presume that ring-0 does not use CET. The situation with callback is follows: for a run-time the user_handler by all practical means is always the same. There is ever only one user handler that gets executed. I.e. the indirect callback will always lead to the same thing. I wonder how much assets an adversary would get if we just remove retpoline bits (not much thinking done yet on that). /Jarkko