From: Jens Axboe <axboe@kernel.dk>
To: Hillf Danton <hdanton@sina.com>
Cc: io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
viro@zeniv.linux.org.uk,
syzbot+45fa0a195b941764e0f0@syzkaller.appspotmail.com,
syzbot+9af99580130003da82b1@syzkaller.appspotmail.com,
Pavel Begunkov <asml.silence@gmail.com>
Subject: Re: [PATCH next] io-wq: fix use-after-free in io_wq_worker_running
Date: Sat, 26 Sep 2020 12:07:19 -0600 [thread overview]
Message-ID: <1ac425e8-f302-4e91-0c1d-3ebb0a40cf96@kernel.dk> (raw)
In-Reply-To: <20200926132655.6192-1-hdanton@sina.com>
On 9/26/20 7:26 AM, Hillf Danton wrote:
> --- a/fs/io-wq.c
> +++ b/fs/io-wq.c
> @@ -200,7 +200,6 @@ static void io_worker_exit(struct io_wor
> {
> struct io_wqe *wqe = worker->wqe;
> struct io_wqe_acct *acct = io_wqe_get_acct(wqe, worker);
> - unsigned nr_workers;
>
> /*
> * If we're not at zero, someone else is holding a brief reference
> @@ -228,15 +227,11 @@ static void io_worker_exit(struct io_wor
> raw_spin_lock_irq(&wqe->lock);
> }
> acct->nr_workers--;
> - nr_workers = wqe->acct[IO_WQ_ACCT_BOUND].nr_workers +
> - wqe->acct[IO_WQ_ACCT_UNBOUND].nr_workers;
> raw_spin_unlock_irq(&wqe->lock);
>
> - /* all workers gone, wq exit can proceed */
> - if (!nr_workers && refcount_dec_and_test(&wqe->wq->refs))
> - complete(&wqe->wq->done);
> -
> kfree_rcu(worker, rcu);
> + if (refcount_dec_and_test(&wqe->wq->refs))
> + complete(&wqe->wq->done);
> }
Nice, we came up with the same fix, thanks a lot for looking into this.
I pushed this one out for syzbot to test:
https://git.kernel.dk/cgit/linux-block/commit/?h=io_uring-5.9&id=41d5f92f60a61e264dafbada79175dad0bc60c5b
which is basically identical. I did consider the EXIT check as well, but
we don't really need it, so I'd prefer to leave that out of it.
I'll queue yours up.
--
Jens Axboe
next parent reply other threads:[~2020-09-26 18:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200926132655.6192-1-hdanton@sina.com>
2020-09-26 18:07 ` Jens Axboe [this message]
2020-09-26 18:35 ` Jens Axboe
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=1ac425e8-f302-4e91-0c1d-3ebb0a40cf96@kernel.dk \
--to=axboe@kernel.dk \
--cc=asml.silence@gmail.com \
--cc=hdanton@sina.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+45fa0a195b941764e0f0@syzkaller.appspotmail.com \
--cc=syzbot+9af99580130003da82b1@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=viro@zeniv.linux.org.uk \
/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®