[PATCH] ubifs: skip dumping tnc tree when zroot is null
Zhihao Cheng
chengzhihao1 at huawei.com
Tue Dec 24 00:44:41 PST 2024
在 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 at huawei.com>
> ---
> fs/ubifs/debug.c | 22 +++++++++++++---------
> 1 file changed, 13 insertions(+), 9 deletions(-)
>
Reviewed-by: Zhihao Cheng <chengzhihao1 at 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);
> }
>
More information about the linux-mtd
mailing list