[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3c46013e-809e-cdcf-8648-2ffe2ab6c32b@huawei.com>
Date: Sat, 9 Nov 2024 10:34:25 +0800
From: Zhihao Cheng <chengzhihao1@...wei.com>
To: Waqar Hameed <waqar.hameed@...s.com>, Richard Weinberger <richard@....at>,
Sascha Hauer <s.hauer@...gutronix.de>
CC: <kernel@...s.com>, <linux-mtd@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] ubifs: Fix use-after-free in ubifs_tnc_end_commit
在 2024/10/9 22:46, Waqar Hameed 写道:
3 nits below.
1. Make the title as 'ubifs: authentication: Fix use-after-free in
ubifs_tnc_end_commit'
2. At the begining of the commit msg, describe the problem:
After TNC tree inserting(which may trigger a znode split and change the
znode->parent) and deleting(which may trigger znode freeing), the
znode->cparent(which still points to a freed znode) may not be updated
at the begining of commit, which could trigger an UAF problem while
accessing znode->cparent in write_index().
> Running
>
> rm -f /etc/test-file.bin
> dd if=/dev/urandom of=/etc/test-file.bin bs=1M count=60 conv=fsync
>
> in a loop, with `CONFIG_UBIFS_FS_AUTHENTICATION`, KASAN reports:
>
> BUG: KASAN: use-after-free in ubifs_tnc_end_commit+0xa5c/0x1950
> Write of size 32 at addr ffffff800a3af86c by task ubifs_bgt0_20/153
>
> Call trace:
[...]
> diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
> index a55e04822d16..a464eb557585 100644
> --- a/fs/ubifs/tnc_commit.c
> +++ b/fs/ubifs/tnc_commit.c
> @@ -657,6 +657,7 @@ static int get_znodes_to_commit(struct ubifs_info *c)
> znode->alt = 0;
> cnext = find_next_dirty(znode);
> if (!cnext) {
3. I'd like to add the the assertion 'ubifs_assert(c, !znode->parent);'
> + znode->cparent = NULL;
> znode->cnext = c->cnext;
> break;
> }
>
Powered by blists - more mailing lists