[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b6a339b4-e25c-1466-3db4-f96739365ca6@gmail.com>
Date: Sat, 22 May 2021 01:55:37 +0100
From: Pavel Begunkov <asml.silence@...il.com>
To: "Zhang, Qiang" <Qiang.Zhang@...driver.com>,
syzbot <syzbot+6cb11ade52aa17095297@...kaller.appspotmail.com>,
"axboe@...nel.dk" <axboe@...nel.dk>,
"io-uring@...r.kernel.org" <io-uring@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"syzkaller-bugs@...glegroups.com" <syzkaller-bugs@...glegroups.com>
Subject: Re: 回复: [syzbot] KASAN: use-after-free Read in io_worker_handle_work
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
Powered by blists - more mailing lists