Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2729544ybi; Mon, 17 Jun 2019 09:39:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqynxq2mU/flFz2YwCrZ1baZfCL+h6Vr7xc0y4wwxQQclBLxPwpB0JWwnPPAIIZs2wfHtoyX X-Received: by 2002:a65:6456:: with SMTP id s22mr1435721pgv.161.1560789563955; Mon, 17 Jun 2019 09:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560789563; cv=none; d=google.com; s=arc-20160816; b=zKYieXLo8UZcEuB2G/+QYnvQCoA8T4NZOiWI4vOu9yWAqrexWmrdjOoHbliEf9ZVm/ CFQ2lUnfq8tt2418W+oT3T2EsR0k7U4vlCd29PPeShDmzd1pmr+Y9XqUoMuABSHl5Gtt D1B7OiWB11hXM/l8O4sgt+3hA/fBMBlERv+6OZiCLpticixwkjN2iQKDVfrTh7OiJzDx 1LVxpIYSthSmX+MtHx9qwzzGd6EVFN5TF11kyeiJDkJeHy8Z9qqxdvypZpJ1WZhdKQV4 vbSJ7avdjutGt80xvk6PE6EzQWR5VhicsaMEZFC9h1McRR5Fsa+rO9WmsAifq7chs3tx h62A== 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=eQY7VTb9IeWRbJHPUBjEbgegZSlNDIv5TkagHzBl8w4=; b=ClLIuFUYZ/1aKhF8p8Bz0cRtqxxLAH7FRrIh5MP971tJaWKl2pF8bQaaqzgrEasYTg xe7PN0QPsphwvrh1VWX7j3raWvyJ5w2aeL1XV6hkqR31cHzypYnXOgMgfiZ63gulCpCp iF18Fsmjf0Ptwg/R3X+DLFWzckhsMzwba+jscZQMRtTRF5u+yj3Jarqwai//5V4UptXM wGgrBrrzTKyf6UCsgDUaBDp87go++D4poKd34UwGR2f6Qxfio8veIVHXL4QQeBkeG6p5 8QFzFhfa4RgjTbRf9nMnPAsnP9bs/Uzi4yPuAmj5407uN1o5y2Qx1xihzKPUIJ/IlV1W TOTQ== 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 u194si11481685pgc.353.2019.06.17.09.39.08; Mon, 17 Jun 2019 09:39:23 -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 S1727821AbfFQQi7 (ORCPT + 99 others); Mon, 17 Jun 2019 12:38:59 -0400 Received: from mga09.intel.com ([134.134.136.24]:41077 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725863AbfFQQi4 (ORCPT ); Mon, 17 Jun 2019 12:38:56 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Jun 2019 09:38:55 -0700 X-ExtLoop1: 1 Received: from rameshr1-mobl.gar.corp.intel.com (HELO localhost) ([10.252.60.156]) by fmsmga005.fm.intel.com with ESMTP; 17 Jun 2019 09:38:44 -0700 Date: Mon, 17 Jun 2019 19:38:47 +0300 From: Jarkko Sakkinen To: Sean Christopherson Cc: Andy Lutomirski , Cedric Xing , Stephen Smalley , James Morris , "Serge E . Hallyn" , LSM List , Paul Moore , Eric Paris , selinux@vger.kernel.org, Jethro Beekman , Dave Hansen , Thomas Gleixner , Linus Torvalds , LKML , X86 ML , linux-sgx@vger.kernel.org, Andrew Morton , nhorman@redhat.com, npmccallum@redhat.com, Serge Ayoun , Shay Katz-zamir , Haitao Huang , Andy Shevchenko , Kai Svahn , Borislav Petkov , Josh Triplett , Kai Huang , David Rientjes , William Roberts , Philip Tricca Subject: Re: [RFC PATCH v2 5/5] security/selinux: Add enclave_load() implementation Message-ID: <20190617163655.GA8710@linux.intel.com> References: <20190606021145.12604-1-sean.j.christopherson@intel.com> <20190606021145.12604-6-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190606021145.12604-6-sean.j.christopherson@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 Wed, Jun 05, 2019 at 07:11:45PM -0700, Sean Christopherson wrote: > The goal of selinux_enclave_load() is to provide a facsimile of the > existing selinux_file_mprotect() and file_map_prot_check() policies, > but tailored to the unique properties of SGX. > > For example, an enclave page is technically backed by a MAP_SHARED file, > but the "file" is essentially shared memory that is never persisted > anywhere and also requires execute permissions (for some pages). > > The basic concept is to require appropriate execute permissions on the > source of the enclave for pages that are requesting PROT_EXEC, e.g. if > an enclave page is being loaded from a regular file, require > FILE__EXECUTE and/or FILE__EXECMOND, and if it's coming from an > anonymous/private mapping, require PROCESS__EXECMEM since the process > is essentially executing from the mapping, albeit in a roundabout way. > > Note, FILE__READ and FILE__WRITE are intentionally not required even if > the source page is backed by a regular file. Writes to the enclave page > are contained to the EPC, i.e. never hit the original file, and read > permissions have already been vetted (or the VMA doesn't have PROT_READ, > in which case loading the page into the enclave will fail). > > Signed-off-by: Sean Christopherson In the end of the day, the main problem with this patch is that the existing LSM hooks are generic. I don't we can have specific hooks for proprietary hardware. /Jarkko