From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5108837160 for ; Tue, 24 Dec 2024 08:44:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735029890; cv=none; b=UvQ+phuZgDeuP9j4D8yEpINUdTDVC0f5Sgl/U4Wd6JGfFmmO07BM8mD+oJz503bgsWiS6TLqImfYZ5+q9TpMjPbqLdPWcrN3gusfsYGB23b7SM/Jl4qovzIfqqDZa9veDKEx7l6nN+9udHtyw5OnCbSrxWmDxodwEu19yyUGu7w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735029890; c=relaxed/simple; bh=EBbM1HFxUkvn7avHXQ5WN7J33jSWHwqFLdH+r2m2eWE=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=KB+mpWj23/kvDiDhd6MrSc/JXAAWYu1R/eZu9RYJtrD9fLAxOclBv9/B7ZpqifUKbXWZgxrYQKtYFSlN/ZcCP1BP1389kNPPKdtCEYaiqx2llIuuab6h8HQKfNRZoHvKMqR9Dd1eRoOS/Qol/nrM22QYjaVq6huAuDExiLIOakk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4YHT2l2mJzz1JG6n; Tue, 24 Dec 2024 16:44:15 +0800 (CST) Received: from kwepemk500005.china.huawei.com (unknown [7.202.194.90]) by mail.maildlp.com (Postfix) with ESMTPS id 6F24A1A0190; Tue, 24 Dec 2024 16:44:44 +0800 (CST) Received: from [10.174.178.46] (10.174.178.46) by kwepemk500005.china.huawei.com (7.202.194.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 24 Dec 2024 16:44:43 +0800 Subject: Re: [PATCH] ubifs: skip dumping tnc tree when zroot is null To: pangliyuan , , , CC: , , References: <20241224081823.15417-1-pangliyuan1@huawei.com> From: Zhihao Cheng Message-ID: Date: Tue, 24 Dec 2024 16:44:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20241224081823.15417-1-pangliyuan1@huawei.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemk500005.china.huawei.com (7.202.194.90) ÔÚ 2024/12/24 16:18, pangliyuan дµÀ: > Clearing slab cache will free all znode in memory and make > c->zroot.znode = NULL, then dumping tnc tree will access > c->zroot.znode which cause null pointer dereference. > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=219624#c0 > Fixes: 1e51764a3c2a ("UBIFS: add new flash file system") > Signed-off-by: pangliyuan > --- > fs/ubifs/debug.c | 22 +++++++++++++--------- > 1 file changed, 13 insertions(+), 9 deletions(-) > Reviewed-by: Zhihao Cheng > diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c > index 5cc69beaa62e..10a86c02a8b3 100644 > --- a/fs/ubifs/debug.c > +++ b/fs/ubifs/debug.c > @@ -946,16 +946,20 @@ void ubifs_dump_tnc(struct ubifs_info *c) > > pr_err("\n"); > pr_err("(pid %d) start dumping TNC tree\n", current->pid); > - znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, NULL); > - level = znode->level; > - pr_err("== Level %d ==\n", level); > - while (znode) { > - if (level != znode->level) { > - level = znode->level; > - pr_err("== Level %d ==\n", level); > + if (c->zroot.znode) { > + znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, NULL); > + level = znode->level; > + pr_err("== Level %d ==\n", level); > + while (znode) { > + if (level != znode->level) { > + level = znode->level; > + pr_err("== Level %d ==\n", level); > + } > + ubifs_dump_znode(c, znode); > + znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, znode); > } > - ubifs_dump_znode(c, znode); > - znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, znode); > + } else { > + pr_err("empty TNC tree in memory\n"); > } > pr_err("(pid %d) finish dumping TNC tree\n", current->pid); > } >