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 2C87747DD55; Sat, 12 Sep 2026 13:36:18 +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=1789220179; cv=none; b=YDxRP/6ZouLAGbwmwBtqLbsWknCxq/o/ZELKIQnerNHhMApJl7S7kWxGeOnksAQeM0UCC4a16JvgZ0afrF8XWeTbwzmRYzYBo3RK/J4j/vNMEVLRNZoxOE6z8UlDMLiYqmW5e7T8q85tElH7Z3LXnIi1G3KWiKXG9HPmU21TSOA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789220179; c=relaxed/simple; bh=VS4ZVQu4Ch3TTwAfWNreu/0BXxqoi1AJcDanMVo0nHk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cwWIuLTupsFRCgMGk/P2UxeyLk6uUrCMQSTx+/XRc4D19B74izkMz/gHe9jlokjkQL7JmvdJvxJilLhLDPk+ERBvmGg7NuALA+xcNxU3hxcfy6p3h1X/IE4rrNmV7RQ6e5GzAnn9HsnZ5KLg+Kv/77dXPrfnI/fwbIYU4neYdpo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xPYtJF5O; 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="xPYtJF5O" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE02C1F000FF; Sat, 12 Sep 2026 13:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789220178; bh=BlYDLkHuqBSMW0QpEGpqagD6MyGwttTiSyKXAflMTZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xPYtJF5OQ72g0AR0riazGOPx/po0Bj9OtFe/UJrsfn3O2Ao8UVPkoPbNgRw7fgUZ4 28IqyvAj5TbJ8lFz9mW0y+gzdGRrS/BxFaxO5U+rK2wSH5x/rBdPdquI+u+OvnyQV6 X/y8u99SSjnlib1535nVo1cru0jEQFAUl4c61V3E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ming-Hung Tsai , Bryam Vargas , Mikulas Patocka Subject: [PATCH 6.6 0125/1424] dm array: reject an array block whose value size is not the callers Date: Sat, 12 Sep 2026 08:42:37 +0200 Message-ID: <20260912065610.100417018@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065607.279695368@linuxfoundation.org> References: <20260912065607.279695368@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.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryam Vargas commit 4538a287bdf5d0f9a379c678e5262b9f5783f547 upstream. array_block_check() can only compare the header against itself, so a block with value_size 4 and max_entries 1018 is internally consistent and passes. dm-cache keeps two arrays -- mappings at 8 bytes and hints at 4 -- and the roots for both live in the superblock. Point the mappings root at a hint block and __load_mappings() walks it through an info whose value size is 8, so element_at() strides 8 bytes over 4-byte entries and reaches offset 8160 of a 4096-byte block. get_ablock() and __shadow_ablock() are the two places that hold the block and the caller at once. Reject there when the two value sizes disagree. Arrays only ever read their own blocks, so this fires on crafted metadata only. Fixes: 6513c29f44f2 ("dm persistent data: add transactional array") Suggested-by: Ming-Hung Tsai Cc: stable@vger.kernel.org Signed-off-by: Bryam Vargas Reviewed-by: Ming-Hung Tsai Signed-off-by: Mikulas Patocka Signed-off-by: Greg Kroah-Hartman --- drivers/md/persistent-data/dm-array.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- a/drivers/md/persistent-data/dm-array.c +++ b/drivers/md/persistent-data/dm-array.c @@ -225,6 +225,14 @@ static int get_ablock(struct dm_array_in return r; *ab = dm_block_data(*block); + if (le32_to_cpu((*ab)->value_size) != info->value_type.size) { + DMERR_LIMIT("%s failed: value_size %u != wanted %u", __func__, + le32_to_cpu((*ab)->value_size), + info->value_type.size); + dm_tm_unlock(info->btree_info.tm, *block); + return -EILSEQ; + } + return 0; } @@ -287,6 +295,14 @@ static int __shadow_ablock(struct dm_arr return r; *ab = dm_block_data(*block); + if (le32_to_cpu((*ab)->value_size) != info->value_type.size) { + DMERR_LIMIT("%s failed: value_size %u != wanted %u", __func__, + le32_to_cpu((*ab)->value_size), + info->value_type.size); + dm_tm_unlock(info->btree_info.tm, *block); + return -EILSEQ; + } + if (inc) inc_ablock_entries(info, *ab);