[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fc567699-59c7-265a-b7c8-7b658cc6fc05@huawei.com>
Date: Tue, 29 Oct 2024 17:06:30 +0800
From: Zhihao Cheng <chengzhihao1@...wei.com>
To: Ryder Wang <rydercoding@...mail.com>, Waqar Hameed
<waqar.hameed@...s.com>, Richard Weinberger <richard@....at>, Sascha Hauer
<s.hauer@...gutronix.de>
CC: "kernel@...s.com" <kernel@...s.com>, "linux-mtd@...ts.infradead.org"
<linux-mtd@...ts.infradead.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH RFC] ubifs: Fix use-after-free in ubifs_tnc_end_commit
在 2024/10/29 16:10, Ryder Wang 写道:
Hi, Ryder
> I just have some interesting finding.
>
> The code of the function write_index() has a race condition bug. c->enext is used in write_index(), but it is NOT protected by c->tnc_mutex. So there must be SOME race condition problem. I believe some znode may be corrupted or misread if 2 kernel tasks are operating the same znode concurrently.
Thanks for reporting that :-). I noticed it a period time ago too, and I
found 'c->znext', 'c->cnext' and 'znode->cnext' won't be accessed (in
write mode) by other tasks, because there is only one function
do_commit() modifying them and do_commit() can be executed by at most
one task in any time.
>
> The code comment of struct ubifs_info below indicates that c->enext must be protected by c->tnc_mutex.
> --------------------------------------------------------------------------------------------------
> * @tnc_mutex: protects the Tree Node Cache (TNC), @zroot, @cnext, @enext, and
> * @calc_idx_sz
> --------------------------------------------------------------------------------------------------
>
> That's why I don't think this patch can fully fix this issue because the race condition is still there.
>
> .
>
Powered by blists - more mailing lists