Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5311147ybi; Tue, 4 Jun 2019 04:51:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqzpYu6DT0YNe1ELVLUHfzLyvEQdLRjaWWaKCyE2fBcHUFJyhl3TbF6gNbjHh9v8sZUKbuMg X-Received: by 2002:a17:90a:2743:: with SMTP id o61mr22500140pje.59.1559649117219; Tue, 04 Jun 2019 04:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559649117; cv=none; d=google.com; s=arc-20160816; b=iTvpTlYxIM2zjrz0PCR5VeyQOEl52MCz8qo1tpOZtJy4lI9xUGW8D0eEQ9ij3o0MEd +KHfeBXruQlWHnkSVYYLYHSGIQ0fMyGNFOuWck9cLaW7KoUWJ7pnUWEZn77aDWwIn82r H2PAQ8O28FzLAtvBwNQevsxOQfzN/RBsDq5n6yfi+oZ1E4/ef27m6m1ayqoo2FnKUh3t tx1MjqdpctxQSCfjF1IYVTy6+uHgat5GHdeY5m7YXxmuGWZ2mLaHipVCooJRa+wOPWHA NudoVFzek/kOcCMtgj3NVyoAI/vf+UFMPA+4SRbn1FSIx1a06/85Om6sp8OTWF/telJg P+KQ== 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=iEE/s5O/OViiwB3MtkO+ndIlg56WMZrW8xS04uVuJxA=; b=c7rSlMEoUhyWsKiebcrBZeYCWykp2D8H2uBLz5hMwiurntLNcvjcMQbvuTgexb5zFr xKav5hl2PSHdeudsVmiHr3eHw89ABMX8DeZkvjTiqHtoXXCY+a5fTPZLDT1VGJdyjy8Y 17zhie4fUz26hecaUpKJEvIv5NX1S3Yj7aT7K3h4xGJZ2gjH6ZZ+T2zF6QU93is1waTX Dif7hXLG945ld6mbFzfpYlExA7ooM9PhWR5jdD2uwQykO72bInEF4RHIMo31PBk9ilKZ 8t2u8IbAwwAXvmVFolRIWhjvS9C9J9LJ6Tg4ZJPdCWcnPu+ckB74yG8SLnoHq+RTk6pf 5UpQ== 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 z188si22064400pgb.503.2019.06.04.04.51.40; Tue, 04 Jun 2019 04:51:57 -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 S1727610AbfFDLuB (ORCPT + 99 others); Tue, 4 Jun 2019 07:50:01 -0400 Received: from mga01.intel.com ([192.55.52.88]:6646 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727301AbfFDLuA (ORCPT ); Tue, 4 Jun 2019 07:50:00 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2019 04:49:59 -0700 X-ExtLoop1: 1 Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.189]) by fmsmga008.fm.intel.com with ESMTP; 04 Jun 2019 04:49:51 -0700 Date: Tue, 4 Jun 2019 14:49:51 +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 2/9] x86/sgx: Do not naturally align MAP_FIXED address Message-ID: <20190604114951.GC30594@linux.intel.com> References: <20190531233159.30992-1-sean.j.christopherson@intel.com> <20190531233159.30992-3-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190531233159.30992-3-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 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. /Jarkko