Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3202495pxj; Mon, 31 May 2021 23:25:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxrUAh0+F9Wc3yURgrneKZdDH7GSp29mSBMgoW0AwXSgRMorBOVMjNH2ZyqCZIQxKbtnV2P X-Received: by 2002:a05:6638:635:: with SMTP id h21mr23821441jar.135.1622528711338; Mon, 31 May 2021 23:25:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622528711; cv=none; d=google.com; s=arc-20160816; b=gKKwJa7AmQ2KoeFksxiko9HVLH+0Rv/Pas8vMWQLnqdbKOlBSYDYeLk5HFiUQzfTZ/ Wa/NGuwyOSxFYY4mVhydxNYNGVMW5y+RUFUQ1Z3LeMbbqVpW3zIbCEwV5hiBghFaPDcz rtzSdvIqkZVB2JNM4KzAc/MaJ2FZwkbxXnhA0hYjOOwAKISOntaAkLIEML1KNfleXf/q rVepnyDw20/nAlgxBuPInWkhzs5G3hOiff0h+DJXaPsHY1SXOHvKi553SwIrEwTPMX1z Jfb1n0vAAB9CFWKpmnO2X3OlyoX2VH0Mq3Loo+seK+RiTGEZF13t0+8CNp4XrWwENyLn XDVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=mtIHbTQEWZy03u+F/1bX9f+NRkMDtukdZ6wYfFJ5x2k=; b=s2GmjmxoTWTDX9fzumXmFqdtMHtWs6UjtXViFLJPzU7S/ERwY7tFeF3ZLYqlPjCNWr iaHHqnm3DhV5cjL1kZ7EuKnLGm07JYuWcDmRZAYHDdQbwUN4qwMh/Eb+1E1POloQH5A8 2wQH0VOfokn26lgEgwK5VrLrC5pNZ2QaOm09gvWuUBt1L3zZB2y5lLAOz2rfyMyA2K61 sAWttauq87NvLnKPb1XgIjbOV5V24JwiaH+TISlzb7dbmiQFbAcUXvxIEXKWqWBvjbmw YY2Kx6AC/eznMjHLptj9F80XNXhIfXkR3r9DDR7dw8dJktM9f8Cd3G+VT1wYhwlPseRH HcQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=XgRh5D8k; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m24si5793195ioc.67.2021.05.31.23.24.58; Mon, 31 May 2021 23:25:11 -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=@linux-foundation.org header.s=google header.b=XgRh5D8k; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232725AbhFAG0I (ORCPT + 99 others); Tue, 1 Jun 2021 02:26:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbhFAG0H (ORCPT ); Tue, 1 Jun 2021 02:26:07 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAB0CC061574 for ; Mon, 31 May 2021 23:24:26 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id q7so20033624lfr.6 for ; Mon, 31 May 2021 23:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=mtIHbTQEWZy03u+F/1bX9f+NRkMDtukdZ6wYfFJ5x2k=; b=XgRh5D8kPOBUFMoADvss3cc0DR+uLPy1UvRB6CNpi0uy2MKHLssEm9xlNM8k8vofWB M6H/dPrzWE78mQwAP9igsuCAeZYDAU+LOsg8UtnsTfENk5jFRwd2PYwVN+NzbLsRSOYB 3CBlfXdSCpwLafhzh9ucwlfibNxyaOWr+V0jA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mtIHbTQEWZy03u+F/1bX9f+NRkMDtukdZ6wYfFJ5x2k=; b=aG1ebOjtA+ZsNK5ORpWwRjr5wRlBLCvsRDxpLw3SkbfPNj6GSKWoybFO7MYlc+1QBX dX6cfxJuq6/wkO3/UkbQlc5c5ZsXfdJh7zB3RHgEuJMEpN46D1K2ricgmR8k0uCWcc1o FlinRt9i49WDRupvDK+bquyYQLKtUCV55/P2ExwH90uW8Tu6dP1uk0EAyvqDQZxzmcM/ VdCo6j7w1WEURI/2JgzJRR/KLAITRP7nKwK/oxjOwBaqK+ZD2iWm50q0ys/F87g032Dj nPpdfWkK6LvOLj3akWBeERZHvm0h9NC4Vse5lFGLhZIjwMurgFJBVoOJwHNiNbbdmlAs SrkA== X-Gm-Message-State: AOAM531AojSHyntcy1hRukl+EF9behKPEWiwLLIJn1+9fYGzKiVYH17s WJKHQi2qSf0oSC/L2BNt5fQSp5Z/wei/nymv X-Received: by 2002:ac2:5cd6:: with SMTP id f22mr9945435lfq.73.1622528664867; Mon, 31 May 2021 23:24:24 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id n5sm1578848lft.139.2021.05.31.23.24.23 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 31 May 2021 23:24:24 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id q1so20037476lfo.3 for ; Mon, 31 May 2021 23:24:23 -0700 (PDT) X-Received: by 2002:a05:6512:3f82:: with SMTP id x2mr11385070lfa.421.1622528663766; Mon, 31 May 2021 23:24:23 -0700 (PDT) MIME-Version: 1.0 References: <20210429154807.hptls4vnmq2svuea@box> <20210429183836.GF8339@xz-x1> <7718ec5b-0a9e-ffa6-16f2-bc0b6afbd9ab@gmail.com> <80c87e6b-6050-bf23-2185-ded408df4d0f@gmail.com> <36fc2485-11f1-5252-904d-f26b63a6cd58@gmail.com> In-Reply-To: From: Linus Torvalds Date: Mon, 31 May 2021 20:24:07 -1000 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Sealed memfd & no-fault mmap To: Ming Lin Cc: Hugh Dickins , Simon Ser , 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" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 31, 2021 at 11:13 AM Ming Lin wrote: > > OK, I borrowed code from filemap_xip.c and implemented this behavior. I think that "unmap page" is too complicated and fragile. The only page that could possibly validly be unmapped is a stale zero page, but that code in shmem_unmap_nofault_page() seems to try to handle other cases too (ie that whole page_remove_rmap() - afaik a zero page has no rmap). I get the feeling that the simpler thing to do is to just say "if you use MAP_NOSIGBUS, and you access pages that don't have a backing store, you will get zero pages, and they will NOT BE SYNCHRONIZED with the backing store possibly later being updated". IOW, just document the fact that a MAP_NOSIGBUS mapping isn't coherent wrt shmem contents that are expanded and filled in later. Don't try to "fix" it - because any user that uses MAP_NOSIGBUS had better just accept that it's not compatible with expanding the shmem backing store later. Keep it simple and stupid. Hmm? Linus