Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1150131ybv; Thu, 20 Feb 2020 14:16:57 -0800 (PST) X-Google-Smtp-Source: APXvYqzLFLTJcpkNBc33zOyAffONB/pr+gIRqlgvjuS5QvfkX3/CdHZpx3/rW3Wk1WA3UM1Zbt4F X-Received: by 2002:a9d:12a8:: with SMTP id g37mr25585773otg.261.1582237017270; Thu, 20 Feb 2020 14:16:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582237017; cv=none; d=google.com; s=arc-20160816; b=QKM3AJ/umdzRbqM5tEMB7euEn4JQbLf6YA7GL2kqpo7pkd47SLhKjm68REZS9xOSYh jpKIqC7Z1l7+Cap++CyVDxDiA2cBjKRjZcC6v6x7ZK2ERaQr5/CMKqAdwteGMHiNSVMe Dz9XBmI2KfzHnixS/8gwfl2iE1ZMg+1e85ZZrWZ+qifhbejgQ3cndtgnFYwY9wFQbTnZ WqdYrwcdKEHILDOWlNf9RQ80EuLq267eBcJthHhKXOx2JTb9mKXHWcDh0u6QK5gC37YN XLfh0C4/UUoSzGklrLEm821j4rtqe+1N0KielOWMu7ertPX9KNcUJ/v0pQTY93C56DeW FRbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=g8Dwe+14uUjVOt9O4Lccn15qmpeqapYnFbix58MP8tU=; b=ic/EVsLJBBauqHUaOQJ46gwUGQGj+fzBoPEMEzJA15djgzhYqisTrT2VFUwl8VzZT7 EiKusdZyfyaFA98nq9gxNYvalJ9x3eSqxW/JHCj59GhGEOZCaSSSXUBetVenXoGnFRyv ZApnntTbSIZOYKTU0960nGronGKakH9ynP5FWCCrUVUfb6JLZmEmL6b86xxOV6wgR+6B CAsVoRNtkeF5y1ODhEhhfJeM+HDzH7lVRAGTxcHEzQAIou4JugX9kcJT82HreWR787FP f1ROznoICnBs/b7AL4+fOtrpRuLPtTXrEQBWlFe+PRm6gvhQUQb9Dk72eruycsODFrZm SGdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id f190si331317oig.229.2020.02.20.14.16.44; Thu, 20 Feb 2020 14:16:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728992AbgBTWQU (ORCPT + 99 others); Thu, 20 Feb 2020 17:16:20 -0500 Received: from mga12.intel.com ([192.55.52.136]:20659 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727656AbgBTWQT (ORCPT ); Thu, 20 Feb 2020 17:16:19 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2020 14:16:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,465,1574150400"; d="scan'208";a="240154208" Received: from evieschw-mobl.ger.corp.intel.com (HELO localhost) ([10.251.86.197]) by orsmga006.jf.intel.com with ESMTP; 20 Feb 2020 14:16:08 -0800 Date: Fri, 21 Feb 2020 00:16:07 +0200 From: Jarkko Sakkinen To: Sean Christopherson Cc: Jordan Hand , linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, nhorman@redhat.com, npmccallum@redhat.com, haitao.huang@intel.com, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, kai.svahn@intel.com, bp@alien8.de, josh@joshtriplett.org, luto@kernel.org, kai.huang@intel.com, rientjes@google.com, cedric.xing@intel.com, puiterwijk@redhat.com, linux-security-module@vger.kernel.org, Suresh Siddha , Haitao Huang Subject: Re: [PATCH v26 10/22] x86/sgx: Linux Enclave Driver Message-ID: <20200220221607.GB26618@linux.intel.com> References: <20200209212609.7928-1-jarkko.sakkinen@linux.intel.com> <20200209212609.7928-11-jarkko.sakkinen@linux.intel.com> <15074c16-4832-456d-dd12-af8548e46d6d@linux.microsoft.com> <20200220181345.GD3972@linux.intel.com> <7738b3cf-fb32-5306-5740-59974444e327@linux.microsoft.com> <20200220184842.GE3972@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200220184842.GE3972@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 20, 2020 at 10:48:42AM -0800, Sean Christopherson wrote: > My biggest concern for allowing PROT_EXEC if RIE is that it would result > in #PF(SGX) (#GP on Skylake) due to an EPCM violation if the enclave > actually tried to execute from such a page. This isn't a problem for the > kernel as the fault will be reported cleanly through the vDSO (or get > delivered as a SIGSEGV if the enclave isn't entered through the vDSO), but > it's a bit weird for userspace as userspace will see the #PF(SGX) and > likely assume the EPC was lost, e.g. silently restart the enclave instead > of logging an error that the enclave is broken. I think right way to fix the current implementation is to -EACCES mmap() (and mprotect) when !!(current->personality & READ_IMPLIES_EXEC). This way supporting RIE can be reconsidered later on without any potential ABI bottlenecks. /Jarkko