Skip to content

Commit e3a43f2

Browse files
gkurzMiklos Szeredi
authored andcommitted
fuse: Fix crash if superblock of submount gets killed early
As soon as fuse_dentry_automount() does up_write(&sb->s_umount), the superblock can theoretically be killed. If this happens before the submount was added to the &fc->mounts list, fuse_mount_remove() later crashes in list_del_init() because it assumes the submount to be already there. Add the submount before dropping sb->s_umount to fix the inconsistency. It is okay to nest fc->killsb under sb->s_umount, we already do this on the ->kill_sb() path. Signed-off-by: Greg Kurz <groug@kaod.org> Fixes: bf109c6 ("fuse: implement crossmounts") Cc: stable@vger.kernel.org # v5.10+ Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent d92d88f commit e3a43f2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎fs/fuse/dir.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,15 +346,15 @@ static struct vfsmount *fuse_dentry_automount(struct path *path)
346346
goto out_put_sb;
347347
}
348348

349+
down_write(&fc->killsb);
350+
list_add_tail(&fm->fc_entry, &fc->mounts);
351+
up_write(&fc->killsb);
352+
349353
sb->s_flags |= SB_ACTIVE;
350354
fsc->root = dget(sb->s_root);
351355
/* We are done configuring the superblock, so unlock it */
352356
up_write(&sb->s_umount);
353357

354-
down_write(&fc->killsb);
355-
list_add_tail(&fm->fc_entry, &fc->mounts);
356-
up_write(&fc->killsb);
357-
358358
/* Create the submount */
359359
mnt = vfs_create_mount(fsc);
360360
if (IS_ERR(mnt)) {

0 commit comments

Comments
 (0)