From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA0F5344DB9; Sat, 30 May 2026 17:44:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780163043; cv=none; b=ZCzLiPxJIHbe/0DAiXZS/5Ud3qCIDU0kdA4qjRtM4/R3FDCNmzIIpejIl1QZF80tOPtrlzI3JVidxQm1yVEDLnnB8WLJZSBD2LL7/SZkiFdOCL291eNLMLryYxI1exTJCuNOzuofUFNaKeaCoSM04/COLlSUMLx3CKujRQVNSuo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780163043; c=relaxed/simple; bh=UOnqJVOhznpJFmtkTcXQ/jGnvr7t4U8RT7kuzSeluOw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O6A7ZFBQHaDnjTem7Rl7wc6TIx3VUuqNldKCYjJ1s5GDRjyvfk2JoKkIkQerFAddsevX0Qok+hJdNiSalbzYSrxZo4tKRP0YRzFoh9HHaZS208mp4eqrFDcqQgxzX8fDfnbmIf44rcZCA6KBol+mPORAMuaXgZgqCM/OffYE8/g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=MzZ4KL76; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="MzZ4KL76" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EF0071F00893; Sat, 30 May 2026 17:44:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780163042; bh=cWUuSyR5bQacNoQSNtB1MYqGVAspYcYfQ/2AxukaTVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MzZ4KL76fCJ6tTpTjWtERWUsAky+nrTUX7eEjIDaK94vxqizxWR1G4D132cHNYgCf WS49hzBttDVSTIjrUaex6PgODi4m1Cf2SrTf3dseONIKwKZ/3KpmDSShBN/7F5Lb3Y jrvB8Rdx6ilEL0x2cTYyLWk9Ah+ejSOnKBqRtykk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chunjie Zhu , Andreas Gruenbacher , Johnny Hao Subject: [PATCH 5.15 138/776] gfs2: No more self recovery Date: Sat, 30 May 2026 17:57:32 +0200 Message-ID: <20260530160243.976017270@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160240.228940103@linuxfoundation.org> References: <20260530160240.228940103@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Andreas Gruenbacher [ Upstream commit deb016c1669002e48c431d6fd32ea1c20ef41756 ] When a node withdraws and it turns out that it is the only node that has the filesystem mounted, gfs2 currently tries to replay the local journal to bring the filesystem back into a consistent state. Not only is that a very bad idea, it has also never worked because gfs2_recover_func() will refuse to do anything during a withdraw. However, before even getting to this point, gfs2_recover_func() dereferences sdp->sd_jdesc->jd_inode. This was a use-after-free before commit 04133b607a78 ("gfs2: Prevent double iput for journal on error") and is a NULL pointer dereference since then. Simply get rid of self recovery to fix that. Fixes: 601ef0d52e96 ("gfs2: Force withdraw to replay journals and wait for it to finish") Reported-by: Chunjie Zhu Signed-off-by: Andreas Gruenbacher [ The context change is due to the commit f80d882edcf2 ("gfs2: Get rid of gfs2_glock_queue_put in signal_our_withdraw") in v6.10 which is irrelevant to the logic of this patch. ] Signed-off-by: Johnny Hao Signed-off-by: Greg Kroah-Hartman --- fs/gfs2/util.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) --- a/fs/gfs2/util.c +++ b/fs/gfs2/util.c @@ -234,31 +234,23 @@ static void signal_our_withdraw(struct g */ ret = gfs2_glock_nq(&sdp->sd_live_gh); + gfs2_glock_put(live_gl); /* drop extra reference we acquired */ + clear_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags); + /* * If we actually got the "live" lock in EX mode, there are no other - * nodes available to replay our journal. So we try to replay it - * ourselves. We hold the "live" glock to prevent other mounters - * during recovery, then just dequeue it and reacquire it in our - * normal SH mode. Just in case the problem that caused us to - * withdraw prevents us from recovering our journal (e.g. io errors - * and such) we still check if the journal is clean before proceeding - * but we may wait forever until another mounter does the recovery. + * nodes available to replay our journal. */ if (ret == 0) { - fs_warn(sdp, "No other mounters found. Trying to recover our " - "own journal jid %d.\n", sdp->sd_lockstruct.ls_jid); - if (gfs2_recover_journal(sdp->sd_jdesc, 1)) - fs_warn(sdp, "Unable to recover our journal jid %d.\n", - sdp->sd_lockstruct.ls_jid); - gfs2_glock_dq_wait(&sdp->sd_live_gh); - gfs2_holder_reinit(LM_ST_SHARED, LM_FLAG_NOEXP | GL_EXACT, - &sdp->sd_live_gh); - gfs2_glock_nq(&sdp->sd_live_gh); + fs_warn(sdp, "No other mounters found.\n"); + /* + * We are about to release the lockspace. By keeping live_gl + * locked here, we ensure that the next mounter coming along + * will be a "first" mounter which will perform recovery. + */ + goto skip_recovery; } - gfs2_glock_queue_put(live_gl); /* drop extra reference we acquired */ - clear_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags); - /* * At this point our journal is evicted, so we need to get a new inode * for it. Once done, we need to call gfs2_find_jhead which