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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AE5DC77B60 for ; Wed, 26 Apr 2023 08:57:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 98D276B00A6; Wed, 26 Apr 2023 04:57:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 93CA86B00A8; Wed, 26 Apr 2023 04:57:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B8876B00A9; Wed, 26 Apr 2023 04:57:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 6E8E86B00A6 for ; Wed, 26 Apr 2023 04:57:45 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 40DD7140209 for ; Wed, 26 Apr 2023 08:57:45 +0000 (UTC) X-FDA: 80722939290.18.3AE8E57 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 57B78140010 for ; Wed, 26 Apr 2023 08:57:42 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="a/75T1GF"; spf=pass (imf26.hostedemail.com: domain of mpenttil@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mpenttil@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682499463; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=qRhtGeXRPBB+p4cr9w0INOAc893fzDgBw6gSZ9r4K6o=; b=iHEuUrI8kDjf/0xRYasB6UrK7lyfx9bZHV8vjQgeENydAolnOTWB+e145cGn5bTNNk0zwD VxnbpZ70/gZQPCJOF6Z6I/N2yTc17lWCNFOwG8iJSTZA91alg9Kojhx7J5hngWypv+mPDZ 2hgcC+gBOfekzV2qXq3QBfhcVorr6TE= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="a/75T1GF"; spf=pass (imf26.hostedemail.com: domain of mpenttil@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=mpenttil@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682499463; a=rsa-sha256; cv=none; b=7TK1Tdzw+5wBB0sJYDAJGOFsVp330LscFeXLeQSZRp9zBkfIsmbmlC7kJ3W+ChR4kFVrsJ MkZ9KuaBRKUMvLWnsFOa56cAP7xQXHoHvqE3Hpp/YxNSrCC+cWlmLe2jTSaPHCYevPOd44 kpPusnNNdL8c5APLfYpUy5NCubmf+pg= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682499461; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qRhtGeXRPBB+p4cr9w0INOAc893fzDgBw6gSZ9r4K6o=; b=a/75T1GFpRzl1Z+jnp1c8vfEAAmvoM6nz//Vqf/CpG6jniPqbdbcDSDTkQ0IsvxWHfH802 TEvCS6h+58xDEelPQcT9K8IsRUwNsQBS3D3QFw/zEm6fzmqkb3agAHDE6TYvJs5VmLFyfO FSOIMZPHqjPXd/4sr1rc/lmzSOwRuAo= Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-lRHhXEqKP0CW8r5bp78cYA-1; Wed, 26 Apr 2023 04:57:40 -0400 X-MC-Unique: lRHhXEqKP0CW8r5bp78cYA-1 Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2ab26301bc6so8211791fa.2 for ; Wed, 26 Apr 2023 01:57:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682499459; x=1685091459; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qRhtGeXRPBB+p4cr9w0INOAc893fzDgBw6gSZ9r4K6o=; b=F2GUUdVW6ROTiRyDnRJ/jGHBoqLmnrWihPTKIvpIjD6xbXTImHuF3NHNkAivFwNqE/ ZXxZc5I4G2c5d5D7c+LaqQ8C2lDLD8KjnQIzFgniNAk/7jSFJhnKuTwPLVBRlpJdm7RA 0XHMZFFuCDdWots3JiS1CCf0Jdpl9kFxmaDjCVuQ8T/5/kad40sBMQ1NDAfL+i4WGF7I z8dNmSZRWWgbKF7ukUqyK29q3MYDTUJcUSAh0PnXHUlmu1NxEly27JsZL1git6yTPVMh XdCjP8w2cp+/nTPxxCoHOxcHTYjznWMUyU47J3MZy7qx52EK8a83ZGnJTA3yVOf7D2b2 zYMQ== X-Gm-Message-State: AAQBX9dCL3YRJJclxyAwdDb1zcufzyjRgRz6NjK7EkO+gMsu8Eqtt368 BYH5yazrDlzq+osEKXr6nUCyQyTwfH+VKGHSCBvAwkkTsCbx1zpiv7XuS1Qx5kNobw2uajcGBYz N2Il9DNRciA== X-Received: by 2002:a2e:6a14:0:b0:29b:d2f1:de9b with SMTP id f20-20020a2e6a14000000b0029bd2f1de9bmr4142467ljc.47.1682499458889; Wed, 26 Apr 2023 01:57:38 -0700 (PDT) X-Google-Smtp-Source: AKy350Yx9BB81vQR6fLd3lXwJ35Cz4Jj1Udt07gGaFpg1cOTHMdrnGmkcWc2ganLveGb7dCQC1foHQ== X-Received: by 2002:a2e:6a14:0:b0:29b:d2f1:de9b with SMTP id f20-20020a2e6a14000000b0029bd2f1de9bmr4142423ljc.47.1682499458568; Wed, 26 Apr 2023 01:57:38 -0700 (PDT) Received: from [192.168.1.121] (85-23-48-202.bb.dnainternet.fi. [85.23.48.202]) by smtp.gmail.com with ESMTPSA id y4-20020a2e9d44000000b002aa4713b925sm1793633ljj.21.2023.04.26.01.57.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Apr 2023 01:57:37 -0700 (PDT) Message-ID: <3562046e-1625-8536-910c-111d38acc346@redhat.com> Date: Wed, 26 Apr 2023 11:57:36 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v4] mm/gup: disallow GUP writing to file-backed mappings by default To: Lorenzo Stoakes Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Jason Gunthorpe , 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, Oleg Nesterov , Jason Gunthorpe , John Hubbard , Jan Kara , "Kirill A . Shutemov" , Pavel Begunkov , David Hildenbrand References: <3b92d56f55671a0389252379237703df6e86ea48.1682464032.git.lstoakes@gmail.com> <5ffd7f32-d236-4da4-93f7-c2fe39a6e035@lucifer.local> <831f0d02-7671-97bf-a968-e2e5bf92dfd7@redhat.com> From: =?UTF-8?Q?Mika_Penttil=c3=a4?= In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 57B78140010 X-Stat-Signature: 3sa9p4n6sohgsurch3bc4runayd1e5sb X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1682499462-867189 X-HE-Meta: U2FsdGVkX19PRTdzcUrnXQRVZIzxY784MrpOZ9/skp/eoNkUhKGtL58Eew9BJ0oLhMQXWhjNvSoEFXYzDcYPiRSlfhAo+VUb1IklXnNeXEU9+bDuNHXlMArGDp5uxg/8LF20Xpk2htK/Hcsh0tKYo3xzV7jUgfRFEainLBbffyRS4NGCMxs6yVSpgLgpCNftfHhWMc/01yrskJ7LAYhDV8o/rzqPvQumvRwi9N/3j8KFhGk8iPahsD8ruP1N28X6pkTrmSUodfbLmqd7qrsUS+yoXh1wW13wAjoe41Hj+F1hFLTlFrREIZyH2uroAQfl+YHCCMdPZvnudw4D3dUz+UzJYc8Aqfsw+annIYyBojXi5In8vIB49vchg3PlKDNggjqUBnxxYUBw50sti+g45lOABTs6oiQokP63GBSO/sEwqkUEJJO/Ltza85VlI+2azjhH/s07pYeQjQP9DQUKNu2TOZid/lWRgiS5uKPH3FomU+qfYNG2Lf3Wagw6Z0YvrjCziqKtGI/ZczVMnjLgV1sXZT4QHdPr4kKD4uZFAZeIYWH96O6blEW6oAgdJU8/lzKOlk4HKiTuv3PRnYrE/XZrFTMl+T1AoxAqa5M7FDuQqTCvHiOlrjkmaNyE8bd2sVV+BdWYyu3S/BiS0O5gAAszyZ18CSpMjGn+k0yI3cm5F57vDAOA0AweGaZgB5CUiOodBQabR594MRFuc/DPxQIRbHc79UWG9PTZNFVMv1Ya+WGUrcjmVaZPOld3DmSz8wGtOEdi3bsnpFAGRBjjWBiCY67iw6c00a/96hLKr3/Fdkdg/DLPpOCgkq1hrjwpCc1RszI3ss+fTLMQM1YLfCCPpAyVH2kpBFJzgTRG+Y/7xtwt6T7eOffmCye5M1AU3L32wiBL5hs+cb+P26iMsA1tgeyzrxTEXJHzKNyzzTWyhkyvfbQHXYcqWHo6OJvEzOWn2UiQ/dqVVyFLN88 zfkJZQyi Z8pbvTHFAnit+ihBAHuADER4hUkTwle0PXQ7pYqTMzn/cpJQYCXyT0/PjLOhvd87LSUi3NyCNeE92ryb6HtCMncbH4Nxo4Uk+DTuYE9qVXpQ1yXf4R58KMDumRmfWjeAw0qE9bc8YAyoHLr2jRt/XUCrDao+IvuAsWF+qzOyNi5WGybKKEoXaEi1sZMCxufqaEmEnWt9cDF0BXgmgcl6pms3w96/CLqSd741s70QqrOHSttLYN9mBRmDBdSA/aXN68Q5E+rAWgw/DxJtclwr+3xOYSbg2wrFJYAaY+9q6t3CeNO1q4ZThd7u61gtaKkhfXa831ZaPS3bP+eRUnXWV1ZJeath7OTtXfQeUzX39QBAXY9MY6A2PNepsYxdC2wU3AxMESnLFGRLVnX5Exs9m54dGoAw7Cs2d8sOy8FxwLItLypEVaGmA0pFfL27H0VBTilmwuZyDyc0j138MmribuiiTnQ== 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 26.4.2023 11.41, Lorenzo Stoakes wrote: > On Wed, Apr 26, 2023 at 10:30:03AM +0300, Mika Penttilä wrote: > > [snip] > >>> The issue is how dirtying works. Typically for a dirty-tracking mapping the >>> kernel makes the mapping read-only, then when a write fault occurs, >>> writenotify is called and the folio is marked dirty. This way the file >>> system knows which files to writeback, then after writeback it 'cleans' >>> them, restoring the read-only mapping and relying on the NEXT write marking >>> write notifying and marking the folio dirty again. >>> >> >> I know how the dirty tracking works :). And gup itself actually triggers the >> _first_ fault on a read only pte. > > I'm sure you don't mean to, but this comes off as sarcastic, 'I know how X > works :)' is not a helpful comment. However, equally apologies if I seemed > patronising, not intentional, I am just trying to be as clear as possible, > which always risks sounding that way :) Absolutely didn't mean that way, and thanks for being clear here! > > Regardless, this is a very good point! I think I was a little too implicit > in the whole 'at any time the kernel chooses to write to this writenotify > won't happen', and you are absolutely right in that we are not clear enough > about that. > >> >> So the problem is accessing the page after that, somewehere in future. I >> think this is something you should write on the description. Because, >> technically, GUP itself works and does invoke the write notify. So the >> misleading part is you say in the description it doesn't. While you mean a >> later write, from a driver or such, doesn't. >> > > Ack, agreed this would be a useful improvement. Will fix on next spin! Yes thanks, think so, at least found myself going thru and wondering what's wrong with the gup code itself, and not the later usage scenario... > > [snip] > --Mika