Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5942012rwr; Mon, 24 Apr 2023 11:07:12 -0700 (PDT) X-Google-Smtp-Source: AKy350bN/JwQm7KKSFSeDvO4hANkXwi8f6ssm/a8JZO32vvEgV4iousOPvhwpbW5jBvOkJB/33A3 X-Received: by 2002:a05:6a00:a93:b0:63f:244d:cd07 with SMTP id b19-20020a056a000a9300b0063f244dcd07mr14865655pfl.31.1682359632503; Mon, 24 Apr 2023 11:07:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682359632; cv=none; d=google.com; s=arc-20160816; b=VeeLDPtgXxFIWC9/I4dhQwPhJiEBqkUM/Ky2Ioz7am/GTpjpDqVigw3nFXsK/Pps2a lc7VcTJUtwv0/jgFBbxnVV8v2UQNMUOPKD7tSkOdEKUg8VGmPEoevW1diEtcYcDNZmVY VhveZenzizw0bsHKZ6IXJNk8U7HxUg71vTHIUTi+p0uSAoVqWlh4uxvT4EvRXeqT8y5b xzrGrCz8A1+LYAHRA90M84h5xZYu+2YQCLxaUwe5lj2/cWid5o9qBO9ZJdmcevguxENt Ek+u+nzaL+SzCq7kdj7cKUZGLBSW1HEST8b0Ii5E+YC9vU6a2Qn4PP3SAnnYxuV+z2TY rzmQ== 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=LlRkGSdEXncwM0PBf9n/N1FPqEniuAvpiADhOOV7oaU=; b=ATtqSQwxQ4NP41fpYp+SfNmp9KRhrlrkVw3B4yUt9thCNHPmPMxBmYkpCztnxgTCzT 0/GW9N/ul8e0YV2JRNedATMx0kNeF3mOai+mBtmS9BvyOyde7+bmxyo9CJgzzO5ULDeh VAdPFdZPdqpyNMuR4HbLRy/Eo5FV6VLIUxzOgdCdnxXI9zsZUWl4j++w+SiBILIDq40r VpzqOMZo6Ik832nOiUrGo0hnrd/Twg59kvqfO5IVTy//UWxzX9S0iKUB80L12n13n18S jjdmNgLteMzMlQtqDNzYQiMrRwaW4esrh4bFaMbpIfMbmt8ylrlOhwF8Gp/aCXrzC+b3 UI5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="Nc/htkEI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w82-20020a627b55000000b0062dbc05a323si8783200pfc.298.2023.04.24.11.06.59; Mon, 24 Apr 2023 11:07:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="Nc/htkEI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232229AbjDXSAL (ORCPT + 99 others); Mon, 24 Apr 2023 14:00:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232035AbjDXSAK (ORCPT ); Mon, 24 Apr 2023 14:00:10 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 763A07AB3 for ; Mon, 24 Apr 2023 11:00:08 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id d75a77b69052e-3ef31b7b868so42373911cf.2 for ; Mon, 24 Apr 2023 11:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1682359207; x=1684951207; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=LlRkGSdEXncwM0PBf9n/N1FPqEniuAvpiADhOOV7oaU=; b=Nc/htkEIM7gLjkyElNiu0ClSDaT8ixeMNVYverT4Tm8Q9Q9OmUiTTzNCWfTYN3JY4i V+5bdaILYV6CWcO+gcFbABYnFng3LljWEKwwI+QzYlCIhXwg6DldQAkO93ckNzLB1ndd txWe/8B/8qNJZHYbklf5BIvpG55Gm2ZBYc25jV33zJYpdshOJSHN3VEJQXFOxXfVcgd9 M8Ctfeoo5HB1UvFSdoWFVz4TMkfR+Xyw/8uaFHMdlWD+U2QfZld7gZQRo4owmGeVDOXF HSieHPxrfK5TlCfDK6e46UiFFsvGPA8bod8EDk6cBA9CxCj0fQUqfun/MS+9n7fGuFn3 /Fyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682359207; x=1684951207; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=LlRkGSdEXncwM0PBf9n/N1FPqEniuAvpiADhOOV7oaU=; b=B5u0z0tWmx9iB8cuCgbqiMXhm9IMpM9klUOXO9+nujUlGxay+S7uNLfa0Ih/469IoE 9cgQzND6aZm5puwDlxQ1AOLzcRHIz+QF1eRYnRP5bmJASW3Zc5NksJjYYsoJsNyC3hjt wU3dNPPJzEXUd7/iY+Z9n+p7OS+uZrGy9s6brl2XvbTUPnanm/HYvwdKQ9hqnVYf54u4 Qpgm/hwOfoJP8e3/cL9rKBae+kXwxF1cXoJezAn3L2c6Jt3Nr5lfHZC5SlLBUqejMvxQ IzYIIUhvJGh6mOZTr54OJVsd1Nm1YZ+t3VaGJL7z0VbQOT9Wndq+6ZJDqk/fIZx9rVtH SiWQ== X-Gm-Message-State: AAQBX9fxJJyG9o0j4qBETitm/bWZ88qOZsGjlN+Slz2vFv02Wf+bzQAF J363++jhvOniMQCV9OdY/mbRzQ== X-Received: by 2002:ac8:5cc8:0:b0:3ef:4da0:a1fc with SMTP id s8-20020ac85cc8000000b003ef4da0a1fcmr24514049qta.50.1682359207561; Mon, 24 Apr 2023 11:00:07 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id u28-20020a05622a199c00b003c034837d8fsm3812578qtc.33.2023.04.24.11.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 11:00:07 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.95) (envelope-from ) id 1pr0Tn-001VxD-Q2; Mon, 24 Apr 2023 14:59:59 -0300 Date: Mon, 24 Apr 2023 14:59:59 -0300 From: Jason Gunthorpe To: "Kirill A. Shutemov" Cc: Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jens Axboe , Matthew Wilcox , Dennis Dalessandro , Leon Romanovsky , Christian Benvenuti , Nelson Escobar , Bernard Metzler , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , Bjorn Topel , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Christian Brauner , Richard Cochran , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , linux-fsdevel@vger.kernel.org, linux-perf-users@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH] mm/gup: disallow GUP writing to file-backed mappings by default Message-ID: References: <20230424120247.k7cjmncmov32yv5r@box.shutemov.name> <3273f5f3-65d9-4366-9424-c688264992f9@lucifer.local> <20230424134026.di6nf2an3a2g63a6@box.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230424134026.di6nf2an3a2g63a6@box.shutemov.name> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 24, 2023 at 04:40:26PM +0300, Kirill A. Shutemov wrote: > > Something more general would be preferable, however I believe there were > > concerns broader than write notify, for instance not correctly marking the > > folio dirty after writing to it, though arguably the caller should > > certainly be ensuring that (and in many cases, do). > > It doesn't make much sense to me. > > Shared writable mapping without page_mkwrite (or pfn_write) will setup > writeable PTE even on read faults[1], so you will not get the page dirty, > unless you scan page table entries for dirty bit. The general statement for supporting GUP is that the VMA owner never relies on write protect, either explicitly through removing the write bit in the PTE or implicitly through zapping the inode and removing all PTEs. The general bug we have is that the FS does some action to prevent writes and then becomes surprised that the page was made dirty. GUP allows write access to the page to continue past any write protect action the FS takes. AFAIK all GUP users do correctly do mkdirty and we have helpers to support this during unpin, that is not the bug. So, I don't know about page_mkwrite, if it correlates with the abvoe then great :) Jason