Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2304405rwr; Fri, 28 Apr 2023 08:37:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ55l7Tzefs+266AIlboGlagecjfMd8PqYPxAsdFlA707Lek6gcNSfvAd07YK8VtVo/I9eAU X-Received: by 2002:a17:90b:474e:b0:247:1605:6e1a with SMTP id ka14-20020a17090b474e00b0024716056e1amr7207376pjb.0.1682696275051; Fri, 28 Apr 2023 08:37:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682696275; cv=none; d=google.com; s=arc-20160816; b=FGlknDajgjDZ52zclN64XfrIYK/eAf/qflR3XxrodGLt/u8JWTsisZ5Nzw/kjZPk/5 o+E/0XLybQYtQCF5hu2B8Nv9+xOkj968ODlKSZYbDZyYLRs9hQVhg95i+OUzXAFobgtg NW7ioA9FuLUkSljYaNweVNFwj7dKrO9FyuyxLtMmQmGTfvWkx32Fn5yuNTUWS6juiFeN XZ3+bwp9BNCk+uG3DiikFBMMXPzPgkRgv7UwhSRQ9rexKzEFj1//MUP05rE2LqehhkG1 p1zMyKIVe8M35JIA4DcofOdw7JrFHE6jY7Uy+QQXqZs/6am/xDWYLgRnCrU0OuWLjG+/ vlzA== 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 :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=i1I3bxKpOJ94ZKtbze6sl4BqpXL9nzWwU/RAx5bKUL4=; b=lbNgIXNAxchrblRn4Rau2t5ABfXiyzzqs5gLbBE+SgY3tdOCV4UkCBPEqrBpTdUz+G up/zgt6UnoJmcIyhlSEg75oJzd4BbY3I/wRkfl/CWv5hPoo++G8oBjUTTupxmcCgeHHJ VkxEPf6Duf+95JvkRAqem8UbYOBBsLuH60k8bhodh6LwGYRR9pA7LIsF+EgGSgjt0Nxb nU8iXvn+WoN82l4xdTg3vUQGdMfbrkIvgoqux/QZ2oUqhw21iyPE8s5LUwB2jb+5wYYh bwhffTCc8HjfFcTPaX30TaywcGRnFUkGh8luQJRheYHUQCM7r0lh5/yWzUS8UwpYtrln 0uag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=I86QE1Tk; 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 j17-20020a17090a589100b002498408b1c5si23562651pji.39.2023.04.28.08.37.43; Fri, 28 Apr 2023 08:37:55 -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=I86QE1Tk; 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 S1346557AbjD1Pfy (ORCPT + 99 others); Fri, 28 Apr 2023 11:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346361AbjD1Pfc (ORCPT ); Fri, 28 Apr 2023 11:35:32 -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 291B75584 for ; Fri, 28 Apr 2023 08:34:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682696083; 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=i1I3bxKpOJ94ZKtbze6sl4BqpXL9nzWwU/RAx5bKUL4=; b=I86QE1TkxvKun1/s4wc+il8yvi/qtSvfYjP9cmcqZ6op3SuD+hxaFeiBIi2Y4GEvYF4xKy SgKCSvl6Uf73EGKkV+ogdydNy2+NzbgYuIXyl2y/h+W2KRUuHAbyWOcKgXJsi6vrcPLNfR lyVRc2/cxpmlZXibJceTPaIr+GdnilU= 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-294-ZqREt6g5Nau0YNtIF7rH9w-1; Fri, 28 Apr 2023 11:34:40 -0400 X-MC-Unique: ZqREt6g5Nau0YNtIF7rH9w-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-3f25376e3b1so22112845e9.1 for ; Fri, 28 Apr 2023 08:34:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682696079; x=1685288079; h=content-transfer-encoding:in-reply-to:organization: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=i1I3bxKpOJ94ZKtbze6sl4BqpXL9nzWwU/RAx5bKUL4=; b=YThsUKLyeXnH3XU2911sgbNp35A9zbQJFc1PevOeQUk2AQ1qWhlZgoq0fyf1csT9Zq CUvL2v6WJoIH3XbAHtJcE1iWiUpjswxqGq7Ll8S6CAKt+EfDxPks0KduV3iDRHMgrRy9 bQXiBQ/SZSkDU7DqyJWSo/WpJhhHaghGPUq5lAHhV8ddKks3nb7QoBL8P5Ml1VG13vww Rm9ziageR6yjkPGda1rLlWuCdOEmceeaV6skSE4ZpIKlc+iemUpbM7lJDAaRASIDIkna jYwTKP6LlhfYxMFrPRVVfu+iSNk+W8DLg7jyCJAGmWJX8pm10LB9voyi/zovj85ICKiZ Dtvw== X-Gm-Message-State: AC+VfDyLQkU75p0UQEmfRyrFxpPahl+x7fdJYykpMWGBHH+VnOqMSMsb K6XKetAMDvKWzLnGZclxJ3Ojtk301NzWRbt9GX0h4tAVpleqfN2DPqKzNHMeddUJZAMpzed3RlW VobXw0wJpD8P6mLtAVU24kOsg X-Received: by 2002:a7b:c408:0:b0:3f1:643e:3872 with SMTP id k8-20020a7bc408000000b003f1643e3872mr4562572wmi.2.1682696079114; Fri, 28 Apr 2023 08:34:39 -0700 (PDT) X-Received: by 2002:a7b:c408:0:b0:3f1:643e:3872 with SMTP id k8-20020a7bc408000000b003f1643e3872mr4562508wmi.2.1682696078744; Fri, 28 Apr 2023 08:34:38 -0700 (PDT) Received: from ?IPV6:2003:cb:c726:9300:1711:356:6550:7502? (p200300cbc72693001711035665507502.dip0.t-ipconnect.de. [2003:cb:c726:9300:1711:356:6550:7502]) by smtp.gmail.com with ESMTPSA id g9-20020a05600c000900b003f0aa490336sm27987597wmc.26.2023.04.28.08.34.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Apr 2023 08:34:38 -0700 (PDT) Message-ID: <62ec50da-5f73-559c-c4b3-bde4eb215e08@redhat.com> Date: Fri, 28 Apr 2023 17:34:35 +0200 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 v5] mm/gup: disallow GUP writing to file-backed mappings by default Content-Language: en-US To: Lorenzo Stoakes Cc: Jason Gunthorpe , 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, Oleg Nesterov , John Hubbard , Jan Kara , "Kirill A . Shutemov" , Pavel Begunkov , Mika Penttila , David Howells , Christoph Hellwig References: <6b73e692c2929dc4613af711bdf92e2ec1956a66.1682638385.git.lstoakes@gmail.com> <094d2074-5b69-5d61-07f7-9f962014fa68@redhat.com> <400da248-a14e-46a4-420a-a3e075291085@redhat.com> <077c4b21-8806-455f-be98-d7052a584259@lucifer.local> From: David Hildenbrand Organization: Red Hat In-Reply-To: <077c4b21-8806-455f-be98-d7052a584259@lucifer.local> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.7 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=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 28.04.23 17:33, Lorenzo Stoakes wrote: > On Fri, Apr 28, 2023 at 05:23:29PM +0200, David Hildenbrand wrote: >>>> >>>> Security is the primary case where we have historically closed uAPI >>>> items. >>> >>> As this patch >>> >>> 1) Does not tackle GUP-fast >>> 2) Does not take care of !FOLL_LONGTERM >>> >>> I am not convinced by the security argument in regard to this patch. >>> >>> >>> If we want to sells this as a security thing, we have to block it >>> *completely* and then CC stable. >> >> Regarding GUP-fast, to fix the issue there as well, I guess we could do >> something similar as I did in gup_must_unshare(): >> >> If we're in GUP-fast (no VMA), and want to pin a !anon page writable, >> fallback to ordinary GUP. IOW, if we don't know, better be safe. > > How do we determine it's non-anon in the first place? The check is on the > VMA. We could do it by following page tables down to folio and checking > folio->mapping for PAGE_MAPPING_ANON I suppose? PageAnon(page) can be called from GUP-fast after grabbing a reference. See gup_must_unshare(). > >> >> Of course, this would prevent hugetlb/shmem from getting pinned writable >> during gup-fast. Unless we're able to whitelist them somehow in there. > > We could degrade those to non-fast assuming not FOLL_FAST_ONLY. But it'd be > a pity. -- Thanks, David / dhildenb