Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp397080pxy; Wed, 5 May 2021 05:05:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRWYmeGBubc/6YC8SIYFuFolPSOFRUwYcba89q96njkX5j7gVsa3KSO4TCKJgu81FmCG9M X-Received: by 2002:a17:902:8502:b029:ee:beb2:e057 with SMTP id bj2-20020a1709028502b02900eebeb2e057mr22034041plb.30.1620216300367; Wed, 05 May 2021 05:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620216300; cv=none; d=google.com; s=arc-20160816; b=nJMc5hSnc1pNW9rArULXQ02D5F42Q0Bwxyt9yX/WIKUTdcUKZHycKs33qscm+lg1wD T3MLVG4MmldosjezZXtVSd6vQ8XRBOBAOLs5Fm9Au++8z05OHR6QK7dZunSiLpcbLdR6 EEfC+xK75RCzHSdgKrHi2zgScEzj1+LBSUYL369xHaiUWUYsVh/KqwQaattaEN4CIIuN DTZzMxxtNhnRemC7OgYXjbfQpFiX+qiljHAZlpkJR/2UIeT3C2bVhGNPRBaxkrAEOjvu 8R7I5qiZs9JXlL8qafmqAESzFNDnHQxf2zOmhoDI7gxcXtv8uOKS3qpcFulG40aAj2GT vh+Q== 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=3RksiCH8cPtPlWk0to7nyL1y138c0K4MSYx/+808EYk=; b=HwlToU7//ap2x17mVWLXjwnF9uaL6O7B6ta5lZnFOel8enayAb+e6NoeZD6FOgf5Ht vJxm+lvU2wBmXNeGsXHgv17cuKn0+05oi3LJMvJh9RKhJoWjoaajEDVyb/POQIbisFZ5 EkFR+FpIf5fbKHFMTjBPXB2c4bhT/HL2PYUrPVVGDEUoVHZcas+ff9hJps0DgczhG7Ay SXjFEz0nsX8QvkCErqxLeEk6tbLJbRZ0vohvNgcqkPpb9hkJNPJ5hQWcjFO7odbpuGqt HJaOmr5Wp+opQtPWpDfqhZhqOUVzZXtHA5gildmYp3Xi4uExV5A7FocJ76YkKsFinh2z M5Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@emersion.fr header.s=protonmail3 header.b=L1Pf1yT4; 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 w6si7220263plp.140.2021.05.05.05.04.46; Wed, 05 May 2021 05:05:00 -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=L1Pf1yT4; 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 S232464AbhEEKWc (ORCPT + 99 others); Wed, 5 May 2021 06:22:32 -0400 Received: from mail2.protonmail.ch ([185.70.40.22]:18132 "EHLO mail2.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232230AbhEEKWb (ORCPT ); Wed, 5 May 2021 06:22:31 -0400 Date: Wed, 05 May 2021 10:21:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail3; t=1620210093; bh=3RksiCH8cPtPlWk0to7nyL1y138c0K4MSYx/+808EYk=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=L1Pf1yT46Pzxfe9OzxG4g/ti/bt8/pX5+BOv5cn5Hz1sSX9ArWdWJg04JoFgxBkwa lDfZzBVdd1Sav2gpsHuJn2YY4i6ttsQ+Nt0Csvk03Dwi3hl977iSpRboqdkcK/J2Mu C3aENO9x9pWrufKsAjf4NtiQ6ipf9+sfrJWQhfxPRA6DF1JxscCIxyAp066yD0sFv/ YcqRgPcCB7L3QDz4wCB8zNm6DX9HIJ1Uu44qS+A0vmsW5g1Y5PTRFOkn48UUStNFkN 0l5iHCe2E18xiuCdXN40ST7SqCOwtbKPTnnJmWeBTROq3wFUS66UiV/lPYniRgrmL2 1ykVAgbWiw+ew== To: Linus Torvalds From: Simon Ser Cc: 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: <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, May 4th, 2021 at 6:08 PM, Linus Torvalds wrote: > On Tue, May 4, 2021 at 2:29 AM Simon Ser contact@emersion.fr wrote: > > > 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. > > So as Peter Xu mentioned, if we made it a "per inode" thing, we > probably could make such an inode do the zero page fill on its own, > and it might be ok for certain cases even for shared mappings. > However, realistically I think it's a horrible idea for the generic > situation, because I think that basically requires the filesystem > itself to buy into it. And we have something like 60+ different > filesystems. > > Is there some very specific and targeted pattern for that "shared > mapping" case? For example, if it's always a shared anonymous mapping > with no filesystem backing, then that would possibly be a simpler case > than the "random arbitrary shared file descriptor". Yes. I don't know of any Wayland client using buffers with real filesystem backing. I think the main cases are: - shm_open(3) immediately followed by shm_unlink(3). On Linux, this is implemented with /dev/shm which is a tmpfs. - Abusing /tmp or /run's tmpfs by creating a file there and unlinking it immediately afterwards. Kind of similar to the first case. - memfd_create(2) on Linux. Is this enough to make it work on shared memory mappings? Is it important that the mapping is anonymous? Thanks, Simon