Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1241248ybv; Thu, 20 Feb 2020 16:12:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzWs8JyqTAmncoXhyqdSyUldTs/b0Qu9qcwm7c3T934bQiBgwLNViTbm/aSDjuiJo1tUrjj X-Received: by 2002:aca:c3c2:: with SMTP id t185mr3996775oif.26.1582243933587; Thu, 20 Feb 2020 16:12:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582243933; cv=none; d=google.com; s=arc-20160816; b=cbN4SM1ttOPoK7hVtJ3pK0oytBnk9tCzRCLe+vAi/7+J2Jg3tcWoxruniI59V5f391 WGoz5aR2tXZ9YFjUrusPeMdgppSKXiCfQcgtbxbbYS9jrjMH23RUA+G59m7pXlf2xi/o kVHkVOC+FOogKKqyz/GhqPVbp2I1/RCkhrRJSFFG0+r+3YjDZysbsoIV/P/Fh7wH+QHz J1T1akma1+8/0cKCFlNAhzR52Cx5Mga9CVH49UNn/aIeB5smYRY2BcwVhA/VNIkZGl8Z EF3+r1S09tkQla4h08l6gt1joMgPnTeWGBZ3A1AnNl+1qBrQqEQS4kVxfaJtAasOXFOe 7/Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature:dkim-filter; bh=zorJuQNXMnYkPB8Xz0B94YjuA01qeWQy1dyOh6tP+f8=; b=D1zZfGy7dWrHLxATG8yfMxuKJnRFL2snBfCuS0/+Q0yrigPD9cjrWuy44//v3zge+Y 0Yd43IRfZoMbQNXDZUojyNCmI3XAhREJr1BDzI3OzDeR1gMt58H1rjYCm5jB51dmu701 sNIqaG2rTKvJ2xPjJsc69asbEnEaq68VpX/GoX5Q+Js95AuxP+cFJti/CsHHaA8k2oxS 6LCgk+9Q9D6AlqaHTKfzKUFuQpMD5SeMWBcPlsc9LsuogP92A5dYlow443SwY32qvGW6 D7U3q52tYEJ6GMM4b0LgVKSILABmWts9uyH/JKBK/m7wpN3DaR5tmgoViSrhzh84633y WV0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Gqbbv60b; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k10si555908otn.323.2020.02.20.16.12.01; Thu, 20 Feb 2020 16:12:13 -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; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Gqbbv60b; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729424AbgBUALG (ORCPT + 99 others); Thu, 20 Feb 2020 19:11:06 -0500 Received: from linux.microsoft.com ([13.77.154.182]:43026 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729373AbgBUALF (ORCPT ); Thu, 20 Feb 2020 19:11:05 -0500 Received: from [10.131.86.135] (unknown [131.107.147.135]) by linux.microsoft.com (Postfix) with ESMTPSA id BF7BB2007690; Thu, 20 Feb 2020 16:11:04 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com BF7BB2007690 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1582243864; bh=zorJuQNXMnYkPB8Xz0B94YjuA01qeWQy1dyOh6tP+f8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Gqbbv60bmqz+5F6mV/kCW3gQZGu3DycmYrYLu8NMF+ZHg4LfwU14I/TTaZKt2yHJK qvlueHIQyEPAkSW+rKdO9Uxo1MXtzS5rI8gxvOKqp0qt1eantpqZaiLAqKmy20yLRv mHenMROitS8e5qUS0mN4zJi8tgUR3TtD4JvjaDLk= Subject: Re: [PATCH v26 10/22] x86/sgx: Linux Enclave Driver To: Jarkko Sakkinen , Sean Christopherson Cc: 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 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> <20200220221607.GB26618@linux.intel.com> From: Jordan Hand Message-ID: <2c077197-a8a7-feac-58ea-e901c92fb58b@linux.microsoft.com> Date: Thu, 20 Feb 2020 16:11:04 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200220221607.GB26618@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/20/20 2:16 PM, Jarkko Sakkinen wrote: > 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). > I agree. It still means userspace code with an executable stack can't mmap/mprotect enclave pages and request PROT_READ but the check you've proposed would more consistently enforce this which is easier to understand from userspace perspective. -Jordan