Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3789901ybi; Sun, 2 Jun 2019 23:43:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOyHiVmWBNF4pYPaFFL70/cQqfW20wsCeJCEMUZg8p3z82h5u3y3EpL536OYrUyeO/UJV3 X-Received: by 2002:aa7:8ac7:: with SMTP id b7mr14519829pfd.100.1559544187917; Sun, 02 Jun 2019 23:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559544187; cv=none; d=google.com; s=arc-20160816; b=1GQoHn7Hp92Hw9n9vME3GBNW5Ue4HGzyeygiFagMj9mS2X2RVnygf1bau/IXuqGVfG 4eEOqRwtvOsFiuyb/KSKwQ8rmvzljI9GM4xMwXbYmwULlmOgDzsMsh2ukJ0/PbPu8+A/ Ggf/gwfqBKHkIPc4JsjCLR25pxEGKSnZQoWzVOTdMytdVaZdvaO0RiYUHMEIQIJT1wPy Yy7w2C2BG5GxlVzeMKkSTLj4Yh2KESFOdvhF30P9ExyJET58uUb3Ypt6txiTMODTsk0A nLqT1jfh5osnMRhhLQuViebKQgYpPfFwlgjxgAlP3STXx0j4T2uL5FkToI/ToUTmIJM1 OZlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=rWWbVfTcoShkjzD8xnIpnnn06KOuz6vIIkcUB+eswBA=; b=HdDsbUDrbmPTAr3CL+Opp8qhkn6BfnCIdy9Fs6AinYgaI74H/9b559PLFsAeiayV7K BIONvNbgCzdwB+yxPEeMH6S/2MoLb61KZ1oz1pwF93OVM2kYyVxFTSB3lJUu55ACNxy8 vzQJl0URx4hlwOstg/vJqKu2Ih8Y93KYUlsz2Qzged04cKoGsXi3myZj0RD8yghojNMO Wq9J3HooYrnseVY5x+3fSfsAWoQxb+xqEeJGt/9PjBvVDWi6pz36wV4cAhWh/8SkiiD7 wgp0sORa9ghN9PRyaly6wj/m1IrhWnKN6R6sbjzQ5qT4bigmnJIR9n8RMGbRjUVo0Jax Sqdg== 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 q8si13772354pll.205.2019.06.02.23.42.51; Sun, 02 Jun 2019 23:43:07 -0700 (PDT) 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 S1726999AbfFCG2j convert rfc822-to-8bit (ORCPT + 99 others); Mon, 3 Jun 2019 02:28:39 -0400 Received: from mga03.intel.com ([134.134.136.65]:47042 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbfFCG2j (ORCPT ); Mon, 3 Jun 2019 02:28:39 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jun 2019 23:28:38 -0700 X-ExtLoop1: 1 Received: from orsmsx102.amr.corp.intel.com ([10.22.225.129]) by fmsmga006.fm.intel.com with ESMTP; 02 Jun 2019 23:28:37 -0700 Received: from orsmsx112.amr.corp.intel.com (10.22.240.13) by ORSMSX102.amr.corp.intel.com (10.22.225.129) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 2 Jun 2019 23:28:37 -0700 Received: from orsmsx116.amr.corp.intel.com ([169.254.7.165]) by ORSMSX112.amr.corp.intel.com ([169.254.3.79]) with mapi id 14.03.0415.000; Sun, 2 Jun 2019 23:28:37 -0700 From: "Xing, Cedric" To: "Christopherson, Sean J" , "Jarkko Sakkinen" CC: Andy Lutomirski , Stephen Smalley , James Morris , "Serge E . Hallyn" , LSM List , Paul Moore , Eric Paris , "selinux@vger.kernel.org" , Jethro Beekman , "Hansen, Dave" , "Thomas Gleixner" , Linus Torvalds , LKML , X86 ML , "linux-sgx@vger.kernel.org" , Andrew Morton , "nhorman@redhat.com" , "npmccallum@redhat.com" , "Ayoun, Serge" , "Katz-zamir, Shay" , "Huang, Haitao" , "Andy Shevchenko" , "Svahn, Kai" , Borislav Petkov , Josh Triplett , "Huang, Kai" , David Rientjes , "Roberts, William C" , "Tricca, Philip B" Subject: RE: [RFC PATCH 5/9] x86/sgx: Restrict mapping without an enclave page to PROT_NONE Thread-Topic: [RFC PATCH 5/9] x86/sgx: Restrict mapping without an enclave page to PROT_NONE Thread-Index: AQHVGAkj7EareWVgR0mChEzTKrZLKaaJYaOA Date: Mon, 3 Jun 2019 06:28:36 +0000 Message-ID: <960B34DE67B9E140824F1DCDEC400C0F654ECC28@ORSMSX116.amr.corp.intel.com> References: <20190531233159.30992-1-sean.j.christopherson@intel.com> <20190531233159.30992-6-sean.j.christopherson@intel.com> In-Reply-To: <20190531233159.30992-6-sean.j.christopherson@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiYjYyMGU2ODgtOTgwZC00ZGUxLTllMzItMmM4N2ZhZWNiNWJmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoicmhGTit5Z0t2RUFBWGhXTlNKMkU5TTkwSjVYdkxqTWhSUHJIZXhndk5cL292SDR0ekwwY1RXTkNBMXFyUlpUZlQifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.22.254.138] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > From: Christopherson, Sean J > Sent: Friday, May 31, 2019 4:32 PM > > To support LSM integration, SGX will require userspace to explicitly specify the allowed > protections for each page. The allowed protections will be supplied to and modified by > LSMs (based on their policies). > To prevent userspace from circumventing the allowed protections, do not allow > PROT_{READ,WRITE,EXEC} mappings to an enclave without an associated enclave page (which > will track the allowed protections). This is unnecessary. For mprotect(), LSM shall validate @prot against existing pages with applicable global flags (e.g. FILE__EXECMOD/PROCESS__EXECMEM in the case of SELinux). For mmap(), SGX driver could invoke security_file_mprotect() explicitly to have LSM validate requested protection. In the case where there's no page associated with an VMA, security_file_mprotect() shall still dictate whether to allow/deny the request. LSM internally is able to track existence/nonexistence of enclave pages. If there's no page, there's no conflict so the decision shall only depend on global flags (if any). Afterwards, #PF may trigger SGX driver to EAUG, in which case security_enclave_load() will be invoked and LSM could decide whether to approve/decline EAUG request.