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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B70B5EB64DC for ; Fri, 14 Jul 2023 12:53:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235714AbjGNMxG (ORCPT ); Fri, 14 Jul 2023 08:53:06 -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: 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.