Linux virtualization list
 help / color / mirror / Atom feed
* [PATCH 1/5] virtiofs: fix DAX range leak on unmount
@ 2026-11-26 14:47 Miklos Szeredi
  2026-11-26 14:47 ` [PATCH 2/5] virtiofs: don't abort DAX removemapping on allocation failure Miklos Szeredi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Miklos Szeredi @ 2026-11-26 14:47 UTC (permalink / raw)
  To: fuse-devel, virtualization; +Cc: Li Wang, German Maglione, Stefan Hajnoczi

generic_shutdown_super() clears SB_ACTIVE before calling evict_inodes(),
so at unmount time fuse_evict_inode() skipped fuse_vdax_inode_cleanup()
for every remaining inode.  The DAX ranges owned by those inodes stay on
fc->vdax->busy_ranges instead of being returned to the free pool, and
fuse_vdax_conn_free() only frees free_ranges before kfree()ing the
connection, so the busy fuse_dax_mapping objects are leaked.  Nothing
warns about it: fuse_free_inode() kfree()s fi->vdax without checking
that the interval tree is empty.

Call fuse_vdax_inode_cleanup() regardless of SB_ACTIVE.  That is what
virtio_fs_conn_destroy() has always assumed ("Soon evict_inodes() will
be called which will free all memory ranges belonging to all inodes").
Unlike the FORGET in the same block, which is pointless once DESTROY has
been sent, the DAX cleanup is the only thing there that owns memory.

On a full unmount virtio_fs_conn_destroy() has already run by the time
evict_inodes() is called, so the FUSE_REMOVEMAPPING requests sent by
fuse_vdax_inode_cleanup() fail with -ENOTCONN, which
inode_reclaim_dmap_range() ignores.  On a submount unmount the
connection is still alive and those requests are both valid and needed.

Fixes: c2d0ad00d948 ("virtiofs: implement dax read/write operations")
Cc: <stable@vger.kernel.org>
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/bug/linux-3b38f8c0-5e4a-4c21-87a6-4f96cc3cf147
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 fs/fuse/inode.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index 20fbc99f3590..344fcb55a64b 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -150,11 +150,16 @@ static void fuse_evict_inode(struct inode *inode)
 
 	truncate_inode_pages_final(&inode->i_data);
 	clear_inode(inode);
+	/*
+	 * Must be done unconditionally: the DAX ranges owned by this inode
+	 * are freed nowhere else, so skipping this on an inactive
+	 * superblock would leak them.
+	 */
+	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);
 
-		if (FUSE_IS_VDAX(inode))
-			fuse_vdax_inode_cleanup(inode);
 		if (fi->nlookup) {
 			fuse_chan_queue_forget(fc->chan, fi->forget, fi->nodeid,
 					       fi->nlookup);
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-26 14:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 14:47 [PATCH 1/5] virtiofs: fix DAX range leak on unmount Miklos Szeredi
2026-11-26 14:47 ` [PATCH 2/5] virtiofs: don't abort DAX removemapping on allocation failure Miklos Szeredi
2026-11-26 14:47 ` [PATCH 3/5] virtiofs: retry request submission from the worker on -ENOMEM Miklos Szeredi
2026-11-26 14:47 ` [PATCH 4/5] virtiofs: abort the connection if the server fails to unmap a DAX range Miklos Szeredi
2026-11-26 14:47 ` [PATCH 5/5] virtiofs: fix forget leak on submount unmount Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox