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 1A42C33A9F3; Sat, 12 Sep 2026 17:10:38 +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=1789233040; cv=none; b=A07Qqe7gLmhI4jP/kzLmVjl9liCXU/yF1o9vGmhAzbRxoiPZFnMCYkpLnVth9FCmDVenmwA+/PtuPv0iC0iravFFkn0vW6jkttZaVS+EhAMvtXb8cJDeAe7ZpCVNvWfPn4M7BB77dqju1wJrLo8NqTZgBeHEV2cqgKcYu16Mr9A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789233040; c=relaxed/simple; bh=RYTvvkYywUqQj+gU22mBwVJDkfAX83war6n6wDUMgdI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kS9L4ycORnDAN+6KtknRuzXSvoT5WwCKTbrKd7khx0a1zoNjUUbeoYJtWDhoUm3fjqLWo7rTbj0MfLkTVIVD279tkFu91uWaSf2ueO6LgY23EAsMRwPZ+LWoV2OHh3t4kmKAGN/n6Ep68PxKWFN8AGRtEiBRVFQU/xxv7d0Y1JI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RtIbGo2i; 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="RtIbGo2i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBD4E1F000FF; Sat, 12 Sep 2026 17:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789233038; bh=PaZ5Cli49wuXnfqHdvi1x2hNFqGiUD10FiUgW40kCB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RtIbGo2ihoY3C4fMCDQXlm7XOvG+y0b+zG+5vpU40epTL9yPcsXDHELtMr3EpjyNK tW8XLfmCqKJH5AFz1Mj+Ez30NDLO6pAdGt/GzAH6J1kWZeQt6GW/Zn1XjKw91JdpaO pL48pvRGfLvqTVzkoXEgq+K8nLfJcbM+BlbpduJM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Joseph Qi , Mark Fasheh , Joel Becker , Junxiao Bi , Changwei Ge , Jun Piao , Heming Zhao , Andrew Morton Subject: [PATCH 5.15 134/935] ocfs2: cluster: fix o2hb_dependent_users leak on pin failure Date: Sat, 12 Sep 2026 08:52:44 +0200 Message-ID: <20260912065529.897460213@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065526.833703348@linuxfoundation.org> References: <20260912065526.833703348@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: Joseph Qi commit 12c2ab42dbe227956c765e2674364bfca5de0533 upstream. In o2hb_region_inc_user(), o2hb_dependent_users is incremented unconditionally before calling o2hb_region_pin(). If the pin fails, the counter is never decremented and any partially-pinned regions are never unpinned, since the caller does not call o2hb_region_dec_user() on error. The leaked counter causes subsequent o2hb_region_inc_user() calls to skip pinning entirely (the > 1 check), leaving heartbeat regions unprotected. Fix by rolling back on failure: call o2hb_region_unpin(NULL) to release any partially-pinned regions and decrement o2hb_dependent_users to restore the pre-increment state. Link: https://lore.kernel.org/20260722124933.430554-4-joseph.qi@linux.alibaba.com Fixes: 58a3158a5d17 ("ocfs2/cluster: Pin/unpin o2hb regions") Signed-off-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Cc: Junxiao Bi Cc: Changwei Ge Cc: Jun Piao Cc: Heming Zhao Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- fs/ocfs2/cluster/heartbeat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -2441,8 +2441,13 @@ static int o2hb_region_inc_user(const ch goto unlock; if (bitmap_weight(o2hb_quorum_region_bitmap, - O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF) + O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF) { ret = o2hb_region_pin(NULL, false); + if (ret) { + o2hb_region_unpin(NULL); + o2hb_dependent_users--; + } + } unlock: spin_unlock(&o2hb_live_lock);