mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: lizetao <lizetao1@huawei.com>
To: Bui Quang Minh <minhquangbui99@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	Pavel Begunkov <asml.silence@gmail.com>,
	"io-uring@vger.kernel.org" <io-uring@vger.kernel.org>,
	"syzbot+5988142e8a69a67b1418@syzkaller.appspotmail.com"
	<syzbot+5988142e8a69a67b1418@syzkaller.appspotmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] io_uring/sqpoll: annotate data race for access in debug check
Date: Wed, 8 Jan 2025 16:24:19 +0000	[thread overview]
Message-ID: <71f1cec18e94459995dfb4bed9a79939@huawei.com> (raw)
In-Reply-To: <20250108151052.7944-1-minhquangbui99@gmail.com>

Hi,

> -----Original Message-----
> From: Bui Quang Minh <minhquangbui99@gmail.com>
> Sent: Wednesday, January 8, 2025 11:11 PM
> To: linux-kernel@vger.kernel.org
> Cc: Bui Quang Minh <minhquangbui99@gmail.com>; Jens Axboe
> <axboe@kernel.dk>; Pavel Begunkov <asml.silence@gmail.com>; io-
> uring@vger.kernel.org;
> syzbot+5988142e8a69a67b1418@syzkaller.appspotmail.com
> Subject: [PATCH] io_uring/sqpoll: annotate data race for access in debug check
> 
> sqd->thread must only be access while holding sqd->lock. In
> io_sq_thread_stop, the sqd->thread access to wake up the sq thread is placed
> while holding sqd->lock, but the access in debug check is not. As this access if
> for debug check only, we can safely ignore the data race here. So we annotate
> this access with data_race to silence KCSAN.
> 
> Reported-by: syzbot+5988142e8a69a67b1418@syzkaller.appspotmail.com
> Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
> ---
>  io_uring/sqpoll.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c index
> 9e5bd79fd2b5..2088c56dbaa0 100644
> --- a/io_uring/sqpoll.c
> +++ b/io_uring/sqpoll.c
> @@ -57,7 +57,7 @@ void io_sq_thread_park(struct io_sq_data *sqd)
> 
>  void io_sq_thread_stop(struct io_sq_data *sqd)  {
> -	WARN_ON_ONCE(sqd->thread == current);
> +	WARN_ON_ONCE(data_race(sqd->thread) == current);
>  	WARN_ON_ONCE(test_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd-
> >state));
> 
>  	set_bit(IO_SQ_THREAD_SHOULD_STOP, &sqd->state);
> --
> 2.43.0
> 

The modification of this patch itself is fine, but there are two other things I need to confirm.
1、Does the io_uring_cancel_generic() require the same modification?
2、It is not holding sqd->lock in io_req_normal_work_add(), is it safe?

Thanks.
Reviewed-by: Li Zetao<lizetao1@huawei.com>

---
Li Zetao

  reply	other threads:[~2025-01-08 16:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08 15:10 Bui Quang Minh
2025-01-08 16:24 ` lizetao [this message]
2025-01-08 16:42   ` Bui Quang Minh

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=71f1cec18e94459995dfb4bed9a79939@huawei.com \
    --to=lizetao1@huawei.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minhquangbui99@gmail.com \
    --cc=syzbot+5988142e8a69a67b1418@syzkaller.appspotmail.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®