Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D27C0C3A5A0 for ; Mon, 19 Aug 2019 15:24:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADA042082A for ; Mon, 19 Aug 2019 15:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726728AbfHSPYe (ORCPT ); Mon, 19 Aug 2019 11:24:34 -0400 Received: from mga04.intel.com ([192.55.52.120]:3495 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbfHSPYe (ORCPT ); Mon, 19 Aug 2019 11:24:34 -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 fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Aug 2019 08:24:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,405,1559545200"; d="scan'208";a="177907623" Received: from jsakkine-mobl1.tm.intel.com (HELO localhost) ([10.237.50.125]) by fmsmga008.fm.intel.com with ESMTP; 19 Aug 2019 08:24:32 -0700 Date: Mon, 19 Aug 2019 18:24:31 +0300 From: Jarkko Sakkinen To: sean.j.christopherson@intel.com Cc: linux-sgx@vger.kernel.org Subject: mmap(), #PF handler and EADD interaction Message-ID: <20190819152431.x5ajhd67cpqag5ue@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: NeoMutt/20180716 Sender: linux-sgx-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sgx@vger.kernel.org I did some backtracking today how the permission flow worked. With the maximum VM flags defined for a page, what if EADD is done after mmap()? E.g. we first do mmap() with RWX and later EADD with lets say RW. The first thing that comes to mind is that the #PF handler should caught this corner case. Now the code correctly validates when you do either mmap() and mprotect() after EADD(s) but I think "other way around" is missing. /Jarkko