vfs: Do not allow underflowing of i_nlink
Jan Kara
reviewerPATCH 1/1 vfs: Do not allow underflowing of i_nlink
Currently, drop_nlink() warns when i_nlink underflows but it still lets the value underflow. Granted such underflow means filesystem corruption so we are screwed but still it limits the damage more if we leave i_nlink at 0 to keep inode in "unlinked" state instead of letting it magically appear linked again which confuses filesystems even more.
For example this would make b50282f3241a "ext4: check to make sure the rename(2)'s destination is not freed" just a cosmetic fix instead of a memory-corruption fix.
CC Theodore Ts'o <[email protected]>
CC Miklos Szeredi <[email protected]>
Signed-off-by Jan Kara <[email protected]>
--- fs/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/inode.c +2 -1
@@ -282,7 +282,8 @@ static void destroy_inode(struct inode *inode)*/ void drop_nlink (struct inode *inode) { -WARN_ON (inode->i_nlink ==0 ); +if (WARN_ON (inode->i_nlink ==0 )) +return ; inode->__i_nlink--;if (!inode->i_nlink)atomic_long_inc (&inode->i_sb->s_remove_count);
Signature · 1 line
2.16.4