Skip to content

Commit

Permalink
udf: Verify inode link counts before performing rename
Browse files Browse the repository at this point in the history
During rename, we are updating link counts of various inodes either when
rename deletes target or when moving directory across directories.
Verify involved link counts are sane so that we don't trip warnings in
VFS.

Reported-by: [email protected]
Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
jankara committed Nov 26, 2024
1 parent c556690 commit 6756af9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fs/udf/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,18 @@ static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
retval = -ENOTEMPTY;
if (!empty_dir(new_inode))
goto out_oiter;
retval = -EFSCORRUPTED;
if (new_inode->i_nlink != 2)
goto out_oiter;
}
retval = -EFSCORRUPTED;
if (old_dir->i_nlink < 3)
goto out_oiter;
is_dir = true;
} else if (new_inode) {
retval = -EFSCORRUPTED;
if (new_inode->i_nlink < 1)
goto out_oiter;
}
if (is_dir && old_dir != new_dir) {
retval = udf_fiiter_find_entry(old_inode, &dotdot_name,
Expand Down

0 comments on commit 6756af9

Please sign in to comment.