From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 09661C55179 for ; Thu, 5 Nov 2020 16:04:46 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4839320936 for ; Thu, 5 Nov 2020 16:04:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=alien8.de header.i=@alien8.de header.b="TTyCVstW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4839320936 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=alien8.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A4A486B0138; Thu, 5 Nov 2020 11:04:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9D45E6B0139; Thu, 5 Nov 2020 11:04:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89ACE6B013A; Thu, 5 Nov 2020 11:04:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id 559426B0138 for ; Thu, 5 Nov 2020 11:04:44 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id D8331181AC9CB for ; Thu, 5 Nov 2020 16:04:43 +0000 (UTC) X-FDA: 77450837646.16.act36_4112111272cb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 9B670100E6917 for ; Thu, 5 Nov 2020 16:04:43 +0000 (UTC) X-HE-Tag: act36_4112111272cb X-Filterd-Recvd-Size: 4927 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 16:04:41 +0000 (UTC) Received: from zn.tnic (p200300ec2f0ee5006c78cd15f1739a31.dip0.t-ipconnect.de [IPv6:2003:ec:2f0e:e500:6c78:cd15:f173:9a31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 0EE661EC03A0; Thu, 5 Nov 2020 17:04:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1604592279; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SzsXHWOTotG9TSv9RImL2IoAhUNP7oiQrY5qi5tuMzg=; b=TTyCVstWqebTE3827G5LtgKLGpokNNaaiDLK72NkKv8n4FR4eGLhoqG67GosMAQP+nAxyu 8FHp+h1yYv1jkvGiKjeYd2WFJhZ9ElQ6sGBygTGjiO1EcfEqVqwPfxSoh9C/vSE+6N3Tqh a7tj641Cq/hxAICh/LzykJUSICAenIw= Date: Thu, 5 Nov 2020 17:04:24 +0100 From: Borislav Petkov To: Jarkko Sakkinen Cc: x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , linux-mm@kvack.org, Andrew Morton , Matthew Wilcox , Jethro Beekman , Darren Kenny , andriy.shevchenko@linux.intel.com, asapek@google.com, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, dave.hansen@intel.com, haitao.huang@intel.com, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com, mikko.ylinen@intel.com Subject: Re: [PATCH v40 10/24] mm: Add 'mprotect' hook to struct vm_operations_struct Message-ID: <20201105160424.GC25636@zn.tnic> References: <20201104145430.300542-1-jarkko.sakkinen@linux.intel.com> <20201104145430.300542-11-jarkko.sakkinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201104145430.300542-11-jarkko.sakkinen@linux.intel.com> Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000030, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Nov 04, 2020 at 04:54:16PM +0200, Jarkko Sakkinen wrote: > From: Sean Christopherson >=20 > Background > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >=20 > 1. SGX enclave pages are populated with data by copying from normal mem= ory > via ioctl() (SGX_IOC_ENCLAVE_ADD_PAGES), which will be added later i= n > this series. > 2. It is desirable to be able to restrict those normal memory data sour= ces. > For instance, to ensure that the source data is executable before > copying data to an executable enclave page. > 3. Enclave page permissions are dynamic (just like normal permissions) = and > can be adjusted at runtime with mprotect(). >=20 > This creates a problem because the original data source may have long s= ince > vanished at the time when enclave page permissions are established (mma= p() > or mprotect()). >=20 > The solution (elsewhere in this series) is to force enclaves creators t= o > declare their paging permission *intent* up front to the ioctl(). This > intent can me immediately compared to the source data=E2=80=99s mapping= and > rejected if necessary. >=20 > The =E2=80=9Cintent=E2=80=9D is also stashed off for later comparison w= ith enclave > PTEs. This ensures that any future mmap()/mprotect() operations > performed by the enclave creator or done on behalf of the enclave > can be compared with the earlier declared permissions. >=20 > Problem > =3D=3D=3D=3D=3D=3D=3D >=20 > There is an existing mmap() hook which allows SGX to perform this > permission comparison at mmap() time. However, there is no correspondi= ng > ->mprotect() hook. >=20 > Solution > =3D=3D=3D=3D=3D=3D=3D=3D >=20 > Add a vm_ops->mprotect() hook so that mprotect() operations which are > inconsistent with any page's stashed intent can be rejected by the driv= er. >=20 > Cc: linux-mm@kvack.org > Cc: Andrew Morton > Cc: Matthew Wilcox > Acked-by: Jethro Beekman > Reviewed-by: Darren Kenny > Signed-off-by: Sean Christopherson > Co-developed-by: Jarkko Sakkinen > Signed-off-by: Jarkko Sakkinen > --- > include/linux/mm.h | 3 +++ > mm/mprotect.c | 5 ++++- > 2 files changed, 7 insertions(+), 1 deletion(-) This needs an ACK from an mm person. --=20 Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette