[PATCH RFC] ubifs: Fix use-after-free in ubifs_tnc_end_commit
Ryder Wang
rydercoding at hotmail.com
Tue Oct 29 01:10:50 PDT 2024
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.
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.
More information about the linux-mtd
mailing list