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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 922D5C433E0 for ; Fri, 8 Jan 2021 18:39:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6278423A7D for ; Fri, 8 Jan 2021 18:39:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728799AbhAHSjJ (ORCPT ); Fri, 8 Jan 2021 13:39:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727919AbhAHSjJ (ORCPT ); Fri, 8 Jan 2021 13:39:09 -0500 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA91CC061380 for ; Fri, 8 Jan 2021 10:38:28 -0800 (PST) Received: by mail-lf1-x12d.google.com with SMTP id s26so25176738lfc.8 for ; Fri, 08 Jan 2021 10:38:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ICXv7r9tS6OnWdFplsRRr1nw62sR7HCP2UfTw3I7zBA=; b=dj/GGvKX+wRhXGlTXy+NoQVbe9htPaa32IMewc/zw2qddtEmoc+ptGXxaxA4nADn10 4958RF03MOEVqneSyMQcauJTehztktCIWwuw2XG26sQYjPOVT0Y14YmuED9xIx3vvIty FFlQQqbhp2rFxeTzU14Rb155846i72ENdlln4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ICXv7r9tS6OnWdFplsRRr1nw62sR7HCP2UfTw3I7zBA=; b=SLhDmizzz2J/WErUZFrfaAaeFsoyhvX7VG9CvQwnGfoRmAHPSI5us/CSpc7WdTdCTB jDg8cPExBj06Wiek9Zci/jhCPxy4OPhzMd6AIp/YHI8lXUk81OfuVOatv44NDmR0JtrM BNMt7Q8d5iQSwNOW36mbQjjQ5/VBetP1732B0nIQuwQIRNer0r9NVaDfOzJGHkoL8+P2 ToB/1MUAn6cyBr166IMyawIgBRWN206Ct23rFA8MpUWZBGXB8nPeLrBZS8CaNx6bgYcT Spwq7/fQNu+Eqrv5jr0fpFvGdSey7khKGrBOnfYvfSePaviWmU6QLaPfmCA+hOqWsRnb Nwaw== X-Gm-Message-State: AOAM532MF0bSeguqz+7yX9g4pnQEyfiVIqCB3W4DGGau9fv/eBcUUw0S GGJhiVGCCB3mfVq5SC+VotVW7mYH7mVrVA== X-Google-Smtp-Source: ABdhPJynchDVRBJ2MGXha1sjPqk+OsiyaF0ZQe1GJuzs+hJjmHTVPfgFKvEwi/BU5Pf0eMLfKbKEqQ== X-Received: by 2002:a05:651c:211d:: with SMTP id a29mr2117228ljq.487.1610131107236; Fri, 08 Jan 2021 10:38:27 -0800 (PST) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id k8sm2106959lfk.187.2021.01.08.10.38.26 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Jan 2021 10:38:26 -0800 (PST) Received: by mail-lf1-f51.google.com with SMTP id m25so25100345lfc.11 for ; Fri, 08 Jan 2021 10:38:26 -0800 (PST) X-Received: by 2002:a05:6512:338f:: with SMTP id h15mr2009336lfg.40.1610131106007; Fri, 08 Jan 2021 10:38:26 -0800 (PST) MIME-Version: 1.0 References: <20210107200402.31095-1-aarcange@redhat.com> <20210107202525.GD504133@ziepe.ca> <20210108133649.GE504133@ziepe.ca> <20210108181945.GF504133@ziepe.ca> In-Reply-To: From: Linus Torvalds Date: Fri, 8 Jan 2021 10:38:09 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 0/2] page_count can't be used to decide when wp_page_copy To: Andy Lutomirski Cc: Jason Gunthorpe , Andrea Arcangeli , Linux-MM , LKML , Yu Zhao , Peter Xu , Pavel Emelyanov , Mike Kravetz , Mike Rapoport , Minchan Kim , Will Deacon , Peter Zijlstra , Hugh Dickins , "Kirill A. Shutemov" , Matthew Wilcox , Oleg Nesterov , Jann Horn , Kees Cook , John Hubbard , Leon Romanovsky , Jan Kara , Kirill Tkhai Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 8, 2021 at 10:31 AM Andy Lutomirski wrote: > > Can we just remove vmsplice() support? We could make it do a normal > copy, thereby getting rid of a fair amount of nastiness and potential > attacks. Even ignoring issues relating to the length of time that the > vmsplice reference is alive, we also have whatever problems could be > caused by a malicious or misguided user vmsplice()ing some memory and > then modifying it. Well, that "misguided user" is kind of the point, originally. That's what zero-copying is all about. But we could certainly remove it in favor of copying, because zero-copy has seldom really been a huge advantage in practice outside of benchmarks. That said, I continue to not buy into Andrea's argument that page_count() is wrong. Instead, the argument is: (1) COW can never happen "too much": the definition of a private mapping is that you have your own copy of the data. (2) the one counter case I feel is valid is page pinning when used for a special "pseudo-shared memory" thing and that's basically what FOLL_GUP does. So _regardless_ of any vmsplice issues, I actually think that those two basic rules should be our guiding principle. And the corollary to (2) is that COW must absolutely NEVER re-use too little. And that _was_ the bug with vmsplice, in that it allowed re-use that it shouldn't have. Linus