From: Ghanshyam Agrawal <ghanshyam1898@gmail.com>
To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz
Cc: Ghanshyam Agrawal <ghanshyam1898@gmail.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+41b43444de86db4c5ed1@syzkaller.appspotmail.com
Subject: [PATCH] VFS: check i_nlink count before trying to unlink
Date: Sat, 7 Sep 2024 22:51:10 +0530 [thread overview]
Message-ID: <20240907172111.127817-1-ghanshyam1898@gmail.com> (raw)
Reported-by: syzbot+41b43444de86db4c5ed1@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=41b43444de86db4c5ed1
Signed-off-by: Ghanshyam Agrawal <ghanshyam1898@gmail.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
next reply other threads:[~2024-09-07 17:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-07 17:21 Ghanshyam Agrawal [this message]
2024-09-07 19:02 ` [PATCH] VFS: check i_nlink count before trying to unlink Al Viro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240907172111.127817-1-ghanshyam1898@gmail.com \
--to=ghanshyam1898@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+41b43444de86db4c5ed1@syzkaller.appspotmail.com \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).