From: Jens Axboe <email@example.com> To: Dave Chinner <firstname.lastname@example.org>, Jan Kara <email@example.com> Cc: firstname.lastname@example.org, email@example.com, Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>, Tejun Heo <firstname.lastname@example.org> Subject: Re: [PATCH] bdi: Fix oops in wb_workfn() Date: Thu, 3 May 2018 15:57:42 -0600 [thread overview] Message-ID: <email@example.com> (raw) In-Reply-To: <20180503215558.GB10363@dastard> On 5/3/18 3:55 PM, Dave Chinner wrote: > On Thu, May 03, 2018 at 06:26:26PM +0200, Jan Kara wrote: >> 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@I-love.SAKURA.ne.jp> >> CC: Tejun Heo <firstname.lastname@example.org> >> Fixes: 839a8e8660b6777e7fe4e80af1a048aebe2b5977 >> Reported-by: syzbot <email@example.com> >> Signed-off-by: Jan Kara <firstname.lastname@example.org> >> --- >> fs/fs-writeback.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c >> index 47d7c151fcba..471d863958bc 100644 >> --- a/fs/fs-writeback.c >> +++ b/fs/fs-writeback.c >> @@ -1961,7 +1961,7 @@ void wb_workfn(struct work_struct *work) >> } >> >> if (!list_empty(&wb->work_list)) >> - mod_delayed_work(bdi_wq, &wb->dwork, 0); >> + wb_wakeup(wb); >> else if (wb_has_dirty_io(wb) && dirty_writeback_interval) >> wb_wakeup_delayed(wb); > > Yup, looks fine - I can't see any more of these open coded wakeup, > either, so we should be good here. > > Reviewed-by: Dave Chinner <email@example.com> > > As an aside, why is half the wb infrastructure in fs/fs-writeback.c > and the other half in mm/backing-dev.c? it seems pretty random as to > what is where e.g. wb_wakeup() and wb_wakeup_delayed() are almost > identical, but are in completely different files... That's always bothered me too, it's due for a cleanup and bringing it all into one location. -- Jens Axboe
next prev parent reply other threads:[~2018-05-03 21:57 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-03 16:26 Jan Kara 2018-05-03 21:55 ` Dave Chinner 2018-05-03 21:57 ` Jens Axboe [this message] 2018-05-09 9:48 ` Jan Kara 2018-05-03 22:35 ` Tetsuo Handa 2018-05-09 9:47 ` Jan Kara 2018-05-19 14:27 ` Tetsuo Handa 2018-05-21 9:38 ` Jan Kara 2018-05-25 10:15 ` Tetsuo Handa 2018-05-09 10:31 ` Jan Kara 2018-05-09 14:42 ` 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 \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --firstname.lastname@example.org \ --email@example.com \ --cc=penguin-kernel@I-love.SAKURA.ne.jp \ --firstname.lastname@example.org \ --subject='Re: [PATCH] bdi: Fix oops in wb_workfn()' \ /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
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).