Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2333688rwr; Fri, 28 Apr 2023 09:01:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7TY/rn/TMW2gansFf5rRi/pPUFChVb/PwlEwNiDbcg5DOknzSA7xHcZ05O9b01pfCABAMD X-Received: by 2002:a05:6a20:7f82:b0:f5:c6e5:e65 with SMTP id d2-20020a056a207f8200b000f5c6e50e65mr6958093pzj.7.1682697714498; Fri, 28 Apr 2023 09:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682697714; cv=none; d=google.com; s=arc-20160816; b=nHTsBL00pShnKfXoM1cvzjbJyAFolY6XhSEqeHOOlqWMLu45qBX3yQ/fCgEgjho3h7 lvytbVjR2ULbjhDuPX/c3PYf6V+0Bnm52vxeo9nT3Yk2Bh64cVl+e2Yt/JGvhQN+8uaQ /5Ym6h2EPSMl7MgyEpBFXE+DGAsRgVXq/Q2rtdxOEC7bfK6SASAzJaOLyAkN66Q2Scxr 1HKs30rUeECVnF8c47kMpaL0zuaIA+dex4GkvZi//YRgYMnYTqzMfCavsr1/gMwTr0v2 EMAWD0Bpb5v8183xyW+fuiPbOa03Vg2jvAe5pJwmyMPbf51ldfweO9ujqfcHAWyfytrP aGTQ== 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=zf2i3kVXtlVgFFMbGoUpKI0IDlebsU5o6nl1WehrK4Y=; b=aqYr3NjWKt7lIydSRnEyinfOWYEE+pROGVSbYcYILKhL5MOpnOR2gd4MNl8QFJDsQO SKqyC7l04vSVxC5Ol3Nww5ET7GzL5wejEByJxlnwlGOTDyusOHoiysAy49r6MIO4Jzxh V4rRQOixKRPPLp/D4Szivu6uxPN+H47LhAS4TkR8F2JHRfCKRcOVl5VjTKXgyUsymIpE Y+KGE0TdtpSMxazRn/0HFHnXJE65HaqUXTHcp4R9AxDGI1nhML3OicqdT/QKGIi9928q wsEFQhNAKDQ+NXouopNN0ZOR2SFv0DVeHFN478E8LRZAabp1emiecpVYt4A3eUEwIDIq ejKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=h32YuTJq; 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 i16-20020a63e910000000b004fb1da0e663si21842597pgh.131.2023.04.28.09.01.24; Fri, 28 Apr 2023 09:01:54 -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=h32YuTJq; 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 S1346064AbjD1P5v (ORCPT + 99 others); Fri, 28 Apr 2023 11:57:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345959AbjD1P5t (ORCPT ); Fri, 28 Apr 2023 11:57:49 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99B4912B for ; Fri, 28 Apr 2023 08:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682697421; 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: in-reply-to:in-reply-to:references:references; bh=zf2i3kVXtlVgFFMbGoUpKI0IDlebsU5o6nl1WehrK4Y=; b=h32YuTJq+OIrsGfGVeGhxbwvHegoLRjuEmXy0P9dk7UMlKWyGJTDwx8szFEz6xMN5ZwqeD r4s5hmUcsta08eAusAiXN+UWFCKJGsYXkFvjSb/u90EYIIPBRMSKTKWXkJDCi2gQYX/rZL TMF7TVwS6hXJO99fFO7SRimWoU16/Kw= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-137-5BTc1JejMa-bMEH44NqIRg-1; Fri, 28 Apr 2023 11:57:00 -0400 X-MC-Unique: 5BTc1JejMa-bMEH44NqIRg-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-7514dd96de3so1780685a.1 for ; Fri, 28 Apr 2023 08:57:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682697420; x=1685289420; 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=zf2i3kVXtlVgFFMbGoUpKI0IDlebsU5o6nl1WehrK4Y=; b=SSJSQaJyW14KN3lsHSeX+fEDhA9Yz8zZw0xq6rTbJD+zppJBmrHElkAVHdUkI1UL1V 7dMQa2OBp5yNZPNdDrdYxWfrNym7MNfcfLI3CykMFhQsIolZM8um/eIZ1qhOJygOdwqR whd3As89iCuz60WJ+3MbhbHYrfffJ16y5nGfb9w+Cb3OL3PuZ9vOafmRPWwCMbseS2bE +RFqyzgKj/dsO+iFE5TKfHE7q1iyMVI0Ohj9D3VLuMmTNIusCmbLpciePKusbShL/N8P UGqDhE7PD975AwlA3vdHiEGrC6F+8VqkWpTSRTnjaQ8DIYkiPEICqs8NXxsfFfp43EUy eYCA== X-Gm-Message-State: AC+VfDx5TrwTDaH8WRIxzmgF5uwK6s5Ps1ujJvlc0Nzg/fIyybJltP4/ MGxRqDlRwAD1fQc+urBrYLh/GfKwHEN2oMHUgk9vNWZ2gaavJIuDlzliGqJk4zuKFvKnLm1zGMz ZowO+lClEa+9pWGNZkwzuav0o X-Received: by 2002:a05:622a:1047:b0:3f0:a887:7d2c with SMTP id f7-20020a05622a104700b003f0a8877d2cmr5184835qte.6.1682697419805; Fri, 28 Apr 2023 08:56:59 -0700 (PDT) X-Received: by 2002:a05:622a:1047:b0:3f0:a887:7d2c with SMTP id f7-20020a05622a104700b003f0a8877d2cmr5184790qte.6.1682697419513; Fri, 28 Apr 2023 08:56:59 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id o16-20020ac872d0000000b003ef5ba0702fsm6392726qtp.7.2023.04.28.08.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 08:56:58 -0700 (PDT) Date: Fri, 28 Apr 2023 11:56:55 -0400 From: Peter Xu To: David Hildenbrand Cc: Lorenzo Stoakes , 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 Subject: Re: [PATCH v5] mm/gup: disallow GUP writing to file-backed mappings by default Message-ID: 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> <62ec50da-5f73-559c-c4b3-bde4eb215e08@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <62ec50da-5f73-559c-c4b3-bde4eb215e08@redhat.com> X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Fri, Apr 28, 2023 at 05:34:35PM +0200, David Hildenbrand wrote: > 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(). Hmm.. Is it a good idea at all to sacrifise all "!anon" fast-gups for this? People will silently got degrade even on legal pins on shmem/hugetlb, I think, which seems to be still a very major use case. -- Peter Xu