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 3D8AA352017; Sat, 12 Sep 2026 15:34:10 +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=1789227251; cv=none; b=Pdjw7zqHztiQ2wd7/ALO1E+aCekgTWGUFGxg4HZ841+I/xLxuPg6NCsx7Qjtuqni3pLIs5eANe+B3irpntUvb6c0tZ0oINNaikGCu+V527EJyfINfLLnbnadvLssls+0UjHSTB9ykEPFyOL5xCJL1a/rgRldOthYQ0D4YiWww2U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789227251; c=relaxed/simple; bh=NxK17GJp+m2CyT6BT81mEDrWKSF22iO7Xl/aU156dGo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W7cvhjFjFk/hWwtrZapRu1Phy0AC3ADsuZpX24xNdiexNQpSmQTS3dBQBejWqBEW2C8xA7OlfcaMzPD3E+W5KzUy2H1U6yMcX9NgolZhlkkPYyFTI8Dq8t8kgsJG0Hl86T/AV3Q5o0ZS97Td+8e7IGVY8rIq/60dZ+CD8x5O2Q8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1CCJCk3w; 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="1CCJCk3w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F0ED61F000FF; Sat, 12 Sep 2026 15:34:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789227250; bh=KTWGQ2zZYfU7hH3yfYBkegBcWooA6vGS0vgJDYRb0CU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1CCJCk3w67k02/E7VWkDnDaONktmsom514hka712Grp9zEDT1zeCpI7qu6pAapOtn tw0poWTlmWKLIwfnZ/IN2pgAvXibKal8JnzvTYVwRoFgzLlmcEpd1i8ary6S1JXeuw ucPjwjY+F1lS5DaNTIOxCuqpRsD812kFscSMAnRA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, liyouhong , Mikulas Patocka Subject: [PATCH 6.1 0105/1191] dm-era: fix shadowed superblock leak on take-snap failure Date: Sat, 12 Sep 2026 08:47:13 +0200 Message-ID: <20260912065550.543907215@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065548.086904252@linuxfoundation.org> References: <20260912065548.086904252@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: liyouhong commit 39c5aa3bd8ec3912d2cd0b3fe092642b0d2b0713 upstream. metadata_take_snap() bumps the live superblock refcount and then dm_tm_shadow_block() allocates a new block for the metadata snapshot. If the subsequent dm_sm_inc_block() of writeset_tree_root or era_array_root fails, the function only unlocks the clone and returns. The newly allocated shadow block is never returned to the metadata space map, so each failed take-snap permanently leaks one metadata block. Free the clone with dm_sm_dec_block() on those error paths, matching the final step of metadata_drop_snap(). Fixes: eec40579d848 ("dm: add era target") Cc: stable@vger.kernel.org Signed-off-by: liyouhong Signed-off-by: Mikulas Patocka Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-era-target.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/drivers/md/dm-era-target.c +++ b/drivers/md/dm-era-target.c @@ -1022,6 +1022,7 @@ static int metadata_checkpoint(struct er static int metadata_take_snap(struct era_metadata *md) { int r, inc; + dm_block_t location; struct dm_block *clone; if (md->metadata_snap != SUPERBLOCK_LOCATION) { @@ -1059,7 +1060,9 @@ static int metadata_take_snap(struct era r = dm_sm_inc_block(md->sm, md->writeset_tree_root); if (r) { DMERR("%s: couldn't inc writeset tree root", __func__); + location = dm_block_location(clone); dm_tm_unlock(md->tm, clone); + dm_sm_dec_block(md->sm, location); return r; } @@ -1067,7 +1070,9 @@ static int metadata_take_snap(struct era if (r) { DMERR("%s: couldn't inc era tree root", __func__); dm_sm_dec_block(md->sm, md->writeset_tree_root); + location = dm_block_location(clone); dm_tm_unlock(md->tm, clone); + dm_sm_dec_block(md->sm, location); return r; }