Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3196156imu; Mon, 17 Dec 2018 15:16:40 -0800 (PST) X-Google-Smtp-Source: AFSGD/WtSh/AT7XljowAchkh7/A4hTa8c5UkADCRbJHE483kavLvgRZrgHS7qUyU81Xlcm4hfPzO X-Received: by 2002:a62:18ce:: with SMTP id 197mr15075692pfy.88.1545088600920; Mon, 17 Dec 2018 15:16:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545088600; cv=none; d=google.com; s=arc-20160816; b=b4crD2jYpVnEAHSMYlKsLgFraoSJ/vHAqA5YrmTOJ4RcGR+VCF3rUxXLFX9i8LXLmm h+zn0PUDJZOge4oyHzHnsKkvv3GmihYJmPHN8lwxu0GgUZDbYL0U6PFo6vu37//cytMR 79V3apq1r5a4BdoQcJeboloEfDc7Fmna5M95Ui0UBbPZ0UbfJKr5SgC3jf9N8uegbEAy WfbnOa79SCkQk8OD2u0jKkSsc7bYVypt4TY1uABPWBUFy3HBLP+2bkrnhlgWJ6Td0C4z CT8kfozOrq0yKx+E7LcwEzUoDHz5W/Cnk4hAWLMP2ILWkP+vGkfs3hK5S74qv0wBFZs2 1o5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XeoUyq/JgoSaJqOv3O84swKUzEWlXGZnkJBDgU2j8mA=; b=HSGouqBbRYZrjbBAKQmuAO2V6bYr7fbmM/8voZHTW2Xgrcmr53ybgN8iIv3ppATnt1 HtGjnFmBg7wTT1lPJbKu1nJCwb6uunK+CGqsVwScURUDqkICWuYMbYVX8gMmUyN0pHLb KPU7oM5++etmwMSnZKpl3/9221ot1NgBRekxAoWl1PICkjawbAS/UKsnyHxUGhNcX3q5 yqDdIXrJ4/FcLdZVXQbZ+FxxD+JYslLe2HfpV9dn2nbEQ8XwaFyBdU0hz0AI1GeQDzXF Bc70Mtqj9+JPg4hMdoYB0jHx49fv6ySbi+dvsNV4g6xVo2s49OpC+Dv6XLSPSTmq85gz RIJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="W8nlSLz/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i198si12612908pfe.289.2018.12.17.15.16.26; Mon, 17 Dec 2018 15:16:40 -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; dkim=pass header.i=@kernel.org header.s=default header.b="W8nlSLz/"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388124AbeLQT0F (ORCPT + 99 others); Mon, 17 Dec 2018 14:26:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:40434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727950AbeLQT0E (ORCPT ); Mon, 17 Dec 2018 14:26:04 -0500 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5226321783 for ; Mon, 17 Dec 2018 19:26:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1545074763; bh=P1xUfZc9TtT1RfxBrBvA9rx94XTVxDT3E4hXNRMQ+Ww=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=W8nlSLz/FdBoMrvH7QGAsVBuKDapmwzv52P0BVbfXVyErEviP5S+cMAUXsrMKHLcc K3Bc3qRD4G3WaHQKo5MhRUVG8xRpiyDOu94sFxpHlDL46Xi/2VPlco1NzGEoDwm9ZM CdPK6XqWWqJ8vLSAQEG721qoOFKc4ZehkHi2LYN4= Received: by mail-wr1-f49.google.com with SMTP id l9so13454925wrt.13 for ; Mon, 17 Dec 2018 11:26:03 -0800 (PST) X-Gm-Message-State: AA+aEWb0xWt2ttyk2CXKAZ5pHqLAYwvftGaTxsPVp53nyQeUdCLL/d6q 3TBNfaHUBfJjOtE+RqKEb875y3hu84Leym6SS4YW1A== X-Received: by 2002:a5d:550f:: with SMTP id b15mr12470572wrv.330.1545074759934; Mon, 17 Dec 2018 11:25:59 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: From: Andy Lutomirski Date: Mon, 17 Dec 2018 11:25:47 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v17 18/23] platform/x86: Intel SGX driver To: Dave Hansen Cc: Andy Lutomirski , Jarkko Sakkinen , 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)" Content-Type: text/plain; charset="UTF-8" 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: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.