mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhihao Cheng <chengzhihao1@huawei.com>
To: Ryder Wang <rydercoding@hotmail.com>,
	Waqar Hameed <waqar.hameed@axis.com>,
	Richard Weinberger <richard@nod.at>,
	Sascha Hauer <s.hauer@pengutronix.de>
Cc: "kernel@axis.com" <kernel@axis.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC] ubifs: Fix use-after-free in ubifs_tnc_end_commit
Date: Tue, 29 Oct 2024 17:06:30 +0800	[thread overview]
Message-ID: <fc567699-59c7-265a-b7c8-7b658cc6fc05@huawei.com> (raw)
In-Reply-To: <MEYP282MB316412B08A32373E5ED9B896BF4B2@MEYP282MB3164.AUSP282.PROD.OUTLOOK.COM>

在 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.
> 
> .
> 


  reply	other threads:[~2024-10-29  9:06 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-09 14:46 Waqar Hameed
2024-10-12 12:30 ` Zhihao Cheng
2024-10-15 18:52   ` Waqar Hameed
2024-10-16  2:11     ` Zhihao Cheng
2024-10-17 18:36       ` Waqar Hameed
2024-10-18  1:40         ` Zhihao Cheng
2024-11-06 16:36           ` Waqar Hameed
2024-11-07  7:14             ` Zhihao Cheng
2024-11-07 22:11               ` Waqar Hameed
2024-10-29  8:10 ` Ryder Wang
2024-10-29  9:06   ` Zhihao Cheng [this message]
2024-10-29  9:56     ` Ryder Wang
2024-10-29 11:19       ` Zhihao Cheng
2024-11-07  8:39 ` Zhihao Cheng
2024-11-07 22:38   ` Waqar Hameed
2024-11-08  1:38     ` Zhihao Cheng
2024-11-08 18:02     ` Waqar Hameed

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=fc567699-59c7-265a-b7c8-7b658cc6fc05@huawei.com \
    --to=chengzhihao1@huawei.com \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=rydercoding@hotmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=waqar.hameed@axis.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®