• npiggin@suse.de's avatar
    fs: fix superblock iteration race · 57439f87
    npiggin@suse.de authored
    list_for_each_entry_safe is not suitable to protect against concurrent
    modification of the list. 6754af64 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: default avatarNick Piggin <npiggin@suse.de>
    Cc: Christoph Hellwig <hch@infradead.org>
    Cc: John Stultz <johnstul@us.ibm.com>
    Cc: Frank Mayhar <fmayhar@google.com>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    57439f87
super.c 24.8 KB