Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6374167rwb; Tue, 9 Aug 2022 14:13:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR4s9kkDjoSKYzPgt0l95W85Geu5o8hrdS5qsLbpZfkSp/JsseKxQ5xxfiSFMN+zcUk4cUuQ X-Received: by 2002:a17:90a:1190:b0:1f2:69d:40c9 with SMTP id e16-20020a17090a119000b001f2069d40c9mr373524pja.188.1660079635221; Tue, 09 Aug 2022 14:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660079635; cv=none; d=google.com; s=arc-20160816; b=we+W2oiJ5DkUbw8NLqasmV0BhuX6zk8+Pv9w2e7Hc72mo1UK6/3ujqKrFpmwsgVwh+ b47BZO0dpGCwcd+tEXom1ZI3Slxlh8Spx4+CQtzFk5FtQXqGpmawVm5uZh1JQJ29FD+u 2RXSoGinWJ+96DIGJnGIELmTY9XDsFmdOq+ehtBpS6CYLOVdIKZJmjLcGygCErzOsmkI WiJGCV1f+al/9KrBUlIFvrfkA3Ih+mP4WsvtwjA6Xit1vYYUwOyn+xNFgxKLRMdaB6YZ vtUvzUZHboMuXqWYSKzEmB+61x9NfArmujtMkF35kQEylr3O6DB3AbJYssO9FEdyyekZ Zhqw== 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=Ft7/3/k2/7AI7wRPnrTn6/PiafTIMMMl8iv+c+g4UYE=; b=VzeFOOroiHKQU0HVdogUAr5dCagfBaK3zDiTAbxkYRlJ6sSAVgDNhEdQOgFYdu3rli NZpNNnAzpTp2jwZazZmeX5KeXjUPclwYsrBd638ThPNPZJkV6h24r9KpqRZ7gefHxOTr 9bteKFJyz2I0Bm7DG+shhPnz2gVkDkT2kfQwhiW+ZWcJGvBancM7zr6dWuI6V8u2tQ4L m5P4BgqXmDcOJgJ5youzDnN3icbFPVCUGz0jktWzR+nuAZSEP68tOKP+oKhEOIJbVTew c4lHehG7RTdOx1C9YB4cbibj5rPke/R/0pJNlQnguTGrg4xChNZkbJL+/1gbMm9QDCSh XDwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gAIeBLHo; 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 y10-20020a63de4a000000b0041c86b0597dsi13595653pgi.594.2022.08.09.14.13.40; Tue, 09 Aug 2022 14:13: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=gAIeBLHo; 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 S245622AbiHIUmS (ORCPT + 99 others); Tue, 9 Aug 2022 16:42:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244516AbiHIUmN (ORCPT ); Tue, 9 Aug 2022 16:42:13 -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 ESMTP id CA3B420192 for ; Tue, 9 Aug 2022 13:42:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660077730; 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=Ft7/3/k2/7AI7wRPnrTn6/PiafTIMMMl8iv+c+g4UYE=; b=gAIeBLHopoPAWsO/TMPH7rNNJTXLoFoBmA2eqwTR5uz3HN/KkmkK2gMnYJsvU90Zw+U2LD Qb0WaVcMDtUde6Zr5V6YJw6LikuuObKS2ujdSyRqk/BlfTvXUI/PqS+WuUwn8RUyg8AKGi vKk3EyLEgyXkaHYYQkynMaIsw0I9nzc= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-7npksSygOCeKrCu2WPWYRw-1; Tue, 09 Aug 2022 16:42:09 -0400 X-MC-Unique: 7npksSygOCeKrCu2WPWYRw-1 Received: by mail-wr1-f70.google.com with SMTP id j20-20020adfb314000000b00220d9957623so2015568wrd.0 for ; Tue, 09 Aug 2022 13:42:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=Ft7/3/k2/7AI7wRPnrTn6/PiafTIMMMl8iv+c+g4UYE=; b=Is4q3c2l6uAUDTS16V/6H71H06UQ4eh4mxxWEDEa5/u58SPF8JmHJR/OeAgn8sMk9W uLsoPAacVrDt5PqghIkKsPupl36m/guV+fCXiG15uRMtagG5gXEYgEODT/oMOPbvDsH7 7STQbx+afS4d79Uzn15Weqhquu2MF4H3cJ0kADeWgCrhnTi4GfFYahyq9fyC5zkRKSlk RgowHz3HV7snV2OEyamPSPHWumi0xfiOX2Ju1rwE6O44eWYQswO49sPCczD/ApnOTvvz 8/YGw/uger+tY/paXu2CEkGNnrw6bHMSRlJ2FYwJpqf9VHcont85XH8zghBO/bj2bxt3 567A== X-Gm-Message-State: ACgBeo1qhCnVE8VlsFRy/YOEJ++aO1FV0X+oWPNAtk6FhR31r1H7QJEY Ovp1UrU7gnbUACH+WCggx+/3mh2LM2vdgZngvW7F3g81SdYsruTYJ5G0Sw90HfnAcLCEbLn0Biz 2dnk85RqpnJ6j2pywaP48Cpm1 X-Received: by 2002:a05:6000:1f0e:b0:221:6d6f:5c7e with SMTP id bv14-20020a0560001f0e00b002216d6f5c7emr13477458wrb.256.1660077727993; Tue, 09 Aug 2022 13:42:07 -0700 (PDT) X-Received: by 2002:a05:6000:1f0e:b0:221:6d6f:5c7e with SMTP id bv14-20020a0560001f0e00b002216d6f5c7emr13477446wrb.256.1660077727693; Tue, 09 Aug 2022 13:42:07 -0700 (PDT) Received: from ?IPV6:2003:cb:c705:3700:aed2:a0f8:c270:7f30? (p200300cbc7053700aed2a0f8c2707f30.dip0.t-ipconnect.de. [2003:cb:c705:3700:aed2:a0f8:c270:7f30]) by smtp.gmail.com with ESMTPSA id r27-20020adfa15b000000b0021d70a871cbsm14650710wrr.32.2022.08.09.13.42.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Aug 2022 13:42:07 -0700 (PDT) Message-ID: <13f149cc-6535-8b50-04de-70437a679826@redhat.com> Date: Tue, 9 Aug 2022 22:42:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v1] mm/gup: fix FOLL_FORCE COW security issue and remove FOLL_COW Content-Language: en-US To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, stable@vger.kernel.org, Andrew Morton , Greg Kroah-Hartman , Axel Rasmussen , Peter Xu , Hugh Dickins , Andrea Arcangeli , Matthew Wilcox , Vlastimil Babka , John Hubbard , Jason Gunthorpe References: <20220808073232.8808-1-david@redhat.com> <91e18a2f-c93d-00b8-7c1b-6d8493c3b2d5@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.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,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 09.08.22 22:30, Linus Torvalds wrote: > On Tue, Aug 9, 2022 at 1:20 PM David Hildenbrand wrote: >> >> IIUC VM_MAYSHARE is always set in a MAP_SHARED mapping, but for file >> mappings we only set VM_SHARED if the file allows for writes > > Heh. > > This is a horrific hack, and probably should go away. > > Yeah, we have that > > if (!(file->f_mode & FMODE_WRITE)) > vm_flags &= ~(VM_MAYWRITE | VM_SHARED); > > > but I think that's _entirely_ historical. > > Long long ago, in a galaxy far away, we didn't handle shared mmap() > very well. In fact, we used to not handle it at all. > > But nntpd would use write() to update the spool file, adn them read it > through a shared mmap. > > And since our mmap() *was* coherent with people doing write() system > calls, but didn't handle actual dirty shared mmap, what Linux used to > do was to just say "Oh, you want a read-only shared file mmap? I can > do that - I'll just downgrade it to a read-only _private_ mapping, and > it actually ends up with the same semantics". > > And here we are, 30 years later, and it still does that, but it leaves > the VM_MAYSHARE flag so that /proc//maps can show that it's a > shared mapping. I was suspecting that this code is full of legacy :) What would make sense to me is to just have VM_SHARED and make it correspond to MAP_SHARED, that would at least confuse me less. Once I have some spare cycles I'll see how easy that might be to achieve. -- Thanks, David / dhildenb