From: Jens Axboe <[email protected]>
To: Hillf Danton <[email protected]>
Cc: [email protected], [email protected],
[email protected], [email protected],
[email protected],
[email protected],
[email protected],
Pavel Begunkov <[email protected]>
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: <[email protected]> (raw)
In-Reply-To: <[email protected]>
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] <[email protected]>
2020-09-26 18:07 ` Jens Axboe [this message]
2020-09-26 18:35 ` [PATCH next] io-wq: fix use-after-free in io_wq_worker_running 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 \
[email protected] \
[email protected] \
[email protected] \
[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