Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36731882rwd; Tue, 11 Jul 2023 05:09:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlFcfHUtj7CLWCisrJkAOspNTh2umTq3tl2czbx89N8zHACfMz05XDl6D+8vi1tacRwRb7eZ X-Received: by 2002:a05:6402:506:b0:51e:26c8:25f7 with SMTP id m6-20020a056402050600b0051e26c825f7mr14319707edv.42.1689077391265; Tue, 11 Jul 2023 05:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689077391; cv=none; d=google.com; s=arc-20160816; b=Zwjyg6RJBkA8mBvAiyM1LQEFTSsWJDy3EDoU49uJJrTc5gnRQzzQE783C9yNA8CHHW 3Ofw28wm35mcRPj3ExEtPRRGGwGy4Iiihwb/54HLGtO47vmyaNpPCq3X377YGEIMeyHY 8g/89A51ePsjnGA+Kx5+xm2bI64HxubPtWSlV00jHJgHtiFwUU5sNOR8n3mJ2p6XQYm3 eGYplDWJCI7V+l+JnvqDWMITUOR3qv9s3BQEAJVkHy007XIFV/IeMJq0WK8qBtwRrA9m L75x8kxAeuRvSJp6O5mkMZDxpDXpVpH+HMof1TCJBDq7k35TzWaKGZ536j0dIkPeCE6k rFhA== 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=ox1ybSLl45XwKkwvaJMisJ5/+NEAsrD7J+jcJG30/JQ=; fh=ooqxuee67hxr95VEg9wswie5B5oAj7CG3uso8DUhGCI=; b=jC2SXWg0bm+97/LD7dwElh6XljRLd6+6T6yNUzZM1Ix/3HJ8KtAi/Z1Svmu6Cnjtw6 xoDbyhaNTgj6tXIcer8ki1gDwNDf+Ay0nN79DtYSocam3k1qWJk6t08wXi+0IpPSCKCJ i1Nc2d6ly2XBt42/DCWTOf7dZchO10LzDxl4ndKzFDhPnC8rdvArNCI53u3hK1SLRc3u H3qWXkbl2Ecf01uLNhcwh1aXV0az5W4eQ2vqSIRmf51f08LcBJfyub2JLbwI7d6J4XiC xUYVB+eB0qcfOi/6QSl89zM52fRsFm1X50J1xnxtlKLPh/unN7zbThhiImyvr9jY3Kmf h8Eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AQaBdNI6; 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 d4-20020aa7d5c4000000b0051ddf359991si1972344eds.344.2023.07.11.05.09.04; Tue, 11 Jul 2023 05:09:51 -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=AQaBdNI6; 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 S231180AbjGKLt5 (ORCPT + 99 others); Tue, 11 Jul 2023 07:49:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230431AbjGKLt5 (ORCPT ); Tue, 11 Jul 2023 07:49:57 -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 ESMTPS id 0B1A2E4B for ; Tue, 11 Jul 2023 04:49:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689076151; 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=ox1ybSLl45XwKkwvaJMisJ5/+NEAsrD7J+jcJG30/JQ=; b=AQaBdNI6PnPj0Gb0TGw5XmSsQZ4M/ID3LOZVmDGa12hvKpyfgSIs51McaD71LQB05edois Of8nzbn9QgP7pB8bXXJ6kv8QIJomxtatR4/o2YjoW0JMZ9uIkOWsPTFwfd+MFW1wW9ttzS d0i9u8Kk4DRtM4Wi4pkTBeR2tZWtlzc= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-48-1i8beNSXMwetrV65OqujKA-1; Tue, 11 Jul 2023 07:49:09 -0400 X-MC-Unique: 1i8beNSXMwetrV65OqujKA-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-3143c9a3519so3923768f8f.2 for ; Tue, 11 Jul 2023 04:49:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689076148; x=1691668148; 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:subject:date:message-id :reply-to; bh=ox1ybSLl45XwKkwvaJMisJ5/+NEAsrD7J+jcJG30/JQ=; b=JgA32WB4aZtdkbMflLUrXSUfQ4kApb7k4t3weK0079S600uW8czvfJYvlMGvzcDLnO VIwxT4VWG0mP5U8yqBVt5B40UmzYf8xPaVl5/L4ZbQYoyZq7sn1uOWtx1Mei/SuJC93f dbC5YeLgnzibatBLpVUFCXg6uRT8WDX9+R1LaMyykImGBx+rw3OEOi1IgjgHfcnHIoiH AMoq6wPWI7Ah/XujFzqko/uT6ILFRu5vu31HQo1DRPAqi9uKD5Ar6YOpIE7MlZcbT/yW 41q4XPRhfhpWoMmsXVdwdKINTRRYBezc6g5VAAaQ6cwn2cZtV5BTSaqmYMzBJbiQ7hm6 povg== X-Gm-Message-State: ABy/qLaY35wMH0lBYVS59JSBgV6YEXb39Zd8dfTAhbWknL10ESH048y5 e9JqaN5Blqe3nfpSmREzCOopdEU+JLJ6Lcz17uCwGekrGhHhZsKPi98dbUJt7Yr6vZLMSTboQkD KMWmHV91dTC4NmwzLgY1F7S9J X-Received: by 2002:adf:f9c9:0:b0:314:2132:a277 with SMTP id w9-20020adff9c9000000b003142132a277mr17501680wrr.9.1689076148759; Tue, 11 Jul 2023 04:49:08 -0700 (PDT) X-Received: by 2002:adf:f9c9:0:b0:314:2132:a277 with SMTP id w9-20020adff9c9000000b003142132a277mr17501654wrr.9.1689076148389; Tue, 11 Jul 2023 04:49:08 -0700 (PDT) Received: from ?IPV6:2003:cb:c745:4000:13ad:ed64:37e6:115d? (p200300cbc745400013aded6437e6115d.dip0.t-ipconnect.de. [2003:cb:c745:4000:13ad:ed64:37e6:115d]) by smtp.gmail.com with ESMTPSA id b7-20020a05600c11c700b003fc015ae1e1sm2386296wmi.3.2023.07.11.04.49.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Jul 2023 04:49:07 -0700 (PDT) Message-ID: <65f4c60a-9534-56dc-099f-ee7a96e0ccaf@redhat.com> Date: Tue, 11 Jul 2023 13:49:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] hugetlbfs: Fix integer overflow check in hugetlbfs_file_mmap() Content-Language: en-US To: Linke Li , linux-mm@kvack.org Cc: 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, Linke Li References: From: David Hildenbrand Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 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,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 10.07.23 10:32, Linke Li wrote: > From: Linke Li > > vma_len = (loff_t)(vma->vm_end - vma->vm_start); > len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT); > /* check for overflow */ > if (len < vma_len) > return -EINVAL; > > The existing code includes an integer overflow check, which indicates > that the variable len has the potential to overflow, leading to undefined > behavior according to the C standard. However, both GCC and Clang > compilers may eliminate this overflow check based on the assumption > that there will be no undefined behavior. Although the Linux kernel > disables these optimizations by using the -fno-strict-overflow option, > there is still a risk if the compilers make mistakes in the future. 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? -- Cheers, David / dhildenb