[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c929d4b4-44b8-810f-2014-98cd1ea0d392@huawei.com>
Date: Tue, 24 Dec 2024 16:44:41 +0800
From: Zhihao Cheng <chengzhihao1@...wei.com>
To: pangliyuan <pangliyuan1@...wei.com>, <richard@....at>,
<Artem.Bityutskiy@...ia.com>, <ext-adrian.hunter@...ia.com>
CC: <linux-mtd@...ts.infradead.org>, <linux-kernel@...r.kernel.org>,
<wangfangpeng1@...wei.com>
Subject: Re: [PATCH] ubifs: skip dumping tnc tree when zroot is null
在 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 <pangliyuan1@...wei.com>
> ---
> fs/ubifs/debug.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
Reviewed-by: Zhihao Cheng <chengzhihao1@...wei.com>
> 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);
> }
>
Powered by blists - more mailing lists