All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Miklos Szeredi" <mszeredi@redhat.com>, virtualization@lists.linux.dev
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
	"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH v2 4/4] virtiofs: fix forget leak on submount unmount
Date: Mon, 30 Nov 2026 14:54:34 +0000	[thread overview]
Message-ID: <sashiko-outbox-241441@kernel.org> (raw)
In-Reply-To: <20261130143728.326871-4-mszeredi@redhat.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] fuse: forget leak and premature FORGET in fuse_evict_inode()
  on failed mount
--

commit 6888c05c6b67c7c443bc776bdec5c1257aae460e
Author: Miklos Szeredi <mszeredi@redhat.com>

virtiofs: fix forget leak on submount unmount

This commit moves the queuing of fi->forget and cleanup of
fi->submount_lookup in fuse_evict_inode() outside the SB_ACTIVE check so
that submount unmounts do not skip them.

> diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
> index eff1c05681e6b..613c203dcd506 100644
> --- a/fs/fuse/inode.c
> +++ b/fs/fuse/inode.c
> @@ -141,6 +141,7 @@ static void fuse_cleanup_submount_lookup(struct fuse_conn *fc,
>  static void fuse_evict_inode(struct inode *inode)
>  {
>  	struct fuse_inode *fi = get_fuse_inode(inode);
> +	struct fuse_conn *fc = get_fuse_conn(inode);
>  
>  	/* Will write inode on close/munmap and in all other dirtiers */
>  	WARN_ON(inode_state_read_once(inode) & I_DIRTY_INODE);
> @@ -157,19 +158,27 @@ static void fuse_evict_inode(struct inode *inode)
>  	 */
>  	if (FUSE_IS_VDAX(inode))
>  		fuse_vdax_inode_cleanup(inode);
> -	if (inode->i_sb->s_flags & SB_ACTIVE) {
> -		struct fuse_conn *fc = get_fuse_conn(inode);
> +	/*
> +	 * Must be done unconditionally as well: on a submount unmount the
> +	 * connection stays alive and no FUSE_DESTROY is sent, so without
> +	 * this the server keeps the lookup counts of every inode in the
> +	 * submount for the lifetime of the connection.  The
> +	 * fuse_submount_lookup object is freed nowhere else, so skipping it
> +	 * leaks that too.  If the connection is already gone (full unmount,
> +	 * failed mount) fuse_chan_queue_forget() just frees the forget.
> +	 */
> +	if (fi->nlookup) {
> +		fuse_chan_queue_forget(fc->chan, fi->forget, fi->nodeid,
> +				       fi->nlookup);
> +		fi->forget = NULL;
> +	}

[Severity: Medium]
Does this leak fi->forget when fuse_fill_super_common() fails after
allocating the root inode?

In fuse_fill_super_common(), fuse_get_root_inode() creates the root inode
with fi->nlookup = 1 while sb->s_root is still NULL and
fc->chan->iq.connected is already 1.  If d_make_root(),
fuse_dev_is_installed(), or fuse_ctl_add_conn() then fails, evicting the
root inode queues fi->forget onto fc->chan->iq.forget_list_tail and clears
fi->forget = NULL instead of letting fuse_free_inode() free it.  During
superblock teardown, fuse_sb_destroy() skips fuse_conn_destroy() and
fuse_chan_abort() because sb->s_root is NULL:

fs/fuse/inode.c:fuse_sb_destroy() {
	...
	if (sb->s_root) {
		last = fuse_mount_remove(fm);
		if (last)
			fuse_conn_destroy(fm);
	}
}

As a result, fi->forget is never drained from forget_list_head before
fc->chan is freed.  On virtiofs, where the virtqueues are already
connected at probe time, the same failure path sends a FUSE_FORGET for
FUSE_ROOT_ID to the server before FUSE_INIT.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130143728.326871-1-mszeredi@redhat.com?part=4

  reply	other threads:[~2026-11-30 14:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 14:37 [PATCH v2 1/4] virtiofs: fix DAX range leak on unmount Miklos Szeredi
2026-11-30 14:37 ` [PATCH v2 2/4] virtiofs: don't abort DAX removemapping on allocation failure Miklos Szeredi
2026-12-01  8:11   ` Li Wang
2026-12-01  9:03     ` Miklos Szeredi
2026-11-30 14:37 ` [PATCH v2 3/4] virtiofs: retry request submission from the worker on -ENOMEM Miklos Szeredi
2026-11-30 14:37 ` [PATCH v2 4/4] virtiofs: fix forget leak on submount unmount Miklos Szeredi
2026-11-30 14:54   ` sashiko-bot [this message]
2026-11-30 14:54 ` [PATCH v2 1/4] virtiofs: fix DAX range leak on unmount sashiko-bot

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=sashiko-outbox-241441@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=eperezma@redhat.com \
    --cc=mst@redhat.com \
    --cc=mszeredi@redhat.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=virtualization@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.