Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1844743rwd; Wed, 17 May 2023 02:05:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7wHlvK383NeoJHEocU0e83OoSgRtNUB5mVTFh5Q3/y5loMeC7zBtEDnz/2mbZIlZW9MWiM X-Received: by 2002:a05:6a20:3d88:b0:105:27c3:1bfc with SMTP id s8-20020a056a203d8800b0010527c31bfcmr17512533pzi.51.1684314311121; Wed, 17 May 2023 02:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684314311; cv=none; d=google.com; s=arc-20160816; b=H+IG7AmW3PqVm68Qvt3KMvBOeG10lUcNssEEEqlV79my/Tqrjv4jLFfSofqgropTAs Owaf8mCvUplDyvdxesFsSPDJScHlN93vbdz4IX6dvGtPdfMd4q1lyFm/hw05TjR9cH5r 5n2DVnwpfYnldoQCqNqAn4uwgFgqcHIQaLTDPZoEZKIsTIZNlOlgUziXC5k09lswKeEi cNkhBWpwHy6sGzCfDOzmrcicDF0A5YTyasK2YykZvBPoufeDEqQItUR5/R1ck4uKDYKG 0rDaxeFxJdw8WFB6E6h9Zs1JLCUT7XfvNAOCjZmn/ICHErbSHpQ+pMFDQ5/oERdgJqUR X+Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=BhjK5yazou5RvTWn30tpmSdINFxSKMIDQ661jcxLjOE=; b=VcfrJ6A15coeW0ADa7RSzl1f1s7FWJ7HFXnOHpOzxkYadZ/LWIj1wmgZj1f6O6ygsR iUxHlLViZsGiHzAJWGZvIpo2QF2x+VQ+HGnLlbdBmyi4n4tSuXPVdhT/saCuA/tpbxcV WHQqCh7U/bOF5tW68BF55jYgm79kG9QP5sj1KytZLhTL/EA5o1KCcP7LZ+7e2wAwPGU+ XryKok50LCF7nA/UiLzuIvXdhXe7w5j/XmjveabCnI/ZTiNOZTuWRAzQAgn1YA5hI/Ga 4CfjVjZPNvpQZYm8yfuZPjjdAFwS88VYQ+Ljzwbrb5tbeOfAtqr00mzuKanSNoMeEtp7 G3zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Hdfs3Zyu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h14-20020aa79f4e000000b00645e8c9e282si21540867pfr.189.2023.05.17.02.04.57; Wed, 17 May 2023 02:05:11 -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=@redhat.com header.s=mimecast20190719 header.b=Hdfs3Zyu; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230393AbjEQI2L (ORCPT + 99 others); Wed, 17 May 2023 04:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230436AbjEQI1u (ORCPT ); Wed, 17 May 2023 04:27:50 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEA3F4209 for ; Wed, 17 May 2023 01:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684312022; 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=BhjK5yazou5RvTWn30tpmSdINFxSKMIDQ661jcxLjOE=; b=Hdfs3ZyuzW17C5O28jpqFd56YDik0Ryg9x3VOJymCYphVmj3AduM7G5Os37yWIF7bkea9q 0nwj2utkmc0Q3PyObVwlECLImOOW63eShhFmoNj3mGxB2bqqkafNS/ZvzOOAw+j9fPgoG5 KMVzOQJSfUse2PNxPWvD2Cxow3OWDsA= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-630-kh-Xj1KQOIqDA0dsSCFPvg-1; Wed, 17 May 2023 04:27:00 -0400 X-MC-Unique: kh-Xj1KQOIqDA0dsSCFPvg-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f4dd7f13d0so2053465e9.3 for ; Wed, 17 May 2023 01:27:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684312019; x=1686904019; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BhjK5yazou5RvTWn30tpmSdINFxSKMIDQ661jcxLjOE=; b=QUvzvbxbohbF4XfQmV6gx70KeasoKoypRd9awxqQr9fkpAv7y+ussqI1/zplTjKbKA 44s64yzU96TdahSQAMs7D1GLYzaFht760ITwbcpSRptw+YvjX7/zYQqDO3geMoDE+FJO rISeh0lKR5H7o7tMEIkqSTf7YVZDbPbC5BjUsnkoUiByk98/9pmSQDe/gYA/wFT7VcdK fiLzzAoLyc833ssrghXIhYOa5IDj++9hr8zKNq1ILFfAcIkfbf/LbSWjbfHWzBCorhX6 lxBuUalVr0Li4mO8ca1rvi+xsbH/V/n9d271QmrDU87Gt2NfriEoXrNn4NyekcyrJGvQ zSrA== X-Gm-Message-State: AC+VfDyFequWb1bbwY9+HQZVamPOtVn8H0pfN2TFmp+EkYu0d2CJMhP2 Fo3r2N08HUJqN5l+2yScVuv35jBtvruGbOyRDKrpLFlbvvScbh7WOVRUfdMh+KvRoyFiRqI6Vco zxfDCsxQcV/XGr3A38duy+/nU X-Received: by 2002:a05:600c:2141:b0:3f4:fd67:6d7c with SMTP id v1-20020a05600c214100b003f4fd676d7cmr9063708wml.40.1684312019279; Wed, 17 May 2023 01:26:59 -0700 (PDT) X-Received: by 2002:a05:600c:2141:b0:3f4:fd67:6d7c with SMTP id v1-20020a05600c214100b003f4fd676d7cmr9063676wml.40.1684312018895; Wed, 17 May 2023 01:26:58 -0700 (PDT) Received: from [192.168.3.108] (p4ff23b51.dip0.t-ipconnect.de. [79.242.59.81]) by smtp.gmail.com with ESMTPSA id a3-20020a05600c224300b003f17848673fsm1416580wmm.27.2023.05.17.01.26.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 May 2023 01:26:58 -0700 (PDT) Message-ID: <3c11455b-3af4-eeaa-9f43-49d4d70348fd@redhat.com> Date: Wed, 17 May 2023 10:26:56 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Content-Language: en-US To: Lorenzo Stoakes , Christoph Hellwig 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 , Mika Penttila , Dave Chinner , Theodore Ts'o , Peter Xu , Matthew Rosato , "Paul E . McKenney" , Christian Borntraeger References: <0eb31f6f-a122-4a5b-a959-03ed4dee1f3c@lucifer.local> <59c47ed5-a565-4220-823c-a278130092d5@lucifer.local> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH v9 0/3] mm/gup: disallow GUP writing to file-backed mappings by default In-Reply-To: <59c47ed5-a565-4220-823c-a278130092d5@lucifer.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham 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 15.05.23 13:31, Lorenzo Stoakes wrote: > On Sun, May 14, 2023 at 10:14:46PM -0700, Christoph Hellwig wrote: >> On Sun, May 14, 2023 at 08:20:04PM +0100, Lorenzo Stoakes wrote: >>> As discussed at LSF/MM, on the flight over I wrote a little repro [0] which >>> reliably triggers the ext4 warning by recreating the scenario described >>> above, using a small userland program and kernel module. >>> >>> This code is not perfect (plane code :) but does seem to do the job >>> adequately, also obviously this should only be run in a VM environment >>> where data loss is acceptable (in my case a small qemu instance). >> >> It would be really awesome if you could wire it up with and submit it >> to xfstests. > > Sure am happy to take a look at that! Also happy if David finds it useful in any > way for this unit tests. I played with a simple selftest that would reuse the existing gup_test infrastructure (adding PIN_LONGTERM_TEST_WRITE), and try reproducing an actual data corruption. So far, I was not able to reproduce any corruption easily without your patches, because d824ec2a1546 ("mm: do not reclaim private data from pinned page") seems to mitigate most of it. So ... before my patches (adding PIN_LONGTERM_TEST_WRITE) I cannot test it from a selftest, with d824ec2a1546 ("mm: do not reclaim private data from pinned page") I cannot reproduce and with your patches long-term pinning just fails. Long story short: I'll most probably not add such a test but instead keep testing that long-term pinning works/fails now as expected, based on the FS type. > > The kernel module interface is a bit sketchy (it takes a user address which it > blindly pins for you) so it's not something that should be run in any unsafe > environment but as long as we are ok with that :) I can submit the PIN_LONGTERM_TEST_WRITE extension, that would allow to test with a stock kernel that has the module compiled in. It won't allow !longterm, though (it would be kind-of hacky to have !longterm controlled by user space, even if it's a GUP test module). Finding an actual reproducer using existing pinning functionality would be preferred. For example, using O_DIRECT (should be possible even before it starts using FOLL_PIN instead of FOLL_GET). That would be highly racy then, but most probably not impossible. Such (racy) tests are not a good fit for selftests. Maybe I'll have a try later to reproduce with O_DIRECT. -- Thanks, David / dhildenb