[PATCH v2] fs/ntfs3: reject remove procdir if create failure

From: Edward Adam Davis

Date: Fri Nov 27 2026 - 00:58:31 EST


"volinfo" and "label" without checking whether proc_create_data() return
NULL in ntfs_create_procdir() and set sbi->procdir = e, potentially
hitting a warning in remove_proc_entry() for remove the label dir entry.

Add a check for label and volinfo when create the proc dir entry.

Fixes: 7832e123490a ("fs/ntfs3: Add support /proc/fs/ntfs3/<dev>/volinfo and /proc/fs/ntfs3/<dev>/label")
Reported-by: syzbot+d7aeb9ab7b1cc022914e@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=d7aeb9ab7b1cc022914e
Signed-off-by: Edward Adam Davis <eadavis@xxxxxxxx>
---
v1 -> v2:
1. add missing volinfo release if lable create failure
2. return after set procdir

fs/ntfs3/super.c | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 29aabdc8a801..a71628b9489e 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -626,18 +626,30 @@ static const struct proc_ops ntfs3_label_fops = {
static void ntfs_create_procdir(struct super_block *sb)
{
struct proc_dir_entry *e;
+ struct ntfs_sb_info *sbi;

if (!proc_info_root)
return;

e = proc_mkdir(sb->s_id, proc_info_root);
if (e) {
- struct ntfs_sb_info *sbi = sb->s_fs_info;
+ sbi = sb->s_fs_info;
+
+ if (!proc_create_data("volinfo", 0444, e,
+ &ntfs3_volinfo_fops, sb))
+ goto out;
+
+ if (!proc_create_data("label", 0644, e, &ntfs3_label_fops, sb))
+ goto out_volinfo;

- proc_create_data("volinfo", 0444, e, &ntfs3_volinfo_fops, sb);
- proc_create_data("label", 0644, e, &ntfs3_label_fops, sb);
sbi->procdir = e;
}
+
+ return;
+out_volinfo:
+ remove_proc_entry("volinfo", sbi->procdir);
+out:
+ remove_proc_entry(sb->s_id, proc_info_root);
}

static void ntfs_remove_procdir(struct super_block *sb)
--
2.43.0