Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp1444779pxb; Fri, 20 Nov 2020 09:35:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsdqFABeZNyvgC65pWexESopd1NsqA5UV4zcwIxxmfMU+ll6QyFGpMYLSc/c7nmDUJV/nz X-Received: by 2002:a17:906:76d0:: with SMTP id q16mr2003396ejn.164.1605893741162; Fri, 20 Nov 2020 09:35:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605893741; cv=none; d=google.com; s=arc-20160816; b=Imnc+n87/J6jbnFSUTvaKAZg73vxNPmpwrz9YqBbi0IsuJvON684lXcYYM6Onc+Ncr UeOPRqReUoU0SYReTUKGlOVjsrP+es7L7ygeDVgTO7GOWId+14/i05eUbGjxRmRBZPbM kg10F92AYG+nu8CG6Vldk9mLEPdPb0R3ad69M8rXRCJhof+i3U1BN6U3aYlPD3JMDyzx BrNr30trvnZ2F1G0CC2ylxp4UZzrP9zm28hPpqE79ZrjfCRrJwG4nN+0btxB+NXZ55UU kaNt3YzjMWZB2WcYCNyD+nya1+6Gms9JC/5noz+rHw8+THQNSl2EVjDMGNY+KE1m89Ii I1Cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:reply-to:message-id:subject:cc:to:from:date; bh=SbmXsml0vCdey1nUOsLw0I80g+TmScNgHUwGCp/7uKM=; b=RmgM5sqfXTlPTPFB+KaUWEHG3yf88I5wbDtXImasUA+Oy897Er9ro5/BK+k2Ho0azy NuGjroefStZ68AkF7IDZ6ifrjTLNCPn1v41Q+SK3X73IQIWvqwLh8VQe2+HJvKknNxYN QKVsd9qed2aGh8/4TCBSRzExFu4chEZ9NFxTqYK56duwffmm+JNO3r2PO1jfS6FJG26X /+73D+pYK8hLTCkEYlVQQITRXq1/niyVcFqRgC1ZACWOjqzVT5z1emj+XgzLgrSrnW71 T62ZVQUrVOD37b4EmCCUlTNhG13eDAdsrFGfsSfh7ILKnklAVM3V58oYP81+8XIxz+XG Acyg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u9si2268395edb.338.2020.11.20.09.35.18; Fri, 20 Nov 2020 09:35:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728751AbgKTRcG (ORCPT + 99 others); Fri, 20 Nov 2020 12:32:06 -0500 Received: from wind.enjellic.com ([76.10.64.91]:33076 "EHLO wind.enjellic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728597AbgKTRcG (ORCPT ); Fri, 20 Nov 2020 12:32:06 -0500 Received: from wind.enjellic.com (localhost [127.0.0.1]) by wind.enjellic.com (8.15.2/8.15.2) with ESMTP id 0AKHVCGT032122; Fri, 20 Nov 2020 11:31:13 -0600 Received: (from greg@localhost) by wind.enjellic.com (8.15.2/8.15.2/Submit) id 0AKHVB9g032121; Fri, 20 Nov 2020 11:31:11 -0600 Date: Fri, 20 Nov 2020 11:31:11 -0600 From: "Dr. Greg" To: Haitao Huang Cc: Andy Lutomirski , Dave Hansen , Jarkko Sakkinen , X86 ML , linux-sgx@vger.kernel.org, LKML , Sean Christopherson , Linux-MM , Andrew Morton , Matthew Wilcox , Jethro Beekman , Darren Kenny , Andy Shevchenko , asapek@google.com, Borislav Petkov , "Xing, Cedric" , chenalexchen@google.com, Conrad Parker , cyhanish@google.com, "Huang, Haitao" , "Huang, Kai" , "Svahn, Kai" , Keith Moyer , Christian Ludloff , Neil Horman , Nathaniel McCallum , Patrick Uiterwijk , David Rientjes , Thomas Gleixner , yaozhangx@google.com, Mikko Ylinen Subject: Re: [PATCH v40 10/24] mm: Add 'mprotect' hook to struct vm_operations_struct Message-ID: <20201120173111.GA31178@wind.enjellic.com> Reply-To: "Dr. Greg" References: <20201104145430.300542-11-jarkko.sakkinen@linux.intel.com> <20201106174359.GA24109@wind.enjellic.com> <20201107150930.GA29530@wind.enjellic.com> <20201112205819.GA9172@wind.enjellic.com> <5c22300c-0956-48ed-578d-00cf62cb5c09@intel.com> <20201116180023.GA32481@wind.enjellic.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.3 (wind.enjellic.com [127.0.0.1]); Fri, 20 Nov 2020 11:31:13 -0600 (CST) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 18, 2020 at 07:39:50PM -0600, Haitao Huang wrote: Good morning, I hope the week is ending well for everyone. > On Mon, 16 Nov 2020 12:00:23 -0600, Dr. Greg wrote: > > >On Thu, Nov 12, 2020 at 02:41:00PM -0800, Andy Lutomirski wrote: > >>It certainly prevents any scheme in which an enclave coordinates > >>with the outside world to do W-and-then-X JIT inside. I'm also not > >>convinced it has any real effect at all unless there's some magic I > >>missed to prevent someone from using mmap(2) to effectively change > >>permissions. > > > >The patch that I posted yesterday addresses the security issue for > >both mmap and mprotect by trapping the permission change request at > >the level of the sgx_encl_may_map() function. > > > >With respect to the W-and-then-X JIT issue, the stated purpose of the > >driver is to implement basic SGX functionality, which is SGX1 > >semantics, it has been stated formally for a year by the developers > >themselves that they are not entertaining a driver that addresses any > >of the issues associated with non-static memory permissions. > The JIT issue is applicable even to SGX1 platforms. We can do EADD > with EPCM.RWX in sec_info and with PTE.RW, EINIT, then mprotect to > set PTE.RX when JIT is done. Correct, which further underscores the point that I am trying make, it is unclear what the current mmap/mprotect protection architecture is accomplishing, since it only enforces EPCM permissions. The hardware is perfectly capable of doing so without assistance from the operating system, in fact, the very reason it was designed was to provide protections in the face of an adversarial operating system. For precisely one year, as of next week, we have engaged in a re-design of this driver, driven by the concern that the previous driver allowed execution of code that bypassed the LSM. So I'm assuming the community has concerns about the possibility of anonymous code execution. If this is the case, the mmap/mprotect protection code in the driver should be implementing some type of control over the execution of anonymous memory, which our patch implements, very simply and very understandably. The other straight forward alternative is a knob that tells the driver to disallow the addition of any page that attempts to set EPCM.XW permissions. As always, corrections gladly accepted if our analysis of the driver or how the hardware itself works is incorrect. > Haitao Have a good weekend. Dr. Greg As always, Dr. Greg Wettstein, Ph.D, Worker Autonomously self-defensive Enjellic Systems Development, LLC IOT platforms and edge devices. 4206 N. 19th Ave. Fargo, ND 58102 PH: 701-281-1686 EMAIL: greg@enjellic.com ------------------------------------------------------------------------------ "My second remark is that our intellectual powers are rather geared to master static relations and that our powers to visualize processes evolving in time are relatively poorly developed." -- Edsger W. Dijkstra