Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp11594900rwb; Fri, 25 Nov 2022 18:25:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Aq35gXq+zmFzPPcjzk6f7SIwfnDTGsiEk5QIR/Rzo3iYX92UxevJ2oPzrG2NqaNE5Hgjw X-Received: by 2002:a17:90b:3c4a:b0:213:1d14:2a27 with SMTP id pm10-20020a17090b3c4a00b002131d142a27mr43783362pjb.109.1669429557941; Fri, 25 Nov 2022 18:25:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669429557; cv=none; d=google.com; s=arc-20160816; b=oJU6D3G441I9fyygyqjYALW84Z6LF16yu9RLrJ9vUnTe73dG4YrvzahgoCx3jDAi+e 6Rj/q3HUHN5KVfVAem35ROMl+5YpduZKrnrXQ0bYykWS022m2k2Zc5HOgfkjTuM/b5uN auJ9tpNzoK7nPG4u05ug9wTrp3Oc7uvgkPdyJLwYwWxxBr4MX+yrpnJkfS5kl5dOBZfr stSSMzL6rlDOXofaVvzwVS6ixM8F0agZvM4xl2UsEB7gzXN/EY7xnYA0ztpZml9Eq9Lu g65MpSw+F+10nEx2vfYwykS9aljltXY5Izr9tAp3CRRkpKsjy9YRIK5BldShA1bxoFnL hQIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=4XOfxip3dzBWCu1+Okjc4Q3b/erH/I8+7hfL4GYh+k8=; b=QEuZFflw73WBDBXLaoN05p2mCwEXNAhF9Dp/Sl81qUyxIdqFoJiGg0fM6ol4nL5u3M 0RW0iXeiq0oTaPWXPaJibjWr05mRRzvZ3boLpMnag1pLyQyCQeTyaIvlTJ/1lMUtThk9 bfLmp4DtbiUg0w5sve+WhPnKwThLsGAwYOinaP2kROF8laBKAtIcwMmlo+fMDhEJtSDF aQa6r//BpGZ4h25Sf6Xildwjo97jEtykKqWJ87sqJonNAuS+6pRRdFPcbx8Mo37ekXH1 vShcafBerdzyB1myMnu49dKm4B7gyAMmBDmdWOGaLzm9eaEnZ0hQaPC5/P0bnAxLUkgp eVAw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h8-20020a170902704800b001892277e107si5277182plt.64.2022.11.25.18.25.46; Fri, 25 Nov 2022 18:25:57 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230057AbiKZB7M (ORCPT + 86 others); Fri, 25 Nov 2022 20:59:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbiKZB7K (ORCPT ); Fri, 25 Nov 2022 20:59:10 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E464A1CFFD; Fri, 25 Nov 2022 17:59:09 -0800 (PST) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NJvv20VVbzqSdh; Sat, 26 Nov 2022 09:55:10 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 26 Nov 2022 09:59:08 +0800 Received: from [10.174.178.55] (10.174.178.55) by dggpemm500006.china.huawei.com (7.185.36.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 26 Nov 2022 09:59:07 +0800 Subject: Re: [PATCH v3 0/2] fs: clear a UBSAN shift-out-of-bounds warning To: Al Viro CC: Eric Biggers , , "Chris Mason" , Josef Bacik , David Sterba , , References: <20221125091358.1963-1-thunder.leizhen@huawei.com> From: "Leizhen (ThunderTown)" Message-ID: <0a8264a8-e2a9-952a-97ce-a7f06920ad39@huawei.com> Date: Sat, 26 Nov 2022 09:59:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.55] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpemm500006.china.huawei.com (7.185.36.236) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS 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 2022/11/26 5:00, Al Viro wrote: > On Fri, Nov 25, 2022 at 05:13:56PM +0800, Zhen Lei wrote: >> v2 --> v3: >> Updated the commit message of patch 2/2 based on Alexander Viro's suggestion. > > Not exactly what I meant... I've tentatively applied it, with the Haha, I felt like something was missing yesterday, too. But as far as my English level is concerned, I usually copy the words suggested by others directly. > following commit message: Thanks. > > -------------------------------- > get rid of INT_LIMIT, use type_max() instead > > INT_LIMIT() tries to do what type_max() does, except that type_max() > doesn't rely upon undefined behaviour[*], might as well use type_max() > instead. > > [*] if T is an N-bit signed integer type, the maximal value in T is > pow(2, N - 1) - 1, all right, but naive expression for that value > ends up with a couple of wraparounds and as usual for wraparounds > in signed types, that's an undefined behaviour. type_max() takes > care to avoid those... > > Caught-by: UBSAN > Suggested-by: Eric Biggers > Signed-off-by: Zhen Lei > Reviewed-by: Eric Biggers > Signed-off-by: Al Viro > -------------------------------- > > Does anybody have objections against the commit message above? Looks good to me. > > . > -- Regards, Zhen Lei