Skip to content

Commit

Permalink
ocfs2: fix NULL pointer dereference when dismount and ocfs2rec simult…
Browse files Browse the repository at this point in the history
…aneously

2 nodes cluster, say Node A and Node B, mount the same ocfs2 volume, and
create a file 1.

Node A			Node B
open 1, get open lock
                        rm 1, and then add 1 to orphan_dir
storage link down,
o2hb_write_timeout
->o2quo_disk_timeout
->emergency_restart
                        at the moment, Node B dismount and do
			ocfs2rec simultaneously
                        1) ocfs2_dismount_volume
			->ocfs2_recovery_exit
			->wait_event(osb->recovery_event)
			->flush_workqueue(ocfs2_wq)
			2) ocfs2rec
			->queue_work(&journal->j_recovery_work)
                        ->ocfs2_recover_orphans
			->ocfs2_commit_truncate
                        ->queue_delayed_work(&osb->osb_truncate_log_wq)

In ocfs2_recovery_exit, it flushes workqueue and then releases system
inodes.  When doing ocfs2rec, it will call ocfs2_flush_truncate_log
which will try to get sys_root_inode, and NULL pointer dereference
occurs.

Signed-off-by: Yiwen Jiang <[email protected]>
Signed-off-by: joyce <[email protected]>
Signed-off-by: Joseph Qi <[email protected]>
Cc: Joel Becker <[email protected]>
Cc: Mark Fasheh <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jiangyiwen123 authored and torvalds committed Jan 22, 2014
1 parent a2a3b39 commit 75f82ea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/ocfs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1945,11 +1945,15 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)

ocfs2_shutdown_local_alloc(osb);

ocfs2_truncate_log_shutdown(osb);

/* This will disable recovery and flush any recovery work. */
ocfs2_recovery_exit(osb);

/*
* During dismount, when it recovers another node it will call
* ocfs2_recover_orphans and queue delayed work osb_truncate_log_wq.
*/
ocfs2_truncate_log_shutdown(osb);

ocfs2_journal_shutdown(osb);

ocfs2_sync_blockdev(sb);
Expand Down

0 comments on commit 75f82ea

Please sign in to comment.