Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1145295ybv; Thu, 20 Feb 2020 14:11:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxQIn0siB112qwokruevCNLEXml8zEKmqguvjcGYA3zhpnkR7TBqykb2uKZvaB4Il/hBNyC X-Received: by 2002:a9d:6a90:: with SMTP id l16mr23832641otq.353.1582236676219; Thu, 20 Feb 2020 14:11:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582236676; cv=none; d=google.com; s=arc-20160816; b=TQhAhY4fvZV6eS20n7vxoiKKWMu5yNaAah93LGIoR8eL6O1epwfUtIK6jQTgbN7jbX JEBWFvFPoz/+SHMvzXX7WkLmDLpdLOOKDn579vPdjbpYsfXCnC9GjJhwujUZCuub5YDi 97iZawLsaFj5byr+g/6FspLY7qfkVqqEIadDvFWtunXveXAnAGDUp3g1uP0yDYfw2rvG unn/v9msVBGOoczniPPdyWjWGiktc4fTxzirrAcQNgOgHv4DviWCHZY0jLQr2DdBG6/w bHaXgCcO8edq+dZfh4Eh9W+sH8rPe31QMwLMDteA1bzqnkT7/KKdKbQSQByryxOd6UP6 +1aQ== 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=js3LqJORcuEyG2YZps+N/zcxXSD6IzaZbJ6YFHsTpsE=; b=FKFuwHnRNi1HSYJF6JBjTp3873lyv5LpWpDapsazEFYJmAcg5WzVuTE3uwi2zOHw0b Fi6S6Zro7+ebQbPszelekXGRjO6JkG6L/POJ2n/pVFaovYGd4gcEusAa4zQSuN4LigjM A9oYbATv5JFCnh5k+DxawjcOT3Yti+lFrYo0J9Zd5DnKS7FX8kI92nFu10HlZvEBugZa 9mUey00nYUrtWxgE77qc7nw3KZuZzG52Ad0f7w1LHFx+YykmHizXl/m8HkCFaynK6bdm kB4hjp8+OeYjKLysB4ObbWnGlTWFsf9ho+CbnifXCTRe2TPE4ENES3zLoXI87aAB1ETi Qe0Q== 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 t7si287172oij.175.2020.02.20.14.11.03; Thu, 20 Feb 2020 14:11:16 -0800 (PST) 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 S1729111AbgBTWKy (ORCPT + 99 others); Thu, 20 Feb 2020 17:10:54 -0500 Received: from mga02.intel.com ([134.134.136.20]:51689 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727656AbgBTWKy (ORCPT ); Thu, 20 Feb 2020 17:10:54 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Feb 2020 14:10:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,465,1574150400"; d="scan'208";a="269758715" Received: from evieschw-mobl.ger.corp.intel.com (HELO localhost) ([10.251.86.197]) by fmsmga002.fm.intel.com with ESMTP; 20 Feb 2020 14:10:45 -0800 Date: Fri, 21 Feb 2020 00:10:38 +0200 From: Jarkko Sakkinen To: Jordan Hand Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linux-sgx@vger.kernel.org, akpm@linux-foundation.org, dave.hansen@intel.com, sean.j.christopherson@intel.com, nhorman@redhat.com, npmccallum@redhat.com, haitao.huang@intel.com, andriy.shevchenko@linux.intel.com, tglx@linutronix.de, kai.svahn@intel.com, bp@alien8.de, josh@joshtriplett.org, luto@kernel.org, kai.huang@intel.com, rientjes@google.com, cedric.xing@intel.com, puiterwijk@redhat.com, linux-security-module@vger.kernel.org, Suresh Siddha , Haitao Huang Subject: Re: [PATCH v26 10/22] x86/sgx: Linux Enclave Driver Message-ID: <20200220221038.GA26618@linux.intel.com> References: <20200209212609.7928-1-jarkko.sakkinen@linux.intel.com> <20200209212609.7928-11-jarkko.sakkinen@linux.intel.com> <15074c16-4832-456d-dd12-af8548e46d6d@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15074c16-4832-456d-dd12-af8548e46d6d@linux.microsoft.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 Tue, Feb 18, 2020 at 07:26:31PM -0800, Jordan Hand wrote: > if (!page || (~page->vm_max_prot_bits & vm_prot_bits)) > return -EACCESS > > This means that for any process where READ_IMPLIES_EXECUTE is set and > page where (vma->vm_flags & VM_MAYEXEC) == true, mmap/mprotect calls to > that request PROT_READ on a page that was not added with PROT_EXEC will > fail. Right. You would end up requesting RX from a R region. And you are suggesting that we tweak it along the lines of to make RIE processes work: unsigned long max_prot_bits = page->vm_max_prot_bits; if (!!(current->personality & READ_IMPLIES_EXEC) && vma->vm_flags & VM_MAY_EXEC) max_prot_bits |= VM_EXEC; /* ... */ if (!page || (~max_prot_bits & vm_prot_bits)) return -EACCESS ? /Jarkko