]> git.baikalelectronics.ru Git - kernel.git/commit
closures: fix a race on wakeup from closure_sync
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 3 Sep 2019 13:25:45 +0000 (21:25 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 3 Sep 2019 14:08:31 +0000 (08:08 -0600)
commitd15fcba23c14b5fdbff2c8b4394bf3a932adc120
treecdda0a4f2abcfaf8627fec61a16de34e19a2223b
parent7cce125b4f06dd265ef21306542dbe2d01f4a713
closures: fix a race on wakeup from closure_sync

The race was when a thread using closure_sync() notices cl->s->done == 1
before the thread calling closure_put() calls wake_up_process(). Then,
it's possible for that thread to return and exit just before
wake_up_process() is called - so we're trying to wake up a process that
no longer exists.

rcu_read_lock() is sufficient to protect against this, as there's an rcu
barrier somewhere in the process teardown path.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Acked-by: Coly Li <colyli@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/md/bcache/closure.c