[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lsq.1539530741.24504917@decadent.org.uk>
Date: Sun, 14 Oct 2018 16:25:41 +0100
From: Ben Hutchings <ben@...adent.org.uk>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
CC: akpm@...ux-foundation.org, "Dave Chinner" <dchinner@...hat.com>,
"Tetsuo Handa" <penguin-kernel@...ove.SAKURA.ne.jp>,
"Tejun Heo" <tj@...nel.org>, "Jens Axboe" <axboe@...nel.dk>,
"Jan Kara" <jack@...e.cz>,
"syzbot" <syzbot+9873874c735f2892e7e9@...kaller.appspotmail.com>
Subject: [PATCH 3.16 258/366] bdi: Fix oops in wb_workfn()
3.16.60-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Jan Kara <jack@...e.cz>
commit b8b784958eccbf8f51ebeee65282ca3fd59ea391 upstream.
Syzbot has reported that it can hit a NULL pointer dereference in
wb_workfn() due to wb->bdi->dev being NULL. This indicates that
wb_workfn() was called for an already unregistered bdi which should not
happen as wb_shutdown() called from bdi_unregister() should make sure
all pending writeback works are completed before bdi is unregistered.
Except that wb_workfn() itself can requeue the work with:
mod_delayed_work(bdi_wq, &wb->dwork, 0);
and if this happens while wb_shutdown() is waiting in:
flush_delayed_work(&wb->dwork);
the dwork can get executed after wb_shutdown() has finished and
bdi_unregister() has cleared wb->bdi->dev.
Make wb_workfn() use wakeup_wb() for requeueing the work which takes all
the necessary precautions against racing with bdi unregistration.
CC: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
CC: Tejun Heo <tj@...nel.org>
Fixes: 839a8e8660b6777e7fe4e80af1a048aebe2b5977
Reported-by: syzbot <syzbot+9873874c735f2892e7e9@...kaller.appspotmail.com>
Reviewed-by: Dave Chinner <dchinner@...hat.com>
Signed-off-by: Jan Kara <jack@...e.cz>
Signed-off-by: Jens Axboe <axboe@...nel.dk>
[bwh: Backported to 3.16:
- Use bdi_wakeup_thread() instead of wb_wakeup()
- Adjust context]
Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
---
fs/fs-writeback.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/fs/fs-writeback.c
+++ b/fs/fs-writeback.c
@@ -1071,7 +1071,7 @@ void bdi_writeback_workfn(struct work_st
}
if (!list_empty(&bdi->work_list))
- mod_delayed_work(bdi_wq, &wb->dwork, 0);
+ bdi_wakeup_thread(bdi);
else if (wb_has_dirty_io(wb) && dirty_writeback_interval)
bdi_wakeup_thread_delayed(bdi);
Powered by blists - more mailing lists