Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3069160imu; Mon, 17 Dec 2018 12:44:34 -0800 (PST) X-Google-Smtp-Source: AFSGD/V/FStTZ0I4KpSeNWd5cD4Qd3Bgd4faz7Bk2pYPPf7uNO9EzfzBYcsOLoqu1uoWXRssJeiO X-Received: by 2002:a17:902:298a:: with SMTP id h10mr14120305plb.312.1545079474572; Mon, 17 Dec 2018 12:44:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545079474; cv=none; d=google.com; s=arc-20160816; b=oIY1362/uWX+YDUHyNvQv3jHWpktFcQV5i/h8QikrGjfQ4QiZ752SiMqUpllSY92E5 SNmaL0e/X2hYHkPSOws7RvgDdbZ/OxMRLG/M0CEBjINteU9pnxP6vc6ZMCcSzMhQU0ei rA43sdk3Kmi4YWZyjiotP6WLcOkelYdmxfEso/0LXsLdKUq0SsTnUCjJ6rbokE6IhOFc HoTz73X2Be6UjxZvrjFLiZDRtNHBdquHM0XLXPMLnfT7JwcEeaF52gIZ1QO/JuI56kD4 kMt5NajFZLYaG66ZeSBsewe0vENtH0Zc5Xe9n8DI0CyUuhVLl+jubf5flS/iItNP/SLi Tm0Q== 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=gVRO2QXLVwxnhR+i8MIpln/BndyUBWK/U6AvEGMVXG0=; b=dwZu9HpHTqJtriVTrpijlcYEQqGMkoTDGQgFbxyBLSuWAA2clMkYXrhUgUgnMoDaiO i3gUXrZY1IZQdUI0sRMUQg0ChCedCZccY4V9p8PRWpljiQnAt6I16hoNkn3cY/nuS/gW lM3Mwg3NolxGev/cJcSSnKZFg9D3Hz/+i8sAbrCjRapOfX3zIOtvC7w8973Q3Sn3XGxO 4mPofRZFp821ypJB+yB31WWS7nGa/iXml4qNirXuik5PYdUt8+mEYInPQXQtMQBjIJrQ 4Onb9/O9KY5qL/JzhEcFZTZqvHkBJFmli0Yce4PRSC0WOI0Y2Jvnv3AO+4OcPN3srblo ex3g== 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 a18si11419224pgj.77.2018.12.17.12.44.18; Mon, 17 Dec 2018 12:44:34 -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 S2388583AbeLQTy4 (ORCPT + 99 others); Mon, 17 Dec 2018 14:54:56 -0500 Received: from mga18.intel.com ([134.134.136.126]:64988 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726989AbeLQTy4 (ORCPT ); Mon, 17 Dec 2018 14:54:56 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2018 11:54:56 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,366,1539673200"; d="scan'208";a="284253898" Received: from quwen-mobl.ccr.corp.intel.com (HELO localhost) ([10.249.254.215]) by orsmga005.jf.intel.com with ESMTP; 17 Dec 2018 11:54:49 -0800 Date: Mon, 17 Dec 2018 21:54:48 +0200 From: Jarkko Sakkinen To: Andy Lutomirski Cc: Dave Hansen , Sean Christopherson , X86 ML , Platform Driver , linux-sgx@vger.kernel.org, nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, Haitao Huang , Andy Shevchenko , Thomas Gleixner , "Svahn, Kai" , mark.shanahan@intel.com, Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Darren Hart , Andy Shevchenko , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v17 18/23] platform/x86: Intel SGX driver Message-ID: <20181217195448.GE29785@linux.intel.com> References: <20181116010412.23967-1-jarkko.sakkinen@linux.intel.com> <20181116010412.23967-19-jarkko.sakkinen@linux.intel.com> <7d5cde02-4649-546b-0f03-2d6414bb80b5@intel.com> <20181217180102.GA12560@linux.intel.com> <20181217183613.GD12491@linux.intel.com> <20181217184333.GA26920@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 Mon, Dec 17, 2018 at 11:25:47AM -0800, Andy Lutomirski wrote: > On Mon, Dec 17, 2018 at 11:17 AM Dave Hansen wrote: > > > > On 12/17/18 11:12 AM, Andy Lutomirski wrote: > > > So I'm not saying that you shouldn't do it the way you are now, but I > > > do think that the changelog or at least some emails should explain > > > *why* the enclave needs to keep a pointer to the creating process's > > > mm. And, if you do keep the current model, it would be nice to > > > understand what happens if you do something awful like mremap()ing an > > > enclave, or calling madvise on it, or otherwise abusing the vma. Or > > > doing fork(), for that matter. > > > > Yeah, the code is built to have one VMA and only one VMA per enclave. > > You need to go over the origin of this restriction and what enforces this. > > There is a sad historical reason that you may regret keeping this > restriction. There are plenty of pieces of code out there that think > it's reasonable to spawn a subprocess by calling fork() and then > execve(). (This is *not* a sensible thing to do. One should use > posix_spawn() or some CLONE_VM variant. But even fairly recent > posix_spawn() implementations will fork(). So the driver has to do > *something* sensible on fork() or a bunch of things that use SGX > unsuspectingly via, for example, PKCS #11, are going to be very sad. > I suppose you could make enclaves just not show up in the fork()ed > children, but then you have a different problem: creating an enclave > and then doing daemon() won't work. > > Yes, POSIX traditions are rather silly. ATM enclave VMAs are not copied on fork. Not sure how you would implement COW semantics with enclaves. /Jarkko