Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp104134rwb; Wed, 30 Nov 2022 22:58:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf5N5B1QVymS3TK2MSmbS2+0WMPHIKTx4NfHykrSSHmx4SpYWjaPXe7zi4Qhq6dDRoxr/BpK X-Received: by 2002:aa7:c1d0:0:b0:46b:431f:f2d4 with SMTP id d16-20020aa7c1d0000000b0046b431ff2d4mr15303538edp.198.1669877885155; Wed, 30 Nov 2022 22:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669877885; cv=none; d=google.com; s=arc-20160816; b=J7ICOqv8/sCdCpi2jaaPtd6QWXPP6q0ixQPB93rf16hXc/gNDYBzWBwUvO41T29gmI EM/FoWNnf3CwFo4/ookmq1LC525o4+IjpqR6XZ8WCKdHZGb3GfdF2uIDEkSe4KffL2B5 A+l5eMD9XFcjO4fDNo8A6lryKBKPGParBAMb/hlQaUwcRaCP/8iZGKhw+iCyglnrmoRt Ml9UoMnIYFpSlSKwNIhZwEf0WaFtTTByu7jHTclMRSDa6KN0TpDae+nDo8WqKWzunBPC q1VQrL9QT9EIYglw4cMeEG6LGGPsptevGQ2g42WwI+opj4kUqfxUoX9rW4nrgp0d1Zyu Lvww== 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:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id; bh=liX6FYdUfGIOES5GylHxqk84dTxGfL0h/U6ulZ2HQyw=; b=hAxb9L+NAVN15bYnsy/4So+7vfIxY4HD3shu9K/XBdnKr+yhTMHMqrvztKrWK5s4Y+ gSfBziFXgKjLsrSEwWOYWpnDp30rMZlc3TeV1Jh9PK+l8Cx3x1jCJifszGBOdxSsFh6+ fFZfBXJEzF+Aha3+FuZuuhaAr7/9KSqPB6I5QdAz4DIjxYGJBxDwYuB7oz3ZlCxNRbyw 9hi7NpReL1E1+yu9oG1GfihyxIrT5NqdlbP1+z9CkQb/x6HVdL3tu017sEqLY0L7nERV OZaY0e7fBKAQGupT4T3WwHU1JXHGrBxcKgT+5IzhQKVZh+TEdmhKYmWygfoSkYBihDyy j/1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 d24-20020a056402079800b0046ba3001425si766123edy.60.2022.11.30.22.57.33; Wed, 30 Nov 2022 22:58:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-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 S229559AbiLAGUN (ORCPT + 99 others); Thu, 1 Dec 2022 01:20:13 -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 X-Spam-Status: No, score=-4.5 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-ext4@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 .