Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6916371ybi; Wed, 5 Jun 2019 08:18:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxs8L0gSN8YrDdt256aothUptB5sq9b/8feeIU4HDtBLAW4Mtdw+sby5Uu7PpoW/eD9kc3s X-Received: by 2002:a65:5241:: with SMTP id q1mr4821830pgp.298.1559747927798; Wed, 05 Jun 2019 08:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559747927; cv=none; d=google.com; s=arc-20160816; b=fk7I60/cVgNrnKVHXt9+oelP/LjbqHsuI9ua/xuTz445Wl4J7cBwH54PRLdQfyHfux FGAk8rz2WlsVhQmMAjEUhS41K7NmPcvOuSLVLCa5b7yqzPwLBJgXhX/fOzB+qOEOYy4l 0p6CAxp5h+a8TxF3yl0tmUDLVCILvUYSa4NNUh7WvQxcHWnCJjSt6ZpniSKSsZjbS3CZ ritZS2At6haygmpW/h6QxDxGYEOfXuli358npW8+tjmksHrp9SZ8zbdR9z14ox4CA6yl wUvneKjhS9iBYGvfcIPTMpvIhfZi4r7h4eFqOolypXLqZjLW+w1qsFvN9XYg9OrIJBqO WGIg== 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=DwlYPDOC8YA6T27pWLkSzBsBUWPdMTQ4WpArUbuFees=; b=vxBgie+bbB40A6ODVZ2g7mWCWmsvvO/7L7I0yqIA7ssqIY4WdeLQmrMHjaeDjIPjkn ATTunYqDhcFktKVZBBo0nfFC3TRajhxckwmMiJOV5dWU2Suvpr1E1hOPeHUriq03MucF RoJMtK7D3M5f5fdprEaqFtRV9HaUHYylPy7Ck8a2t6ZseUmzDOnqL3qGpSd2jcTQsWVj SFUhOnfxrnsPgtZtrRbWAx8XvVzzXqEuvgxOoCIg6/j7N/RR05g8B3Q+QEjpUZpJAJqX wCCnzuiHdsrAl8FfgNFrrB3KO+N9RhmRJ0KQ62G8SVrPhtSRaQYmvbHzTWeHboScOVe2 t7Fg== 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 f62si28087710plf.88.2019.06.05.08.18.30; Wed, 05 Jun 2019 08:18:47 -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 S1728683AbfFEPPl (ORCPT + 99 others); Wed, 5 Jun 2019 11:15:41 -0400 Received: from mga12.intel.com ([192.55.52.136]:43679 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728132AbfFEPPl (ORCPT ); Wed, 5 Jun 2019 11:15:41 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jun 2019 08:15:40 -0700 X-ExtLoop1: 1 Received: from araresx-wtg1.ger.corp.intel.com (HELO localhost) ([10.252.46.102]) by fmsmga001.fm.intel.com with ESMTP; 05 Jun 2019 08:15:30 -0700 Date: Wed, 5 Jun 2019 18:15:24 +0300 From: Jarkko Sakkinen To: Andy Lutomirski Cc: Sean Christopherson , 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 2/9] x86/sgx: Do not naturally align MAP_FIXED address Message-ID: <20190605151524.GJ11331@linux.intel.com> References: <20190531233159.30992-1-sean.j.christopherson@intel.com> <20190531233159.30992-3-sean.j.christopherson@intel.com> <20190604114951.GC30594@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Tue, Jun 04, 2019 at 01:16:04PM -0700, Andy Lutomirski wrote: > On Tue, Jun 4, 2019 at 4:50 AM Jarkko Sakkinen > wrote: > > > > On Fri, May 31, 2019 at 04:31:52PM -0700, Sean Christopherson wrote: > > > SGX enclaves have an associated Enclave Linear Range (ELRANGE) that is > > > tracked and enforced by the CPU using a base+mask approach, similar to > > > how hardware range registers such as the variable MTRRs. As a result, > > > the ELRANGE must be naturally sized and aligned. > > > > > > To reduce boilerplate code that would be needed in every userspace > > > enclave loader, the SGX driver naturally aligns the mmap() address and > > > also requires the range to be naturally sized. Unfortunately, SGX fails > > > to grant a waiver to the MAP_FIXED case, e.g. incorrectly rejects mmap() > > > if userspace is attempting to map a small slice of an existing enclave. > > > > > > Signed-off-by: Sean Christopherson > > > > Why you want to allow mmap() to be called multiple times? mmap() could > > be allowed only once with PROT_NONE and denied afterwards. Is this for > > sending fd to another process that would map already existing enclave? > > > > I don't see any checks for whether the is enclave underneath. Also, I > > think that in all cases mmap() callback should allow only PROT_NONE > > as permissions for clarity even if it could called multiple times. > > > > What's the advantage to only allowing PROT_NONE? The idea here is to > allow a PROT_NONE map followed by some replacemets that overlay it for > the individual segments. Admittedly, mprotect() can do the same > thing, but disallowing mmap() seems at least a bit surprising. I was merely wondering if it is specifically for the application where a client process would mmap(MAP_FIXED) an enclave created by a server process. /Jarkko