[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241202004104.20604-2-leocstone@gmail.com>
Date: Sun, 1 Dec 2024 16:41:02 -0800
From: Leo Stone <leocstone@...il.com>
To: syzbot+5df2d3fa14f2d3e49305@...kaller.appspotmail.com,
jack@...e.com
Cc: Leo Stone <leocstone@...il.com>,
linux-kernel@...r.kernel.org
Subject: [PATCH] udf: Prevent rmdir of deleted directories
The syzbot reproducer mounts a UDF image with the undelete option
enabled. It then creates a directory, and eventually attempts to call
rmdir on it 65 times. Because the undelete option is set, the
directory still gets found in udf_fiiter_find_entry(), and the link
count of its parent directory is decremented until it triggers the
warning in drop_nlink().
Prevent directories with the FID_FILE_CHAR_DELETED flag set from being
deleted again.
#syz test
Reported-by: syzbot+5df2d3fa14f2d3e49305@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5df2d3fa14f2d3e49305
Signed-off-by: Leo Stone <leocstone@...il.com>
---
fs/udf/namei.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 78a603129dd5..0a577b7459de 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -504,6 +504,12 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
if (ret)
goto out;
+ if (iter.fi.fileCharacteristics & FID_FILE_CHAR_DELETED) {
+ udf_warn(inode->i_sb,
+ "tried to rmdir a directory that was already deleted\n");
+ ret = -ENOENT;
+ goto end_rmdir;
+ }
ret = -EFSCORRUPTED;
tloc = lelb_to_cpu(iter.fi.icb.extLocation);
if (udf_get_lb_pblock(dir->i_sb, &tloc, 0) != inode->i_ino)
--
2.43.0
Powered by blists - more mailing lists