From: Sukrut Heroorkar <hsukrut3@gmail.com>
To: Jan Kara <jack@suse.com>, linux-kernel@vger.kernel.org (open list)
Cc: shuah@kernel.org, david.hunter.linux@gmail.com,
Jan Kara <jack@suse.cz>,
syzbot+3ff7365dc04a6bcafa66@syzkaller.appspotmail.com,
syzbot+99bb36d7a3ea562b950e@syzkaller.appspotmail.com,
Sukrut Heroorkar <hsukrut3@gmail.com>
Subject: [PATCH 5.15.y 2/2] udf: Verify inode link counts before performing rename
Date: Tue, 25 Nov 2025 16:36:37 +0530 [thread overview]
Message-ID: <20251125110638.15758-3-hsukrut3@gmail.com> (raw)
In-Reply-To: <20251125110638.15758-1-hsukrut3@gmail.com>
From: Jan Kara <jack@suse.cz>
[ Upstream commit 6756af923e06aa33ad8894aaecbf9060953ba00f ]
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: syzbot+3ff7365dc04a6bcafa66@syzkaller.appspotmail.com
Signed-off-by: Jan Kara <jack@suse.cz>
Tested-by: syzbot+99bb36d7a3ea562b950e@syzkaller.appspotmail.com
Signed-off-by: Sukrut Heroorkar <hsukrut3@gmail.com>
---
fs/udf/namei.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index f4aded54a994..cb98f2d88f40 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -773,8 +773,18 @@ static int udf_rename(struct user_namespace *mnt_userns, 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,
--
2.43.0
prev parent reply other threads:[~2025-11-25 11:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 11:06 [PATCH 5.15.y 0/2] udf: backport udf_rename fixes to verify link-count Sukrut Heroorkar
2025-11-25 11:06 ` [PATCH 5.15.y 1/2] udf_rename(): only access the child content on cross-directory rename Sukrut Heroorkar
2025-11-25 11:06 ` Sukrut Heroorkar [this message]
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=20251125110638.15758-3-hsukrut3@gmail.com \
--to=hsukrut3@gmail.com \
--cc=david.hunter.linux@gmail.com \
--cc=jack@suse.com \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=syzbot+3ff7365dc04a6bcafa66@syzkaller.appspotmail.com \
--cc=syzbot+99bb36d7a3ea562b950e@syzkaller.appspotmail.com \
/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
all inboxes | Powered by JetHome®