Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3401473ybi; Mon, 10 Jun 2019 09:37:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqw+1HTRhqaH6I0Rhvc/HCl3fPNt0xJDvma1V/YCY4WvRRJi6Q/RF40a9b77ieiPpUCjT413 X-Received: by 2002:a63:2b8a:: with SMTP id r132mr16247680pgr.196.1560184659642; Mon, 10 Jun 2019 09:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560184659; cv=none; d=google.com; s=arc-20160816; b=bj7iW7gzQmT9mgZrEGH+lesz2mIOXRAT4r4RWTxXlgrfXjktrLCWizAlkSH2aayMod g0+clw9WyUS+jV6MURtPC5G3xMgXflSpQWcAwQlvQ1c5K+Vpu/Uc+fBy3XKiVBhTYQ8o JL9db5obZhwT+plUVeaO823EEQETqP5SbHJu1HY/MCAZKnZsMFzFXhg3zvx3g6WefpJo ezB5kt1M/Z70ruVw9b33elVz3wnkmCvRDeoeW6IJSsFmTPTHSYc5ZRpayz05iD5s/c8n c8X3IKciO4GUkdLWHnSlCDrhrmvzhM0EpDNU0jDuSZYsGU/pEaQVMfgJk9FG9HaASiMg j30A== 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=E5nxqe3dFc2oyhTrRLpkIMZI6xvLETlyoMRMjP25LEE=; b=wLzx4diLh8b2QB3MZwp7v3szdoT7rDF0WeK7GZ6TNs+kXsOhzvFaRZVA/YApDtewnW 3XOkHZsjdBT9DiujDwGrNMEePhw4WU6lex07Z0BFLwsRhtxXMbBW/heXkD/t1XY7+iz/ wnlGpddZZ68ZI0/8Vg07AW/hutaUuZ7Yn8LfOsnUtPua9DNvpll4TcTBpCWoiTE68m// iG7sXXkFj+4d857AtL6x5ECCMxYgHz8pOxjEEzJAJebJjVxtnoT+2zCtAqlXwhTgGefK 4PL35TAFgMN/QbBmdzSejoI9n6nrMh76IoY/R2YolAmUZqSNXyI+rMmMeuNM9SSn5KhO oSHg== 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 go16si2241099plb.292.2019.06.10.09.37.24; Mon, 10 Jun 2019 09:37:39 -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 S2390817AbfFJQAc (ORCPT + 99 others); Mon, 10 Jun 2019 12:00:32 -0400 Received: from mga18.intel.com ([134.134.136.126]:54869 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389356AbfFJQAb (ORCPT ); Mon, 10 Jun 2019 12:00:31 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Jun 2019 09:00:31 -0700 X-ExtLoop1: 1 Received: from cmargarx-wtg.ger.corp.intel.com (HELO localhost) ([10.249.34.77]) by orsmga001.jf.intel.com with ESMTP; 10 Jun 2019 09:00:19 -0700 Date: Mon, 10 Jun 2019 19:00:18 +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 3/5] x86/sgx: Enforce noexec filesystem restriction for enclaves Message-ID: <20190610160005.GC3752@linux.intel.com> References: <20190606021145.12604-1-sean.j.christopherson@intel.com> <20190606021145.12604-4-sean.j.christopherson@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190606021145.12604-4-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:43PM -0700, Sean Christopherson wrote: > + goto out; > + } > + > + /* > + * Query VM_MAYEXEC as an indirect path_noexec() check (see do_mmap()), > + * but with some future proofing against other cases that may deny > + * execute permissions. > + */ > + if (!(vma->vm_flags & VM_MAYEXEC)) { > + ret = -EACCES; > + goto out; > + } > + > + if (copy_from_user(dst, (void __user *)src, PAGE_SIZE)) > + ret = -EFAULT; > + else > + ret = 0; > + > +out: > + up_read(¤t->mm->mmap_sem); > + > + return ret; > +} I would suggest to express the above instead like this for clarity and consistency: goto err_map_sem; } /* Query VM_MAYEXEC as an indirect path_noexec() check * (see do_mmap()). */ if (!(vma->vm_flags & VM_MAYEXEC)) { ret = -EACCES; goto err_mmap_sem; } if (copy_from_user(dst, (void __user *)src, PAGE_SIZE)) { ret = -EFAULT; goto err_mmap_sem; } return 0; err_mmap_sem: up_read(¤t->mm->mmap_sem); return ret; } The comment about future proofing is unnecessary. /Jarkk