Received: by 2002:ab3:5012:0:b0:1d7:b7fe:f8b7 with SMTP id y18csp3089293ltb; Tue, 9 Aug 2022 12:25:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR7HgY3zO+FmcYwcGjivJeUP/pR7GeXzrmgsKHYKup4U8HDYVrr6wgp1q9jYrtaw7MuyQjKo X-Received: by 2002:a63:484b:0:b0:41d:9ddd:ade with SMTP id x11-20020a63484b000000b0041d9ddd0ademr6468357pgk.540.1660073126460; Tue, 09 Aug 2022 12:25:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660073126; cv=none; d=google.com; s=arc-20160816; b=za94rGy9dE0uAfitFx9XZYsbjVpJk8vgQFBUIfXH+622gRzmn2vWMG2m4WEyv65kS+ /TcjixvpWccEwzXYCQhQnxXwFmjcTZ6l7l1eRJ+Zdx6jlH85BmgVLRzl26hdBXBkOdwS 3MswsvoXpDwsnGtPYPxIF3EHXKHAAPk8Ip8g1Y8vQ8X8A0UEXYhwsnqa/jDAXjFRBnP8 lnF9jOvORQG1Z3PhU/bXcZdPUkUMuFJn4CDCWtHaos2wrkskNNIfKanG3VDjzSfNsG9w PY1ly1jDZ9i7bpkiDAjsKlwoNem4+IiPgaE5o9heYpHXdIRMCk1XjRqyWCDK2s+P3GYV 8BjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=VVV8GGpoeLc6+MwlCT0V9dvKeeRB3XD+JQNEfU5zFB4=; b=SB448e92AN8oEjwRrvEN6d14pRYtfwP2T4+R9QQfZ5wlY2FXaaG5wPI+pHcfHFBLGl 0BuZhEk8b4/aEmHKMMfr6FT7p1bGGUNc4VgnYxFfjOS2MTHfII7c7JAYhQ3eVKYtH9qT 8XJhMR10heP+PsbL23XZAvWy5aeWHhmLnXmaqieNsQJ8dPo2z91X/w7KzccNPqwljllW XVRMZleDiOMAZgOgmS7JVAEkMEulWGjZHmdzZfrI1v8wxpGEnJYlEAKWIGZu5RqpyDCt dvNCMRaiLErtew6l1drXOf+c7yUUBfUTbn9lw5diUg24m2JBw5ONT/tHZOhnfEUVJdb/ imtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=XS74q4C+; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l16-20020a635710000000b003fd2121ace3si13618531pgb.237.2022.08.09.12.25.12; Tue, 09 Aug 2022 12:25:26 -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=@linux-foundation.org header.s=google header.b=XS74q4C+; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345764AbiHITMg (ORCPT + 99 others); Tue, 9 Aug 2022 15:12:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346481AbiHITLK (ORCPT ); Tue, 9 Aug 2022 15:11:10 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CBB0330 for ; Tue, 9 Aug 2022 12:00:05 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id i14so23843398ejg.6 for ; Tue, 09 Aug 2022 12:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=VVV8GGpoeLc6+MwlCT0V9dvKeeRB3XD+JQNEfU5zFB4=; b=XS74q4C+R/RkerpK/v956xeICTISjlZPR7ZGmhz92t1i3i7F2m/3inQg+aj3m+m6dr M77s0vBeprURuoen9lVmJrVsTNMEMY6A9xIYseaKhApwnfZEJpAmNH7oRlfDEbFcQVug aYGLct1cvKUeJSKUfVfOlQcwDiMP9ep2ky3lI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=VVV8GGpoeLc6+MwlCT0V9dvKeeRB3XD+JQNEfU5zFB4=; b=dFnsXv3UhqqbSU0BPEZ4a4rjPLK+EqOITgYjDcKipXqX/LtHQlxhMyd1vWyESq84Bn 0wopLIFKmJT0OLlX8I03XtAPBIP/N46AoB8gdh6E4DpSp2n/Y8YqOVmbOfZZr6TBsMXv MuCNiQ9cJlhJrDs+lKCJsswfbKBQICaKX9leiCmNs1suhs0jC+Sj69wWT+NsPB0S4i6V q8eWMAifiZ+gz1c7GJikCOeWHOee+6rvs5+DBi4bqIhAH1/+CfLgj8xnEJfJNjIEo/lP feubxZ0ffsXTkGXWGKrhH8oJb2NBXddykWauniTo+eE7svcRKcQFBvv7oPg+fM56Sovk ALhw== X-Gm-Message-State: ACgBeo1i+XODS2WZw/Jd9WW3aMN07lwxf6BgfAanUZ5uiAgj2xwfgF/y B0yMIGNC/eeX5pRnMq4WLP41hZvLUvto32d2oW8= X-Received: by 2002:a17:907:2722:b0:731:2aeb:7942 with SMTP id d2-20020a170907272200b007312aeb7942mr10941951ejl.734.1660071603637; Tue, 09 Aug 2022 12:00:03 -0700 (PDT) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com. [209.85.221.41]) by smtp.gmail.com with ESMTPSA id f26-20020a170906139a00b0072b55713daesm1433477ejc.56.2022.08.09.12.00.02 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Aug 2022 12:00:02 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id z12so15301491wrs.9 for ; Tue, 09 Aug 2022 12:00:02 -0700 (PDT) X-Received: by 2002:a5d:56cf:0:b0:21e:ce64:afe7 with SMTP id m15-20020a5d56cf000000b0021ece64afe7mr14879214wrw.281.1660071601819; Tue, 09 Aug 2022 12:00:01 -0700 (PDT) MIME-Version: 1.0 References: <20220808073232.8808-1-david@redhat.com> <1a48d71d-41ee-bf39-80d2-0102f4fe9ccb@redhat.com> In-Reply-To: <1a48d71d-41ee-bf39-80d2-0102f4fe9ccb@redhat.com> From: Linus Torvalds Date: Tue, 9 Aug 2022 11:59:45 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1] mm/gup: fix FOLL_FORCE COW security issue and remove FOLL_COW To: David Hildenbrand 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 Tue, Aug 9, 2022 at 11:45 AM David Hildenbrand wrote: > > I totally agree with BUG_ON ... but if I get talked to in all-caps on a > Thursday evening and feel like I just touched the forbidden fruit, I > have to ask for details about VM_BUG_ON nowadays. > > VM_BUG_ON is only active with CONFIG_DEBUG_VM. ... which indicated some > kind of debugging at least to me. I *know* that Fedora enables it and I > *know* that this will make Fedora crash. No. VM_BUG_ON() has the exact same semantics as BUG_ON. It is literally no different, the only difference is "we can make the code smaller because these are less important". The only possible case where BUG_ON can validly be used is "I have some fundamental data corruption and cannot possibly return an error". This kind of "I don't think this can happen" is _never_ an excuse for it. Honestly, 99% of our existing BUG_ON() ones are completely bogus, and left-over debug code that wasn't removed because they never triggered. I've several times considered just using a coccinelle script to remove every single BUG_ON() (and VM_BUG_ON()) as simply bogus. Because they are pure noise. I just tried to find a valid BUG_ON() that would make me go "yeah, that's actually worth it", and couldn't really find one. Yeah, there are several ones in the scheduler that make me go "ok, if that triggers, the machine is dead anyway", so in that sense there are certainly BUG_ON()s that don't _hurt_. But as a very good approximation, the rule is "absolutely no new BUG_ON() calls _ever_". Because I really cannot see a single case where "proper error handling and WARN_ON_ONCE()" isn't the right thing. Now, that said, there is one very valid sub-form of BUG_ON(): BUILD_BUG_ON() is absolutely 100% fine. Linus