summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruenba@redhat.com>2025-08-06 23:34:03 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-29 14:08:52 +0100
commit279bde3bbb0ac0bad5c729dfa85983d75a5d7641 (patch)
tree85c3d5e51590d6b68b823ed873bdb303b9be0fc4 /fs
parentec2830217b1abc6f26268f49e7d39516e4a7d711 (diff)
downloadlinux-279bde3bbb0ac0bad5c729dfa85983d75a5d7641.tar.gz
linux-279bde3bbb0ac0bad5c729dfa85983d75a5d7641.tar.bz2
linux-279bde3bbb0ac0bad5c729dfa85983d75a5d7641.zip
gfs2: Fix unlikely race in gdlm_put_lock
[ Upstream commit 28c4d9bc0708956c1a736a9e49fee71b65deee81 ] In gdlm_put_lock(), there is a small window of time in which the DFL_UNMOUNT flag has been set but the lockspace hasn't been released, yet. In that window, dlm may still call gdlm_ast() and gdlm_bast(). To prevent it from dereferencing freed glock objects, only free the glock if the lockspace has actually been released. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Reviewed-by: Andrew Price <anprice@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/lock_dlm.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c
index 9e27dd8bef88..38ea69ca2303 100644
--- a/fs/gfs2/lock_dlm.c
+++ b/fs/gfs2/lock_dlm.c
@@ -321,12 +321,6 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT);
gfs2_update_request_times(gl);
- /* don't want to call dlm if we've unmounted the lock protocol */
- if (test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) {
- gfs2_glock_free(gl);
- return;
- }
-
/*
* When the lockspace is released, all remaining glocks will be
* unlocked automatically. This is more efficient than unlocking them
@@ -348,6 +342,11 @@ again:
goto again;
}
+ if (error == -ENODEV) {
+ gfs2_glock_free(gl);
+ return;
+ }
+
if (error) {
fs_err(sdp, "gdlm_unlock %x,%llx err=%d\n",
gl->gl_name.ln_type,