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 6F7F9C43217 for ; Thu, 1 Dec 2022 06:20:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229619AbiLAGUO (ORCPT ); Thu, 1 Dec 2022 01:20:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbiLAGUM (ORCPT ); Thu, 1 Dec 2022 01:20:12 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9AB7AB001; Wed, 30 Nov 2022 22:20:11 -0800 (PST) Received: from dggpeml500021.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NN5Wf65c3zHwP3; Thu, 1 Dec 2022 14:19:26 +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.31; Thu, 1 Dec 2022 14:20:09 +0800 Message-ID: Date: Thu, 1 Dec 2022 14:20:09 +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 a NULL pointer when validating an inode bitmap To: Theodore Ts'o CC: =?UTF-8?Q?Lu=c3=ads_Henriques?= , Andreas Dilger , , , References: <20221010142035.2051-1-lhenriques@suse.de> <20221011155623.14840-1-lhenriques@suse.de> Content-Language: en-US From: Baokun Li In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit 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-kernel@vger.kernel.org On 2022/12/1 12:32, Theodore Ts'o wrote: > On Wed, Nov 30, 2022 at 11:20:11AM +0800, Baokun Li wrote: >>> If we can protect against the problem by adding a check that has other >>> value as well (such as making usre that when ext4_iget fetches a >>> special inode, we enforce that i_links_couint must be > 0), maybe >>> that's worth it. >> Yes, but some special inodes allow i_links_couint to be zero, >> such as the uninitialized boot load inode. > That's a good point; but the only time when a special inode can > validly have a zero i_links_count is when it has no blocks associated > to it. Otherwise, when the file system releases the inode using > iput() when the file system is unmounted, all of the blocks will get > released when the inode is evicted. So we can have ext4_iget() allow > fetching an inode if i_blocks[] is zeros. But if it has any blocks > and i_links_count is non-zero, something must be terribly wrong with > that inode. > > Cheers, > > - Ted > Totally agree! That sounds good! -- With Best Regards, Baokun Li .