From: Al Viro <viro@zeniv.linux.org.uk>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>
Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
linux-kernel@vger.kernel.org,
Zhan Xusheng <zhanxusheng@xiaomi.com>
Subject: Re: [PATCH] fs/ntfs3: fix potential double iput on d_make_root() failure
Date: Sat, 4 Apr 2026 17:19:29 +0100 [thread overview]
Message-ID: <20260404161929.GQ3836593@ZenIV> (raw)
In-Reply-To: <20260326091232.92760-1-zhanxusheng@xiaomi.com>
On Thu, Mar 26, 2026 at 05:12:32PM +0800, Zhan Xusheng wrote:
> d_make_root() consumes the reference to the passed inode: it either
> attaches it to the newly created dentry on success, or drops it via
> iput() on failure.
>
> In the error path, the code currently does:
> sb->s_root = d_make_root(inode);
> if (!sb->s_root)
> goto put_inode_out;
>
> which leads to a second iput(inode) in put_inode_out. This results in
> a double iput and may trigger a use-after-free if the inode gets freed
> after the first iput().
>
> Fix this by jumping directly to the common cleanup path, avoiding the
> extra iput(inode).
Matter of fact, the whole put_inode_out should go; if you *ever* get
an inode with NULL ->i_op, it's a bug.
NULL should never be stored there; not even transiently. Yes, ntfs_read_mft()
_is_ bogus, as NTFS folks had been repeatedly told before, to no visible effect.
next prev parent reply other threads:[~2026-04-04 16:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-26 9:12 [PATCH] fs/ntfs3: fix potential double iput on d_make_root() failure Zhan Xusheng
2026-04-04 16:19 ` Al Viro [this message]
2026-04-07 17:23 ` Konstantin Komarov
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=20260404161929.GQ3836593@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=linux-kernel@vger.kernel.org \
--cc=zhanxusheng1024@gmail.com \
--cc=zhanxusheng@xiaomi.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