reiserfs: Fix use after free in journal teardown
authorJan Kara <jack@suse.cz>
Wed, 6 Aug 2014 17:43:56 +0000 (19:43 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 13 Sep 2014 22:41:44 +0000 (23:41 +0100)
commite1c88681a9d8b010813947745778cd557f83f0ab
tree1eeaf98b157f0fdd9f788534459e5714536231e6
parent67fddd870e5dfc50d104e721ceee13b01db93069
reiserfs: Fix use after free in journal teardown

commit 01777836c87081e4f68c4a43c9abe6114805f91e upstream.

If do_journal_release() races with do_journal_end() which requeues
delayed works for transaction flushing, we can leave work items for
flushing outstanding transactions queued while freeing them. That
results in use after free and possible crash in run_timers_softirq().

Fix the problem by not requeueing works if superblock is being shut down
(MS_ACTIVE not set) and using cancel_delayed_work_sync() in
do_journal_release().

Signed-off-by: Jan Kara <jack@suse.cz>
[bwh: Backported to 3.2:
 - Adjust context
 - commit_wq is global, not per-superblock
 - Change comment about 'these works'; we only have one work item
 - Drop inapplicable changes to reiserfs_schedule_old_flush()]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
fs/reiserfs/journal.c