Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp3452704pxy; Tue, 4 May 2021 02:32:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiTtvNTH1ipiXBTwzfCCsdHMgPe/7Fz324hNFJnWuBwYt00l+q+N3pxPWJrOFtsBOO0Y6a X-Received: by 2002:a05:6a00:2b5:b029:28e:9c4b:b8b4 with SMTP id q21-20020a056a0002b5b029028e9c4bb8b4mr9236716pfs.22.1620120740013; Tue, 04 May 2021 02:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620120740; cv=none; d=google.com; s=arc-20160816; b=svo1LA8MG4ks8RVb4GNNTCyeoGgVh8IArGRwBVf6jCjzZBH90T99KQuDjUYrxa9yQo g3nH/a8E2hhdEp9xvjL5nwEbe5VkxO6z2OTfPpsgbaqIu35C7ax1k4lScyjiZlaG37Gg IF1E0ZR6BS+nOihoHARBBkBrNuVEOAXT0UYsRo7Nvm6hXbYvUrn3xVyUQp7cPPxPDSyO tkwr+PLyzyjvt9Wpmt48WBwS8DR4n8716cQD8NGln2j2/ftPj8oIx3OvqhB4eLktGFxO 5gV90p2gx2vOm93nmjv6iBTHPEW8XcuqzyDtBP2ovS06D7Ar14lyxgZc4pF8MTXDSzES AkkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:reply-to:cc:from:to :dkim-signature:date; bh=8iedi1sBuOfuU+AkuHmOzKPH2PiTW40aDNApIMiPXLA=; b=o3A8r5ibvkxRxB/X2lgInIks4rrlwsKXCyS5P2lRVMIYj9bdaF54NkZi7wQQyWrQ0t G5JSOE7N1Bu6SbianPAVgFZQ5U0d/kQa6n/Ik8CKNc9hApSCuACzD5y78vim7K7ghjbi 6hDgeoRb6XqkjYyCXQ7i41ZtCXaMcSA3f4QoJnakEHHE8fmTqJ4yrC15xVh4oyIsWWoD nmAZqYPw8zP+DQ280/Df1pLOPiTMW9pk/kWyuuB5KdO0J2I7CPRdnsudbqlkrTHesvTP LTNPoiYIRkjjScvA6Pa3hS3CXJC/1qBZ/mJffMabfEbyaE+EXJiTAVV7Z+Bk2BIimi6g Vr4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@emersion.fr header.s=protonmail3 header.b=tAiyHvRC; 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=emersion.fr Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i22si2684363pjl.16.2021.05.04.02.32.06; Tue, 04 May 2021 02:32:20 -0700 (PDT) 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=@emersion.fr header.s=protonmail3 header.b=tAiyHvRC; 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=emersion.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbhEDJax (ORCPT + 99 others); Tue, 4 May 2021 05:30:53 -0400 Received: from mail1.protonmail.ch ([185.70.40.18]:38564 "EHLO mail1.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229903AbhEDJax (ORCPT ); Tue, 4 May 2021 05:30:53 -0400 Date: Tue, 04 May 2021 09:29:43 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail3; t=1620120596; bh=8iedi1sBuOfuU+AkuHmOzKPH2PiTW40aDNApIMiPXLA=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=tAiyHvRC8v8kPq68agftdrYPHDxDVNL7m4bPC7JlHMKGC8VOcVvgzDhHnEDilDOGQ wOIzmq7e59KCBq+O2mcWmQFdfko89fvthHPX8BlVJ3K8UjGHpp9677/lZd3+DwWihW ySBr9RH/6OcaFlob4DSW6VB8XvCWxfg293MAPBBuGJb7Cs6nrBOwhPSWSRA7KkHG4U jXzhFWc5FZPlbg6BO45/YgDUuz1rBG0R+5QCmR32EkJ/oyf6b2iufODTMdQBuK8dSf rZuFyvoMjozWTMPVbOaHnEWcS/JsbAvEgy1IlsalVXfKuU7RNelAkP0cJ26qji1ibV MwepNZanJfCpg== To: Peter Xu From: Simon Ser Cc: "Kirill A. Shutemov" , Linus Torvalds , Matthew Wilcox , Dan Williams , "Kirill A. Shutemov" , Will Deacon , Linux Kernel Mailing List , David Herrmann , "linux-mm@kvack.org" , Greg Kroah-Hartman , "tytso@mit.edu" Reply-To: Simon Ser Subject: Re: Sealed memfd & no-fault mmap Message-ID: In-Reply-To: <20210429183836.GF8339@xz-x1> References: <20210429154807.hptls4vnmq2svuea@box> <20210429183836.GF8339@xz-x1> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday, April 27th, 2021 at 6:51 PM, Linus Torvalds wrote: > Hmm. It doesn't look too hard to do. The biggest problem is actually > that we've run out of flags in the vma (on 32-bit architectures), but > you could try this UNTESTED patch that just does the MAP_NOFAULT thing > unconditionally. Oh, thanks for the patch! Will test. > Side note: this will only ever work for non-shared mappings. That's > fundamental. We won't add an anonymous page to a shared mapping, and > do_anonymous_page() does verify that. So a MAP_SHARED mappign will > still return SIGBUS even with this patch (although it's not obvious > from the patch - the VM_FAULT_SIGBUS will just be re-created by > do_anonymous_page()). > > So if you want a _shared_ mapping to honor __MAP_NOFAULT and insert > random anonymous pages into it, I think the answer is "no, that's not > going to be viable". > > So _if_ this works for you, and if it's ok that only MAP_PRIVATE can > have __MAP_NOFAULT, and if Kirill/Peter/Will don't say "Oh, Linus, > you're completely off your rocker and clearly need to be taking your > meds", something like this - if we figure out the conditional bit - > might be doable. Hm, that's unfortunate. For the use-case of a Wayland compositor this doesn't seem like a complete show-stopper: in 90% of cases the compositor only needs a read-only mapping. Wayland clients submit buffers they're rendered pixels to, compositors only need to read them. So the compositor could map with MAP_PRIVATE and still get up-to-date pages from a client process I think. The remaining 10% is when the compositor needs a writable mapping for things like screen capture. It doesn't seem like a SIGBUS handler can be avoided in this case then=E2=80=A6 Oh well. > That's a fair number of "ifs". > > Ok, back to the merge window for me, I'll be throwing away this crazy > untested patch immediately after hitting "send". This is very much a > "throw the idea over to other people" patch, in other words. Got it. I'll take over the patch if this is a good way forward.