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=-10.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 2C164C47097 for ; Thu, 3 Jun 2021 13:14:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B6B93613BF for ; Thu, 3 Jun 2021 13:14:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6B93613BF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=emersion.fr Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DB88E6B00AE; Thu, 3 Jun 2021 09:14:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D68846B00AF; Thu, 3 Jun 2021 09:14:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C097C6B00B0; Thu, 3 Jun 2021 09:14:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 8B76C6B00AE for ; Thu, 3 Jun 2021 09:14:51 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 235A8180AD802 for ; Thu, 3 Jun 2021 13:14:51 +0000 (UTC) X-FDA: 78212457582.10.78D7207 Received: from mail2.protonmail.ch (mail2.protonmail.ch [185.70.40.22]) by imf21.hostedemail.com (Postfix) with ESMTP id 2F113E00027E for ; Thu, 3 Jun 2021 13:14:32 +0000 (UTC) Date: Thu, 03 Jun 2021 13:14:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail3; t=1622726088; bh=zvZG+KNrKsbetpCBgPErfPJwO6MpNxHlXwG7DMuT3J4=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=KLrPCUk/xa/J4AxaB3vZpUw7LDGaakyDvn37cAL+jfr6vlg3jC9MKqq4hzM964NPJ rmUciJgUMX39tk9SLPMJFZk+tfBtXMpf7/nrMNMmX3rvnSLAG3zrE+97SAmhW0b+A5 WogkweWoBKYwmlq8mBE0WpdmRJNElUBKxUknUA48lODDpXmIB0KYKTgAeNKb9TvVQr ox1IHZ6HZ1llIuCu3Tc4gYYDnZRx/igojes/AqkbR7UU3321vI5dwusDAY1CQmgjNF M7AcT9L6ZKQd05h89IaNJd06AhsftywLt25vOHSMVBZTq4ZEnyu7NmOwASb5AqriVz 3pfpv8akEgz2A== To: Hugh Dickins From: Simon Ser Cc: Linus Torvalds , "Lin, Ming" , Peter Xu , "Kirill A. Shutemov" , 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: References: <7718ec5b-0a9e-ffa6-16f2-bc0b6afbd9ab@gmail.com> <80c87e6b-6050-bf23-2185-ded408df4d0f@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=emersion.fr header.s=protonmail3 header.b="KLrPCUk/"; dmarc=pass (policy=none) header.from=emersion.fr; spf=pass (imf21.hostedemail.com: domain of contact@emersion.fr designates 185.70.40.22 as permitted sender) smtp.mailfrom=contact@emersion.fr X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2F113E00027E X-Stat-Signature: t4p46fdagbgr9gnc4zjrx5586n8anurd X-HE-Tag: 1622726072-46509 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Saturday, May 29th, 2021 at 10:15 PM, Hugh Dickins wr= ote: > And IIUC it would have to be the recipient (Wayland compositor) doing > the NOFAULT business, because (going back to the original mail) we are > only considering this so that Wayland might satisfy clients who predate > or refuse Linux-only APIs. So, an ioctl (or fcntl, as sealing chose) > at the client end cannot be expected; and could not be relied on anyway. Yes, that is correct. > NOFAULT? Does BSD use "fault" differently, and in Linux terms we > would say NOSIGBUS to mean the same? > > Can someone point to a specification of BSD's __MAP_NOFAULT? > Searching just found me references to bugs. __MAP_NOFAULT isn't documented, sadly. The commit that introduces the flag [1] is the best we're going to get, I think. > What mainly worries me about the suggestion is: what happens to the > zero page inserted into NOFAULT mappings, when later a page for that > offset is created and added to page cache? Not 100% sure exactly this means what I think it means, but from my PoV, it's fine if the contents of an expanded shm file aren't visible from the process that has mapped it with MAP_NOFAULT/MAP_NOSIGBUS. In other words, it's fine if: - The client sets up a 1KiB shm file and sends it to the compositor. - The compositor maps it with MAP_NOFAULT/MAP_NOSIGBUS. - The client expands the file to 2KiB and writes interesting data in it. - The compositor still sees zeros past the 1KiB mark. The compositor needs to unmap and re-map the file to see the data past the 1KiB mark. If the MAP_NOFAULT/MAP_NOSIGBUS flag only affects the mapping itself and nothing else, this should be fine? > Treating it as an opaque blob of zeroes, that stays there ever after, > hiding the subsequent data: easy to implement, but a hack that we would > probably regret. (And I notice that even the quote from David Herrmann > in the original post allows for the possibility that client may want to > expand the object.) > > I believe the correct behaviour would be to unmap the nofault page > then, allowing the proper page to be faulted in after. That is > certainly doable (the old mm/filemap_xip.c used to do so), but might > get into some awkward race territory, with filesystem dependence > (reminiscent of hole punch, in reverse). shmem could operate that > way, and be the better for it: but I wouldn't want to add that, > without also cleaning away all the shmem_recalc_inode() stuff. [1]: https://github.com/openbsd/src/commit/37f480c7e4870332b7ffb802fa6578f5= 47c8a19f