From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Farhad Alemi <farhad.alemi@berkeley.edu>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>
Cc: falemi@asu.edu, ocfs2-devel@lists.linux.dev,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
linux-fsdevel@vger.kernel.org, Jaegeuk Kim <jaegeuk@kernel.org>,
Chao Yu <chao@kernel.org>,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ocfs2: don't let the root inode outlive a failed mount
Date: Mon, 14 Sep 2026 13:53:02 +0800 [thread overview]
Message-ID: <c11b5a78-a1d7-4618-beab-dda967863f50@linux.alibaba.com> (raw)
In-Reply-To: <CA+0ovChT6BRXp0kntaJ_Eiw-2-z=fpofsvyALiwdORe3zG_YWA@mail.gmail.com>
On 9/11/26 5:47 AM, Farhad Alemi wrote:
> ocfs2_init_global_system_inodes() installs osb->root_inode before the
> second ocfs2_iget() runs, and when that iget fails ocfs2_initialize_super()
> jumps to out_dlm_out, which sits below out_system_inodes, so
> ocfs2_release_system_inodes() never runs and the kfree(osb) that follows
> makes the stranded root inode reference unreachable. ocfs2_fill_super()
> strands the same inode a second way: nothing drops the reference igrab()
> takes on osb->root_inode when an out_dismount path ahead of d_make_root()
> is taken, so the ocfs2_release_system_inodes() call inside
> ocfs2_dismount_volume() cannot free it and the root inode stays hashed on a
> superblock whose ocfs2_super has already been freed. The reported KASAN
> slab-use-after-free write hits an ocfs2_inode_cache object that
> ocfs2_release_system_inodes() freed during teardown, so an ocfs2 inode
> reference that survives that call is a lifetime error on those same objects
> and not a bare leak. Release the system inodes at that failing
> ocfs2_iget() and drop the igrab() reference on out_dismount, clearing inode
> right after d_make_root(), which consumes it on success and on failure
> alike, so it cannot be dropped twice.
>
> Closes: https://lore.kernel.org/all/CA+0ovCjAKQMn7iF8BJR-3+G9_HBRnRFtJxjr-9P9GuKSxFj+3Q@mail.gmail.com/
> Signed-off-by: Farhad Alemi <farhad.alemi@berkeley.edu>
> ---
> --- a/fs/ocfs2/super.c
> +++ b/fs/ocfs2/super.c
Seems it is a corrupt patch?
> @@ -450,6 +450,7 @@ static int ocfs2_init_global_system_inodes(struct
> ocfs2_super *osb)
> if (IS_ERR(new)) {
> status = PTR_ERR(new);
> mlog_errno(status);
> + ocfs2_release_system_inodes(osb);
> goto bail;
> }
> osb->sys_root_inode = new;
> @@ -1110,6 +1111,8 @@ static int ocfs2_fill_super(struct super_block
> *sb, struct fs_context *fc)
> }
>
> root = d_make_root(inode);
> + /* d_make_root() consumed our reference, on success and on failure. */
> + inode = NULL;
> if (!root) {
> status = -ENOMEM;
> goto out_dismount;
> @@ -1163,6 +1166,7 @@ out_dismount:
> atomic_set(&osb->vol_state, VOLUME_DISABLED);
> wake_up(&osb->osb_mount_event);
> ocfs2_free_replay_slots(osb);
Please rebase on top of the latest linux-next.
The above 'ocfs2_free_replay_slots(osb)' is removed.
Thanks,
Joseph
> + iput(inode);
> ocfs2_dismount_volume(sb, 1);
> goto out;
prev parent reply other threads:[~2026-09-14 5:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 21:47 Farhad Alemi
2026-09-14 5:53 ` Joseph Qi [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=c11b5a78-a1d7-4618-beab-dda967863f50@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=brauner@kernel.org \
--cc=chao@kernel.org \
--cc=falemi@asu.edu \
--cc=farhad.alemi@berkeley.edu \
--cc=jaegeuk@kernel.org \
--cc=jlbec@evilplan.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
--cc=viro@zeniv.linux.org.uk \
/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®