VFS: check i_nlink count before trying to unlink
PATCH 1/1 VFS: check i_nlink count before trying to unlink
Reported-by [email protected]
Signed-off-by Ghanshyam Agrawal <[email protected]>
--- fs/namei.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/namei.c +2 -1
@@ -4419,7 +4419,8 @@ int vfs_unlink(struct mnt_idmap *idmap, struct inode *dir, error =try_break_deleg (target, delegated_inode);if (error) goto out; - error = dir->i_op->unlink (dir, dentry); +if (dentry->d_inode->i_nlink) + error = dir->i_op->unlink (dir, dentry);if (!error) {dont_mount (dentry);detach_mounts (dentry);
Signature · 1 line
2.34.1
Al Viro
maintainerQuoted 3 lines · Ghanshyam Agrawal
Reported-by [email protected]Signed-off-by Ghanshyam Agrawal <[email protected]>
As far as I can tell, you have jfs_unlink() find and remove a directory entry without any problems, then find that the damn thing had corrupted inode link count (presumably due to creatively fucked up image).
IF that's the case, NAK.
vfs_unlink() is *NOT* the place to try and cope with that kind of crap. What's more, having unlink(2) quietly succeed and do nothing to directory is simply wrong.