Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp124593ybi; Thu, 13 Jun 2019 12:48:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2jrqMgY7rn3LN7rYv2B9+hkbPnJl1uVLB1oI9ZrUbj5JVb5F0PZLGUk5uugLZNGXroa83 X-Received: by 2002:a17:902:8f93:: with SMTP id z19mr4207536plo.97.1560455334601; Thu, 13 Jun 2019 12:48:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560455334; cv=none; d=google.com; s=arc-20160816; b=qQSkvaW8xzz89HKza3/pmcAgsXenMIyRQZlTJ3XaCjPIYgJ83jaDgY8rk0JytJ2uX1 MRkXHpkbkscJSNEeZajQhgqx4X9bFBvz4Y3hWNR8NQzGNaFxLAnMdbMPF+wzRCGqSGBF DVQO6mvB+21IllsfsfkIVrMQ1+VL45D3JfFd3bLzSbDXunSuIiAU3EgvaR9mOjw8U3dL rJO4QRZygGYNopkWZCLbvgZmLNGDhLQcyb4RUB6eyrSqam3gmyZ4BhbN379XCNo9GhPn oXqFLfoKO/mYwO1STw31LW4AXp3w/t7CBLxQfWamyp+2V2elbFWDX9LjHSEvLQik6uB4 qAcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=DgdVLWLjuT1tfvoDqgpaxcF8tNfcTRw+MPsbopqSbZY=; b=WTibZGI7SycAvsyf/KOWVsQj9SH+v0qEssP0Rt8O5LyKu6VUp0+XnjJzX2Tat+wO9H BC6zkrp6vZrm4V0fuuFNa7YFI8hLR1ijCdXTrdihtG38Yf8bD/DJZTbjmRORuFCzNtMr N56Eqj93TTDE8jDEKHNrH4ylV+e5OWnfKysuxbhCeioEKE7JDL4/SNiIT3DZwpT5pbSG z3xVoWXHrgZqxG/HfuGaTZvYK55A1pufxnWB4sg5r69nKDCzABTj57CYYFxd6sogWLWg rSPF3KtnKLJqX28aK8M19jx94yo/rNjxS+1kUAOChQYBNSqz9SPCEtl0zEH+YTAIAknx z7AA== 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 m64si478996pgm.274.2019.06.13.12.48.38; Thu, 13 Jun 2019 12:48:54 -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 S1729004AbfFMTse (ORCPT + 99 others); Thu, 13 Jun 2019 15:48:34 -0400 Received: from mga18.intel.com ([134.134.136.126]:56847 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbfFMTse (ORCPT ); Thu, 13 Jun 2019 15:48:34 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jun 2019 12:48:33 -0700 X-ExtLoop1: 1 Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.36]) by orsmga002.jf.intel.com with ESMTP; 13 Jun 2019 12:48:33 -0700 Date: Thu, 13 Jun 2019 12:48:33 -0700 From: Sean Christopherson To: Stephen Smalley Cc: "Xing, Cedric" , "linux-security-module@vger.kernel.org" , "selinux@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-sgx@vger.kernel.org" , "jarkko.sakkinen@linux.intel.com" , "luto@kernel.org" , "jmorris@namei.org" , "serge@hallyn.com" , "paul@paul-moore.com" , "eparis@parisplace.org" , "jethro@fortanix.com" , "Hansen, Dave" , "tglx@linutronix.de" , "torvalds@linux-foundation.org" , "akpm@linux-foundation.org" , "nhorman@redhat.com" , "pmccallum@redhat.com" , "Ayoun, Serge" , "Katz-zamir, Shay" , "Huang, Haitao" , "andriy.shevchenko@linux.intel.com" , "Svahn, Kai" , "bp@alien8.de" , "josh@joshtriplett.org" , "Huang, Kai" , "rientjes@google.com" , "Roberts, William C" , "Tricca, Philip B" Subject: Re: [RFC PATCH v1 2/3] LSM/x86/sgx: Implement SGX specific hooks in SELinux Message-ID: <20190613194833.GB18385@linux.intel.com> References: <960B34DE67B9E140824F1DCDEC400C0F65502A85@ORSMSX116.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 13, 2019 at 02:00:29PM -0400, Stephen Smalley wrote: > On 6/11/19 6:55 PM, Xing, Cedric wrote: > >You are right that there are SGX specific stuff. More precisely, SGX > >enclaves don't have access to anything except memory, so there are only 3 > >questions that need to be answered for each enclave page: 1) whether X is > >allowed; 2) whether W->X is allowed and 3 whether WX is allowed. This > >proposal tries to cache the answers to those questions upon creation of each > >enclave page, meaning it involves a) figuring out the answers and b) > >"remember" them for every page. #b is generic, mostly captured in > >intel_sgx.c, and could be shared among all LSM modules; while #a is SELinux > >specific. I could move intel_sgx.c up one level in the directory hierarchy > >if that's what you'd suggest. > > > >By "SGX", did you mean the SGX subsystem being upstreamed? It doesn’t track > >that state. In practice, there's no way for SGX to track it because there's > >no vm_ops->may_mprotect() callback. It doesn't follow the philosophy of > >Linux either, as mprotect() doesn't track it for regular memory. And it > >doesn't have a use without LSM, so I believe it makes more sense to track it > >inside LSM. > > Yes, the SGX driver/subsystem. I had the impression from Sean that it does > track this kind of per-page state already in some manner, but possibly he > means it does under a given proposal and not in the current driver. Yeah, under a given proposal. SGX has per-page tracking, adding new flags is fairly easy. Philosophical objections aside, adding .may_mprotect() is trivial. > Even the #b remembering might end up being SELinux-specific if we also have > to remember the original inputs used to compute the answer so that we can > audit that information when access is denied later upon mprotect(). At the > least we'd need it to save some opaque data and pass it to a callback into > SELinux to perform that auditing.