From: Zhihao Cheng <chengzhihao1@huawei.com>
To: pangliyuan <pangliyuan1@huawei.com>, <richard@nod.at>,
<Artem.Bityutskiy@nokia.com>, <ext-adrian.hunter@nokia.com>
Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>,
<wangfangpeng1@huawei.com>
Subject: Re: [PATCH] ubifs: skip dumping tnc tree when zroot is null
Date: Tue, 24 Dec 2024 16:44:41 +0800 [thread overview]
Message-ID: <c929d4b4-44b8-810f-2014-98cd1ea0d392@huawei.com> (raw)
In-Reply-To: <20241224081823.15417-1-pangliyuan1@huawei.com>
在 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@huawei.com>
> ---
> fs/ubifs/debug.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.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);
> }
>
prev parent reply other threads:[~2024-12-24 8:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-24 8:18 pangliyuan
2024-12-24 8:44 ` Zhihao Cheng [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c929d4b4-44b8-810f-2014-98cd1ea0d392@huawei.com \
--to=chengzhihao1@huawei.com \
--cc=Artem.Bityutskiy@nokia.com \
--cc=ext-adrian.hunter@nokia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=pangliyuan1@huawei.com \
--cc=richard@nod.at \
--cc=wangfangpeng1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®