Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp635054pxb; Tue, 3 Nov 2020 08:32:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1wRKFwTnpG9srQ6xzLIu5Xskhv4sPfRE1QGOGOAZcY4src1RDmPdbOx8zz6DbIdDtuN3Z X-Received: by 2002:a17:906:3092:: with SMTP id 18mr20904411ejv.43.1604421134633; Tue, 03 Nov 2020 08:32:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604421134; cv=none; d=google.com; s=arc-20160816; b=mSeJkpPJKBosEjbLv6FirLsDM2HS1ETlkW7kXamqVhjRypzyF0XcNLzKNRwbbi7apJ kGMmMa6+4UNp/BnCyj1Zio/gWv61qzKs7n/UKYAUusZrVotmUOufWVm67IOFVEA4BlZb X78dUNFfOatTnAJQNYR9NnSsqMbZMHbXKbajq2BgIlPTLS5g1FDlnXfJFmk9LV7w+M37 9ZBxgUxEexsWey2dqhg3ebgm4FM1PvSDnS/Id/zY96QhsewwbqG0DsYc4NzoHwYQPBGi sq+0ZeoDgMzXB1x3ST+NFbZXNiIKx+PcTae9Kx3EqaG9BF3U1D7Q1aKNh/meQ69Qt9bH 5qug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=yYR/ZNJZkGu6zB0NhjdzVADen4gEbA1kl5eRBT+Di6o=; b=de8IbPKfjXlG0U9d47FQmK8Qus5rz2RefC8/NLQKySyKrR38cF6C1XnI1E9C72svIA 1gE58zUcxXGDRC6zXupGmO4It2BnUCpa6O4LlFGcAqGlEebOMatwS5jGHsiAu1E4tKn8 VfovRJBmzIhPFqwFACZnjdNisJTGR0J9TuA9341xruc5/kkz27qePSOZ/9DsLOVEXrL4 hD6al07MUfHJVaOi0rKzDC34pwXjBQGaObviT3KLYV0uIJNG4vDlk/0lRdYopjViNBMS TMqxHKt6A5JXEj9+/SlpsIotAB3DRf4UrSc2moqYKjJG+uXev4+JQpNPhfI3+fgFvZi6 YQxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aIT9WT+B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id pw16si12436943ejb.430.2020.11.03.08.31.50; Tue, 03 Nov 2020 08:32:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aIT9WT+B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728387AbgKCQaS (ORCPT + 99 others); Tue, 3 Nov 2020 11:30:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:53470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728082AbgKCQaS (ORCPT ); Tue, 3 Nov 2020 11:30:18 -0500 Received: from kernel.org (unknown [87.71.17.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8FB1C206DF; Tue, 3 Nov 2020 16:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604421016; bh=jYHfX66WW2BdNqS2XWf0ysCG2+5llIa7XFBTFdDX/eI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aIT9WT+BvHALjjzBR+JANCva7x0iax3JsHcWBCEfbBEXiFyByvncM0vQDEjoMsNzh qIUHx4c/P1fmtrQLv9EIQHUB/NNPUa0sJ3XCbfY5Co0b/q6PUKAT7BitPwWCXDu5+c 05kTyD2Qgu6hQisAN/yBj1hMLhxnioRXXIEvqYek= Date: Tue, 3 Nov 2020 18:30:02 +0200 From: Mike Rapoport To: Hagen Paul Pfeifer Cc: Andrew Morton , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , David Hildenbrand , Elena Reshetova , "H. Peter Anvin" , Idan Yaniv , Ingo Molnar , James Bottomley , "Kirill A. Shutemov" , Matthew Wilcox , Mark Rutland , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , Thomas Gleixner , Shuah Khan , Tycho Andersen , Will Deacon , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, linux-riscv@lists.infradead.org, x86@kernel.org Subject: Re: [PATCH v6 0/6] mm: introduce memfd_secret system call to create "secret" memory areas Message-ID: <20201103163002.GK4879@kernel.org> References: <20200924132904.1391-1-rppt@kernel.org> <20201101110935.GA4105325@laniakea> <20201102154028.GD4879@kernel.org> <1547601988.128687.1604411534845@office.mailbox.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1547601988.128687.1604411534845@office.mailbox.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 03, 2020 at 02:52:14PM +0100, Hagen Paul Pfeifer wrote: > > On 11/02/2020 4:40 PM Mike Rapoport wrote: > > > > Isn't memfd_secret currently *unnecessarily* designed to be a "one task > > > feature"? memfd_secret fulfills exactly two (generic) features: > > > > > > - address space isolation from kernel (aka SECRET_EXCLUSIVE, not in kernel's > > > direct map) - hide from kernel, great > > > - disabling processor's memory caches against speculative-execution vulnerabilities > > > (spectre and friends, aka SECRET_UNCACHED), also great > > > > > > But, what about the following use-case: implementing a hardened IPC mechanism > > > where even the kernel is not aware of any data and optionally via SECRET_UNCACHED > > > even the hardware caches are bypassed! With the patches we are so close to > > > achieving this. > > > > > > How? Shared, SECRET_EXCLUSIVE and SECRET_UNCACHED mmaped pages for IPC > > > involved tasks required to know this mapping (and memfd_secret fd). After IPC > > > is done, tasks can copy sensitive data from IPC pages into memfd_secret() > > > pages, un-sensitive data can be used/copied everywhere. > > > > As long as the task share the file descriptor, they can share the > > secretmem pages, pretty much like normal memfd. > > Including process_vm_readv() and process_vm_writev()? Let's take a hypothetical > "dbus-daemon-secure" service that receives data from process A and wants to > copy/distribute it to data areas of N other processes. Much like dbus but without > SOCK_DGRAM rather direct copy into secretmem/mmap pages (ring-buffer). Should be > possible, right? I'm not sure I follow you here. For process_vm_readv() and process_vm_writev() secremem will be only accessible on the local part, but not on the remote. So copying data to secretmem pages using process_vm_writev wouldn't work. > > > One missing piece is still the secure zeroization of the page(s) if the > > > mapping is closed by last process to guarantee a secure cleanup. This can > > > probably done as an general mmap feature, not coupled to memfd_secret() and > > > can be done independently ("reverse" MAP_UNINITIALIZED feature). > > > > There are "init_on_alloc" and "init_on_free" kernel parameters that > > enable zeroing of the pages on alloc and on free globally. > > Anyway, I'll add zeroing of the freed memory to secretmem. > > Great, this allows page-specific (thus runtime-performance-optimized) zeroing > of secured pages. init_on_free lowers the performance to much and is not precice > enough. > > Hagen -- Sincerely yours, Mike.