Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2443277rwp; Fri, 14 Jul 2023 06:21:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlHanLNCDFUsn2YZVa5/rDNAF6esMYXZVErPrLfePUOobCNhErl1c/qXPFEGDVE9pMkfP6Mo X-Received: by 2002:a05:6830:20c1:b0:6b9:9cc0:4854 with SMTP id z1-20020a05683020c100b006b99cc04854mr5229682otq.32.1689340918093; Fri, 14 Jul 2023 06:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689340918; cv=none; d=google.com; s=arc-20160816; b=nr+A9Czbb73Zbhv50VfSw2lXX1nKPX7dCIQw/SYXAnqhlMOJPeQdELDP/uzTLofKW+ 7ClcPqVAbMOESFZ2uvSC4a5P+rLgNnjgVKuP3kC5jmmtMMe0itjawbMQz21OBGaW3okD x6MRr3M2M740ODtIsOc9LJEZKXhe5EJ0FoS5Th4qwHINHA561MnfKkT/tDlMmq6zaykm SS6UfEp5liRLzG/mVHElJ7t0eIBBdRwUOx3iCg9r0UDBuJKUex0rzj7WaEcdeK1mlycg zjeykhFll4ZKym5QIdYhd57RVjKXkBNWAJXorw0I+/0mBRgT/wFdglKoEG5qW275esDk p1vQ== 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=E/uvTGpdsO84eiBOXbT08FQEwaKw+LLHao9zm8yjSI4=; fh=x5aRjXGc+w2IUDAK6QWkcuMpz8Jhrlr6XXAT+14mD1o=; b=nlk6MU/u0jSoUUwWNMZJfjK3Sqwmb3B3hoyim6rGSrfBigVzg+qCX8s8GJYjfCnnxd ebKm604FoNiyVeMWqBoXb8Pb+WtB3Ovqyl2TNt086fkUWrlh4r55SuXUQmIv/9Uby581 phaREhRv5xjEXLfhTLqphpaBcGyvYxV/Bvq66K8GPQs1tGyFUX439Y/63zqqsXkxaCvg Uh2cjZ0kAOj1VPeMv991ASMovtxUbxjzRZujDWIrT1FRDVNAgn83bvMgQppVtN3UwNf5 /UpsY8VgFSXMDwfOin/ktdQdEhnKB9mkf0GzkndPqHUGxSX8ubqxIZCfiNPDv+h6L6pO yI6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=FP8ruYQi; 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 v191-20020a6389c8000000b0055e607f1e9asi1343605pgd.254.2023.07.14.06.21.46; Fri, 14 Jul 2023 06:21:58 -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=@infradead.org header.s=casper.20170209 header.b=FP8ruYQi; 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 S235665AbjGNMxF (ORCPT + 99 others); Fri, 14 Jul 2023 08:53:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235854AbjGNMxD (ORCPT ); Fri, 14 Jul 2023 08:53:03 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C081A1734 for ; Fri, 14 Jul 2023 05:53:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=E/uvTGpdsO84eiBOXbT08FQEwaKw+LLHao9zm8yjSI4=; b=FP8ruYQiZTFFixHtvuSZCr1ita rJQGcgxW8kFtC8roPSOdSCvH8bEYqEFlpn/XITGepsrsk6ZA1tFBQUXfpAGXr6CEA5rfBb7Z7HR5b PB7zD4r0mmk+R/jllJhh724eFKrz7kMu82qNzjLSMgqTNbxrpRfBCM76EjJrRUf1t3qN+9V7fLE+4 g+qq3/QVKQa5V792KuCl+vfx5AQlBVPDI6KaNutoEKeG9UOIiexyXlvofL35xGncDqz4E4EK4rr0e HL6815YJaDVt3hkTen0eFGsrGj61X8oI/1ZIv0/LkccCAdmJiTzFKzOfsXGVksvAPAQwFzTOhuLhb 3AllT3NA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qKIHo-0013fW-LQ; Fri, 14 Jul 2023 12:52:40 +0000 Date: Fri, 14 Jul 2023 13:52:40 +0100 From: Matthew Wilcox To: linke li Cc: David Hildenbrand , Linke Li , linux-mm@kvack.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, trix@redhat.com, ndesaulniers@google.com, nathan@kernel.org, muchun.song@linux.dev, mike.kravetz@oracle.com Subject: Re: [PATCH] hugetlbfs: Fix integer overflow check in hugetlbfs_file_mmap() Message-ID: References: <65f4c60a-9534-56dc-099f-ee7a96e0ccaf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Thu, Jul 13, 2023 at 03:55:55PM +0800, linke li wrote: > > So we're adding code to handle eventual future compiler bugs? That sounds > > wrong, but maybe I misunderstood the problem you are trying to solve? > > Sorry for not making it clear. My focus is the presence of undefined > behavior in kernel code. > Compilers can generate any code for undefined behavior and compiler > developers will not > take this as compiler bugs. In my option, kernel should not have > undefined behavior. The point that several people have tried to make to you is that *this is not undefined behaviour*. The kernel is compiled with -fno-strict-overflow which causes the compiler to define signed arithmetic overflow to behave as twos-complement. Check the gcc documentation.