[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240907172111.127817-1-ghanshyam1898@gmail.com>
Date: Sat, 7 Sep 2024 22:51:10 +0530
From: Ghanshyam Agrawal <ghanshyam1898@...il.com>
To: viro@...iv.linux.org.uk,
brauner@...nel.org,
jack@...e.cz
Cc: Ghanshyam Agrawal <ghanshyam1898@...il.com>,
linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
syzbot+41b43444de86db4c5ed1@...kaller.appspotmail.com
Subject: [PATCH] VFS: check i_nlink count before trying to unlink
Reported-by: syzbot+41b43444de86db4c5ed1@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=41b43444de86db4c5ed1
Signed-off-by: Ghanshyam Agrawal <ghanshyam1898@...il.com>
---
fs/namei.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/namei.c b/fs/namei.c
index 5512cb10fa89..9e5214dfd05d 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -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);
--
2.34.1
Powered by blists - more mailing lists