This is a note to let you know that I've just added the patch titled gfs2: Refcounting fix in gfs2_thaw_super to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: gfs2-refcounting-fix-in-gfs2_thaw_super.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit cac69531b06595b4fc0945bf6a8dd8348b7f119d Author: Andreas Gruenbacher <agruenba@xxxxxxxxxx> Date: Mon Dec 25 20:07:46 2023 +0100 gfs2: Refcounting fix in gfs2_thaw_super [ Upstream commit 4e58543e7da4859c4ba61d15493e3522b6ad71fd ] It turns out that the .freeze_super and .thaw_super operations require the filesystem to manage the superblock refcount itself. We are using the freeze_super() and thaw_super() helpers to mostly take care of that for us, but this means that the superblock may no longer be around by when thaw_super() returns, and gfs2_thaw_super() will then access freed memory. Take an extra superblock reference in gfs2_thaw_super() to fix that. Signed-off-by: Andreas Gruenbacher <agruenba@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index f9b47df485d17..aff8cdc61eff7 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -814,6 +814,7 @@ static int gfs2_thaw_super(struct super_block *sb) if (!test_bit(SDF_FREEZE_INITIATOR, &sdp->sd_flags)) goto out; + atomic_inc(&sb->s_active); gfs2_freeze_unlock(&sdp->sd_freeze_gh); error = gfs2_do_thaw(sdp); @@ -824,6 +825,7 @@ static int gfs2_thaw_super(struct super_block *sb) } out: mutex_unlock(&sdp->sd_freeze_mutex); + deactivate_super(sb); return error; }