diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2023-12-25 20:07:46 +0100 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2023-12-27 13:16:48 +0100 |
commit | 4e58543e7da4859c4ba61d15493e3522b6ad71fd (patch) | |
tree | a3213c9193b3bbf4f1df7105f469282fe325baa4 /fs/gfs2 | |
parent | 5a7a964689b78be5817f14409619fded6882821d (diff) | |
download | lwn-4e58543e7da4859c4ba61d15493e3522b6ad71fd.tar.gz lwn-4e58543e7da4859c4ba61d15493e3522b6ad71fd.zip |
gfs2: Refcounting fix in gfs2_thaw_super
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@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/super.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 6b45b7866212..ae92ae1203d8 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -819,6 +819,7 @@ static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who) return -EINVAL; } + atomic_inc(&sb->s_active); gfs2_freeze_unlock(&sdp->sd_freeze_gh); error = gfs2_do_thaw(sdp); @@ -828,6 +829,7 @@ static int gfs2_thaw_super(struct super_block *sb, enum freeze_holder who) clear_bit(SDF_FROZEN, &sdp->sd_flags); } mutex_unlock(&sdp->sd_freeze_mutex); + deactivate_super(sb); return error; } |