public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: "Zhang, Qiang" <[email protected]>,
	syzbot <[email protected]>,
	"[email protected]" <[email protected]>,
	"[email protected]" <[email protected]>,
	"[email protected]" <[email protected]>,
	"[email protected]"
	<[email protected]>
Subject: Re: 回复: [syzbot] KASAN: use-after-free Read in io_worker_handle_work
Date: Sat, 22 May 2021 01:55:37 +0100	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <DM6PR11MB42024E7A188486B8850905D6FF299@DM6PR11MB4202.namprd11.prod.outlook.com>

On 5/21/21 9:45 AM, Zhang, Qiang wrote:
[...]
> It looks like 
> thread iou-wrk-28796 in io-wq(A)  access wqe in the wait queue(data->hash->wait),  but this wqe  has been free due to the destruction of another io-wq(B).
> 
> Should we after wait for all iou-wrk thread exit in the io-wq,  remove wqe from the waiting queue (data->hash->wait).   prevent some one  wqe  belonging to this io-wq , may be still existing in the (data->hash->wait)queue before releasing. 

The guess looks reasonable, it's likely a problem.
Not sure about the diff, it seems racy but I need to
take a closer look to say for sure


> look forward to your opinion.
> 
> --- a/fs/io-wq.c
> +++ b/fs/io-wq.c
> @@ -1003,13 +1003,17 @@ static void io_wq_exit_workers(struct io_wq *wq)
>                 struct io_wqe *wqe = wq->wqes[node];
>  
>                 io_wq_for_each_worker(wqe, io_wq_worker_wake, NULL);
> -               spin_lock_irq(&wq->hash->wait.lock);
> -               list_del_init(&wq->wqes[node]->wait.entry);
> -               spin_unlock_irq(&wq->hash->wait.lock);
>         }
>         rcu_read_unlock();
>         io_worker_ref_put(wq);
>         wait_for_completion(&wq->worker_done);
> +       for_each_node(node) {
> +               struct io_wqe *wqe = wq->wqes[node];
> +
> +               spin_lock_irq(&wq->hash->wait.lock);
> +               list_del_init(&wq->wqes[node]->wait.entry);
> +               spin_unlock_irq(&wq->hash->wait.lock);
> +       }
>         put_task_struct(wq->task);
>         wq->task = NULL;
>  }

-- 
Pavel Begunkov

  reply	other threads:[~2021-05-22  0:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-19  6:08 [syzbot] KASAN: use-after-free Read in io_worker_handle_work syzbot
2021-05-21  8:45 ` 回复: " Zhang, Qiang
2021-05-22  0:55   ` Pavel Begunkov [this message]
2021-05-23 20:07     ` Pavel Begunkov

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 \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /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