mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hongling Zeng <zenghongling@kylinos.cn>
To: linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
	zhongling0719@126.com, Hongling Zeng <zenghongling@kylinos.cn>,
	stable@vger.kernel.org
Subject: [PATCH v3 3/3] ntfs: NULL vol->vol_ino in the load_system_files() error teardown
Date: Wed,  9 Sep 2026 10:48:03 +0800	[thread overview]
Message-ID: <20260909024803.810556-4-zenghongling@kylinos.cn> (raw)
In-Reply-To: <20260909024803.810556-1-zenghongling@kylinos.cn>

The error unwind of load_system_files() drops vol->vol_ino on two
paths but leaves the stale pointer in place while it keeps iput()ing
the remaining system inodes ($Bitmap, $MFT bitmap, $MFTMirr; $MFT
itself is dropped by the caller, ntfs_fill_super()).  A third path
carried an iput() that can never execute: it sits inside the
IS_ERR(vol->vol_ino) branch guarded by !IS_ERR(vol->vol_ino), and is
removed along with the stale pointers.  Nothing in the teardown
dereferences vol_ino today, so this is pure hygiene, but a stale
pointer to a freed inode surviving the unwind is a trap for any
future code walking the volume during teardown.

ntfs_put_super() and the ntfs_fill_super() error path already NULL it
after their iput(); do the same here.

Cc: stable@vger.kernel.org
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
 fs/ntfs/super.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
index 4b4af1ea8b09..2d4132aa39d3 100644
--- a/fs/ntfs/super.c
+++ b/fs/ntfs/super.c
@@ -1541,8 +1541,7 @@ static bool load_system_files(struct ntfs_volume *vol)
 	 */
 	vol->vol_ino = ntfs_iget(sb, FILE_Volume);
 	if (IS_ERR(vol->vol_ino)) {
-		if (!IS_ERR(vol->vol_ino))
-			iput(vol->vol_ino);
+		vol->vol_ino = NULL;
 volume_failed:
 		ntfs_error(sb, "Failed to load $Volume.");
 		goto iput_lcnbmp_err_out;
@@ -1551,6 +1550,7 @@ static bool load_system_files(struct ntfs_volume *vol)
 	if (IS_ERR(m)) {
 iput_volume_failed:
 		iput(vol->vol_ino);
+		vol->vol_ino = NULL;
 		goto volume_failed;
 	}
 
@@ -1716,6 +1716,8 @@ static bool load_system_files(struct ntfs_volume *vol)
 	if (vol->logfile_ino)
 		iput(vol->logfile_ino);
 	iput(vol->vol_ino);
+	/* Do not leave a stale pointer behind for the rest of the teardown. */
+	vol->vol_ino = NULL;
 iput_lcnbmp_err_out:
 	iput(vol->lcnbmp_ino);
 iput_attrdef_err_out:
-- 
2.25.1


  parent reply	other threads:[~2026-09-09  2:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  2:48 [PATCH v4 0/4] ntfs: fix volume flag update races and persist the recorded error state Hongling Zeng
2026-09-09  2:48 ` [PATCH v4 1/4] ntfs: fix volume flag update races Hongling Zeng
2026-09-09  2:48 ` [PATCH v3 2/3] ntfs: sync the volume dirty bit with the recorded error state Hongling Zeng
2026-09-09  2:48 ` Hongling Zeng [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-09-07  7:08 [PATCH v3 0/3] ntfs: fix volume flag update races and persist " Hongling Zeng
2026-09-07  7:08 ` [PATCH v3 3/3] ntfs: NULL vol->vol_ino in the load_system_files() error teardown Hongling Zeng
2026-09-08  4:38   ` liubaolin
2026-09-08  9:42   ` Namjae Jeon
2026-09-07  6:22 [PATCH v3 0/3] ntfs: fix volume flag update races and persist the recorded error state Hongling Zeng
2026-09-07  6:22 ` [PATCH v3 3/3] ntfs: NULL vol->vol_ino in the load_system_files() error teardown Hongling Zeng

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=20260909024803.810556-4-zenghongling@kylinos.cn \
    --to=zenghongling@kylinos.cn \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=zhongling0719@126.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®