mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
fs: fix superblock iteration race
list_for_each_entry_safe is not suitable to protect against concurrent
modification of the list. 6754af6 introduced a race in sb walking.
list_for_each_entry can use the trick of pinning the current entry in
the list before we drop and retake the lock because it subsequently
follows cur->next. However list_for_each_entry_safe saves n=cur->next
for following before entering the loop body, so when the lock is
dropped, n may be deleted.
Signed-off-by: Nick Piggin <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: John Stultz <[email protected]>
Cc: Frank Mayhar <[email protected]>
Cc: Al Viro <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
5904b3b81d
commit
57439f878a
3 changed files with 23 additions and 0 deletions
|
|
@ -590,6 +590,8 @@ static void prune_dcache(int count)
|
|||
up_read(&sb->s_umount);
|
||||
}
|
||||
spin_lock(&sb_lock);
|
||||
/* lock was dropped, must reset next */
|
||||
list_safe_reset_next(sb, n, s_list);
|
||||
count -= pruned;
|
||||
__put_super(sb);
|
||||
/* more work left to do? */
|
||||
|
|
|
|||
Loading…
Reference in a new issue