Skip to content

Commit 2b99e41

Browse files
chenglin130Chandan Babu R
authored andcommitted
xfs: introduce protection for drop nlink
When abnormal drop_nlink are detected on the inode, return error, to avoid corruption propagation. Signed-off-by: Cheng Lin <[email protected]> Reviewed-by: "Darrick J. Wong" <[email protected]> Signed-off-by: Chandan Babu R <[email protected]>
1 parent 9fa8753 commit 2b99e41

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/xfs/xfs_inode.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -918,6 +918,13 @@ xfs_droplink(
918918
xfs_trans_t *tp,
919919
xfs_inode_t *ip)
920920
{
921+
if (VFS_I(ip)->i_nlink == 0) {
922+
xfs_alert(ip->i_mount,
923+
"%s: Attempt to drop inode (%llu) with nlink zero.",
924+
__func__, ip->i_ino);
925+
return -EFSCORRUPTED;
926+
}
927+
921928
xfs_trans_ichgtime(tp, ip, XFS_ICHGTIME_CHG);
922929

923930
drop_nlink(VFS_I(ip));

0 commit comments

Comments
 (0)