Skip to content

Commit 28c4d9b

Browse files
author
Andreas Gruenbacher
committed
gfs2: Fix unlikely race in gdlm_put_lock
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>
1 parent 6ab2655 commit 28c4d9b

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

fs/gfs2/lock_dlm.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,6 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
344344
gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT);
345345
gfs2_update_request_times(gl);
346346

347-
/* don't want to call dlm if we've unmounted the lock protocol */
348-
if (test_bit(DFL_UNMOUNT, &ls->ls_recover_flags)) {
349-
gfs2_glock_free(gl);
350-
return;
351-
}
352-
353347
/*
354348
* When the lockspace is released, all remaining glocks will be
355349
* unlocked automatically. This is more efficient than unlocking them
@@ -379,6 +373,11 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
379373
goto again;
380374
}
381375

376+
if (error == -ENODEV) {
377+
gfs2_glock_free(gl);
378+
return;
379+
}
380+
382381
if (error) {
383382
fs_err(sdp, "gdlm_unlock %x,%llx err=%d\n",
384383
gl->gl_name.ln_type,

0 commit comments

Comments
 (0)