Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3482237ybg; Mon, 28 Oct 2019 13:37:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzG5qy3NL7rV9HDUrit9cEdcVCJuyKsdsHqBzJC7n1jyr0O/oAchpnk245CP8e5l2yFHa5S X-Received: by 2002:aa7:c590:: with SMTP id g16mr19185037edq.292.1572295029531; Mon, 28 Oct 2019 13:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572295029; cv=none; d=google.com; s=arc-20160816; b=xuVjOJDwM7iRaL84z7LbLcDX+qvkcVQrFIGvimWBwYXJjXWLwUkHT88SEoRR1/t6UE g5Cl7CQwbHu4M7qZG7Yc9fali4ud5Par1+ojuSTx54H4smbSL/MH+UReGYnZ+64hQG6P Sm5G58h+g5yIJlOtYjzPGb30xevsC1BbV5z6ubChs6N5XthENeIi6O3x4zkaBLWRK4/i Mp1x9qisWrmviJRnr1+sH/+5Q1lurlS5UCM1J8JVuKgZT2hO+BTvMNhemOhexUY0jXf/ Af+2AfSyuqkyr40bpsg6ap7VVBtk37+ODJxcwTl/z5/u/M3vHecpHAOo+aGJDET84Cj3 8s6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=RcPtv5d4Xhg7Yg5t5dc7cf1sdnUkFOizbhSvjAdERFI=; b=EBioBN8tyYhh2Cvdd5FpOobhqR7R1qx36m9JSZ/88BMv/avZr+4TZR1HR2zQWC08vw a9STy4fe7uVsjVvpmnexDPY3v9O+hw9MRz1eFvsUNtnxPZ4hxuQz6SxHRkWdWy7/U/jX Dqn5UrAFcrD/pFqZ2EX2aq+6sF2WSJ0QpRU1EqcvMi//0SkdU/bkIChAjF3xOcaWWE14 lkGpUhBLByKOZiaaKk1aAWxZKohkBQuqpCXnCnfKwDEk7MvriOFVrRINPey4In5SfsAY q8/C/X60J/tEC5WbpS8fITMZlVT7szd5DprI6Ea24Wkx5IgvGhcEarbSrbMe4f1G/0CX 3LQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=utV3o3aT; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w27si8300872eda.296.2019.10.28.13.36.45; Mon, 28 Oct 2019 13:37:09 -0700 (PDT) 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=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b=utV3o3aT; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388728AbfJ1NQY (ORCPT + 99 others); Mon, 28 Oct 2019 09:16:24 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:34075 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388553AbfJ1NQX (ORCPT ); Mon, 28 Oct 2019 09:16:23 -0400 Received: by mail-lj1-f195.google.com with SMTP id 139so11126856ljf.1 for ; Mon, 28 Oct 2019 06:16:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=RcPtv5d4Xhg7Yg5t5dc7cf1sdnUkFOizbhSvjAdERFI=; b=utV3o3aTqHm5KCIW69feKUGPuTsUaHcp/zpYcTzvlXi3Olyfe1n4hKAzlQ3gdcEU3p +QuGe8rjB2g0Q7BIO4DNZGZICNhpkadVJx6bhQNCcPFHCbbNxkbF8orYFak5554TAru/ zMFayG+JhL2iTkDnZS3Ij6Xzb7NTBaWhtt+JCUB0Rwk/pt5gSDRIBDeaJ43vJywfeHAW SVXD2yhcM/0PInIsF3BvsDNaIHhqr3EAHAyEtdAxKawuv7fbhwNuNFOfPrC/zMa/xlJp RMwOt9XPvVBsYbuKzo3XnYLSDEEF3Q9ZhMMpv50JXGIKgrSy8rO2t6dogMuXPfXa0Yni l7eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=RcPtv5d4Xhg7Yg5t5dc7cf1sdnUkFOizbhSvjAdERFI=; b=THABzz71MeP+9tnm5XeSEjxuNMh/qhvPC9UXyyZdjz473fP4y580O1L1RI1IiZY1KU Il+5ydsM0+wzCIkc4NsWK05g6W+P605iTZnkpISbIeE/Vlx8lOhfuLnMP7KxTtwlPSnP wsSDpCr+MryvKIUvrUDn5MSwvEa9+JBjccVn1XF2E9NLKsifuGKLwiv/BSJ030XJDGwy Ik2li4xYyBXF9g6pnr4J7ZiP6advFx4dZCZCk67ERAgH6cAzoKmSfvc5ysCm/o2FCVYn Mqd4EV+2UHGlP8bY/GXP32K4W+v7n0CaVIoXTzVZ8JEDrKjnCAc3eBBjmYPepMYgWeXa bqRQ== X-Gm-Message-State: APjAAAVMBxdyjA9lBmKoXsxcBPtCN8XGNYRgNYppEND9wNMH32rJ+ZrO oTPdquKvmfUPB+umFaZ/+3k1EQ== X-Received: by 2002:a2e:924a:: with SMTP id v10mr11766000ljg.134.1572268582067; Mon, 28 Oct 2019 06:16:22 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id y20sm8981461ljd.99.2019.10.28.06.16.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 06:16:21 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id 23644100242; Mon, 28 Oct 2019 16:16:23 +0300 (+03) Date: Mon, 28 Oct 2019 16:16:23 +0300 From: "Kirill A. Shutemov" To: Mike Rapoport Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan , Andrew Morton , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Dave Hansen , James Bottomley , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , linux-api@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org, Mike Rapoport Subject: Re: [PATCH RFC] mm: add MAP_EXCLUSIVE to create exclusive user mappings Message-ID: <20191028131623.zwuwguhm4v4s5imh@box> References: <1572171452-7958-1-git-send-email-rppt@kernel.org> <1572171452-7958-2-git-send-email-rppt@kernel.org> <20191028123124.ogkk5ogjlamvwc2s@box> <20191028130018.GA7192@rapoport-lnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191028130018.GA7192@rapoport-lnx> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 28, 2019 at 02:00:19PM +0100, Mike Rapoport wrote: > On Mon, Oct 28, 2019 at 03:31:24PM +0300, Kirill A. Shutemov wrote: > > On Sun, Oct 27, 2019 at 12:17:32PM +0200, Mike Rapoport wrote: > > > From: Mike Rapoport > > > > > > The mappings created with MAP_EXCLUSIVE are visible only in the context of > > > the owning process and can be used by applications to store secret > > > information that will not be visible not only to other processes but to the > > > kernel as well. > > > > > > The pages in these mappings are removed from the kernel direct map and > > > marked with PG_user_exclusive flag. When the exclusive area is unmapped, > > > the pages are mapped back into the direct map. > > > > I probably blind, but I don't see where you manipulate direct map... > > __get_user_pages() calls __set_page_user_exclusive() which in turn calls > set_direct_map_invalid_noflush() that makes the page not present. Ah. okay. I think active use of this feature will lead to performance degradation of the system with time. Setting a single 4k page non-present in the direct mapping will require splitting 2M or 1G page we usually map direct mapping with. And it's one way road. We don't have any mechanism to map the memory with huge page again after the application has freed the page. It might be okay if all these pages cluster together, but I don't think we have a way to achieve it easily. -- Kirill A. Shutemov