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 87157C00140 for ; Fri, 12 Aug 2022 13:34:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238972AbiHLNe5 (ORCPT ); Fri, 12 Aug 2022 09:34:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238971AbiHLNe5 (ORCPT ); Fri, 12 Aug 2022 09:34:57 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3938D9F0DA; Fri, 12 Aug 2022 06:34:55 -0700 (PDT) Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M44MZ0zStzkWMq; Fri, 12 Aug 2022 21:31:38 +0800 (CST) Received: from [10.174.177.174] (10.174.177.174) by dggpeml500021.china.huawei.com (7.185.36.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 12 Aug 2022 21:34:52 +0800 Message-ID: <515c1447-9ca2-844c-0a89-a698157d14f6@huawei.com> Date: Fri, 12 Aug 2022 21:34:51 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH v2] ext4: fix bug in extents parsing when eh_entries == 0 and eh_depth > 0 Content-Language: en-US To: =?UTF-8?Q?Lu=c3=ads_Henriques?= CC: Theodore Ts'o , Andreas Dilger , , , , "zhangyi (F)" , , "yukuai (C)" , Baokun Li References: <20220812105347.2251-1-lhenriques@suse.de> From: Baokun Li In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.177.174] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500021.china.huawei.com (7.185.36.21) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi Luís, On 8/12/2022 9:19 PM, Luís Henriques wrote: > Hi Baokun! > > On Fri, Aug 12, 2022 at 08:50:34PM +0800, Baokun Li wrote: >> Hi Luís, > ... >>> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c >>> index 53cfe2c681c4..a5457ac1999c 100644 >>> --- a/fs/ext4/extents.c >>> +++ b/fs/ext4/extents.c >>> @@ -460,6 +460,11 @@ static int __ext4_ext_check(const char *function, unsigned int line, >>> error_msg = "invalid eh_entries"; >>> goto corrupted; >>> } >>> + if (unlikely((le16_to_cpu(eh->eh_entries) == 0) && >>> + (le16_to_cpu(eh->eh_depth > 0)))) { le16_to_cpu(eh->eh_depth > 0) It's the wrong position of the parentheses here. >> The parentheses are misplaced, > I'm not sure I understand what you mean. I want to have > > if (unlikely((CONDITION A) && (CONDITION B))) { > /* ... */ > } > > so they look correct. Or is that a matter of style/alignment? (Which > checkpatch.pl doesn't complains about, by the way.) > >> and le16_to_cpu is not needed here. > OK, I guess that, since both conditions do a comparison against '0', the > le16_to_cpu() can be dropped. And, if the parentheses problem you > mentioned above is a style problem, dropping it will also solve it because > that statement will become > > if (unlikely((eh->eh_entries == 0) && (eh->eh_depth > 0))) { > /* ... */ > } Yeah, but it could be more streamlined here. The earlier judgment has guaranteed "depth == eh->eh_depth" > And once again, thanks for your review! > > Cheers, -- With Best Regards, Baokun Li