Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9136499rwp; Wed, 19 Jul 2023 23:29:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlHcEhN3Yzc5eq+p7LSUzkBolBl7LocU1GHzfzbnw2efN2VTFXXqbS+OFOdVRLQ29hrodeTH X-Received: by 2002:a17:906:6a03:b0:994:34a2:8727 with SMTP id qw3-20020a1709066a0300b0099434a28727mr5652851ejc.41.1689834571022; Wed, 19 Jul 2023 23:29:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689834571; cv=none; d=google.com; s=arc-20160816; b=d01dM1hXp7IG8RcjbUl3hEKkKRA3v3STkyFr9E8jdELgMAG6Kx9NxCNVC6T6U+R0J0 azNEgsbZDFiICot2UOV2b4cvuW3zcPZy4TP81QLo610PHHj3osOlVnzWbJmgYfzOT0b0 nluHz4PbGEp1gQQqthtbnnTS6AmSeZDoGJ29gL2eVEXKZbTTeP4JDKd3kxaZjNbRz3hp UJixoMi6Ae3RWQ8F8C1l9djp8Nh20or418Q4J3BQQ4j+ZFRvEHAVDr+iKAmZ1mULcl57 2ink3h/Xz/RxKVSPHFf4tNc5kCC4Blr6Guayw+LJvf+Efzj3Aecb75Zyb5bEVoTPS7xp NuHA== 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:sender :in-reply-to:references:mime-version:dkim-signature; bh=JNL4l5GRlHwxV4ntRBz/satLVd2URGo3WiWHTSW6eE4=; fh=f938WDlTHMScCfGnxjcp1d5K8hCrj1tAF4x8WSEaGws=; b=UWBJhendG9DpK56R94DGKIzEHzScKItkqIWlH7+j3GDvoRnwQW31wchDYWU5ELAKee 8KEgYwaH8dLhDppcSC1ga7pkWmJ0ysbLoYAogLbKkzI41QQxYA5RedV1m1alrqcwA2Jl 9C3KzikTcwHJ836AxmcoyIpCn7DearpPEmU/wIP/dR3AUBD+DV9usnFiLcVIf9qcta+l J1WOyThiWkPNOX7a7DhcBu8C4h5MywHWBBTKp7V47sK3Bib5Pb6oHgjBip6IVuWRBDKF wsIinVOKzwA0Vrgs9aUITQjD2+gLPyQiAVT6VKW+Mxb3+MK5TC+NYaB9DLD87PQZGCwC HUZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=QSIEs6AV; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q24-20020a170906b29800b00992083e604fsi251696ejz.154.2023.07.19.23.29.05; Wed, 19 Jul 2023 23:29:31 -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=@gmail.com header.s=20221208 header.b=QSIEs6AV; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229729AbjGTGZT (ORCPT + 99 others); Thu, 20 Jul 2023 02:25:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbjGTGZS (ORCPT ); Thu, 20 Jul 2023 02:25:18 -0400 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B437128 for ; Wed, 19 Jul 2023 23:25:17 -0700 (PDT) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-51de9c2bc77so493546a12.3 for ; Wed, 19 Jul 2023 23:25:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689834316; x=1690439116; h=cc:to:subject:message-id:date:from:sender:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JNL4l5GRlHwxV4ntRBz/satLVd2URGo3WiWHTSW6eE4=; b=QSIEs6AVNYFv9z7/VkvFN6axf4NcXNTrxvEwfbAuZA0WcfDW38zoK9JiXytigKHeC5 DYrGbL81QYKlCI3xxV2RkC77wi61QADL6LviFW9H11F/dPugFW7xEmVX+QjEXU1feoVD r/iGgnqx5NWyBUmW3RjUTvFEQdxnxtgYgIylX3zuVgOSCcn3FbbI6ZrikCDtfGGw0SzM GlA76rMc2dAxDSVfmtfttYx25yhlC3DcZSusFga55N33uy9Dghfn6kFirVqYwJHUS1G5 rHe56vsX6IiWWtJR/I0a6iP9g4YPMWImyJ81ITLfzqgoHcJ60W4jLbJbry35YY68TR/O 6BQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689834316; x=1690439116; h=cc:to:subject:message-id:date:from:sender:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JNL4l5GRlHwxV4ntRBz/satLVd2URGo3WiWHTSW6eE4=; b=j8Rl2Pa6EECdut3+zzldJs/2YaZHCnqM+2sgvurVNDa9uvh2h5FUmRgZ2VgZMP9h1S /ZXkNVPs5XpRhgDLXE/o5VHREX0Vqb6gYFF4tPPkowPkAXyUW2wsHjuEzBv2LhIBovdd Wz/rW+fV3jvTAvslrE3J3NLuefzBSyHfhHZvzM0iGle3YQ5EaqE5lwIQhygejidSBrzl GaFofUR2AwNxvVnQi8OEmYnGJPQlKuTtXurkj2kYWq/MOHPBUT/cRVsifxYW+94YpsR6 0bUaVLYxiTwDp8qQfmNnMvcR9xXgyjFbwOd+sfDt2+0hDzC7kmJrtUyWxZfImkoRwOBi 6jMw== X-Gm-Message-State: ABy/qLa6j0Qd//ps0Ghl58jEXJpxg7q3QTdeR1oYPn8OJvj5h5TQC+es HWaT4Lexr9DTwOf0Zcvi71mUA5QcncMPK/HtqoHdTI6OQ9E= X-Received: by 2002:aa7:c38a:0:b0:51e:36b8:34fa with SMTP id k10-20020aa7c38a000000b0051e36b834famr3973631edq.4.1689834315425; Wed, 19 Jul 2023 23:25:15 -0700 (PDT) MIME-Version: 1.0 References: <65f4c60a-9534-56dc-099f-ee7a96e0ccaf@redhat.com> <20230712235813.GE6354@monkey> <6c3191e1-23fd-4f9e-9b5e-321c51599897@moroto.mountain> <20230719232248.GC3240@monkey> In-Reply-To: <20230719232248.GC3240@monkey> Sender: cl1ntlov3@gmail.com X-Google-Sender-Delegation: cl1ntlov3@gmail.com From: linke li Date: Thu, 20 Jul 2023 14:25:03 +0800 X-Google-Sender-Auth: vNNFw5NqUWJumSZdCdnOBZIRxbk Message-ID: Subject: Re: [PATCH] hugetlbfs: Fix integer overflow check in hugetlbfs_file_mmap() To: Mike Kravetz Cc: Dan Carpenter , Linke Li , David Hildenbrand , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, 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 > > What about using the check_add_overflow() macro? > > I like the macro. It seems to have plenty of users. > > Linke Li, what do you think? If you like, please send another path > using the macro as suggested by Dan. Thanks for Dan's advice. I have tested this macro in gcc-9 and clang-14, it can work well in both compilers and regardless of whether "-fno-strict-overflow" is added or not. I will send a new patch. Best Regards