Skip to content
Snippets Groups Projects
Commit 909a4cf1 authored by Andreas Dilger's avatar Andreas Dilger Committed by Theodore Ts'o
Browse files

ext4: avoid setting directory i_nlink to zero


If a directory with more than EXT4_LINK_MAX subdirectories, the nlink
count is set to 1.  Subsequently, if any subdirectories are deleted,
ext4_dec_count() decrements the i_nlink count, which may go to 0
temporarily before being incremented back to 1.

While this is done under i_mutex, which prevents races for directory
and inode operations that check i_nlink, the temporary i_nlink == 0
case is exposed to userspace via stat() and similar calls that do not
hold i_mutex.

Instead, change the code to not decrement i_nlink count for any
directories that do not already have i_nlink larger than 2.

Reported-by: default avatarCliff White <cliffw@whamcloud.com>
Reviewed-by: default avatarJohann Lombardi <johann@whamcloud.com>
Signed-off-by: default avatarAndreas Dilger <adilger@whamcloud.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
parent cf803903
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment