mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Edward Adam Davis <eadavis@sina.com>
To: eadavis@sina.com
Cc: almaz.alexandrovich@paragon-software.com,
	linux-kernel@vger.kernel.org, ntfs3@lists.linux.dev,
	syzbot+d7aeb9ab7b1cc022914e@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: [PATCH v2] fs/ntfs3: reject remove procdir if create failure
Date: Fri, 27 Nov 2026 13:58:13 +0800	[thread overview]
Message-ID: <20261127055813.58182-1-eadavis@sina.com> (raw)
In-Reply-To: <20261126110326.39235-1-eadavis@sina.com>

"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@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d7aeb9ab7b1cc022914e
Signed-off-by: Edward Adam Davis <eadavis@sina.com>
---
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


      reply	other threads:[~2026-11-27  5:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 10:13 [syzbot] [ntfs3?] WARNING: proc registration bug in ntfs_put_super syzbot
2026-11-26 11:03 ` [PATCH] fs/ntfs3: reject remove procdir if create failure Edward Adam Davis
2026-11-27  5:58   ` Edward Adam Davis [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=20261127055813.58182-1-eadavis@sina.com \
    --to=eadavis@sina.com \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=syzbot+d7aeb9ab7b1cc022914e@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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®