Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3EBCA1B0413 for ; Sun, 19 Jan 2025 11:53:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737287630; cv=none; b=B401JToNePFmEFKSUOLh1o8Xh2D6FIJc6jOMt9PSFjhIjQq+rI0mQSFz7izwKexqQ9jLG5xQw8ONT9/vtZl6vlCTJcYi6ZIF8pes/EhMkHPPAM7Tyt/F815I5HN/gHUJA7Cq/WUvp8C4X/siXGh3wfapKy7CCe4B6dfOt3Vy+wk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737287630; c=relaxed/simple; bh=rxNrabGgI3Mo9pAQRpcFD4b1Thov8G/ZsVd9qE/GYTE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=oix7dl9hnHnu3dAlndxLXoNCKABLxZJAKYOCG/bu7Tc3Rt0jW5GFqGySuidjAKatXbErcnbhe/VQBlwlUjLN4J/MK6eF6o6vlR2p0svVFjiMNb9nel5EejAJSCXnStpRujQf1MRXQuWGlA6yh1zLeaOpGszcgRn812591EySPMQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IrDjMnOI; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IrDjMnOI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DF72C4CED6; Sun, 19 Jan 2025 11:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1737287629; bh=rxNrabGgI3Mo9pAQRpcFD4b1Thov8G/ZsVd9qE/GYTE=; h=From:To:Cc:Subject:Date:Reply-to:From; b=IrDjMnOIJwS9Vc0R6OBLRVc3+gdeC3PPs67lynx1KMwMLJHYBOalFiKH++TfqdVqi uEITc4BId4W3VLyE9GB5l2UEItCUtAfp5cxpS+VNTWfp7CRJpqvBS6loNVvlpnisGT 6cAP4Bk4MoYsumfd/nXweMdgAwmrimUQiGSO9AFc= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-57929: dm array: fix releasing a faulty array block twice in dm_array_cursor_end Date: Sun, 19 Jan 2025 12:53:00 +0100 Message-ID: <2025011945-CVE-2024-57929-2b82@gregkh> X-Mailer: git-send-email 2.48.1 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4493; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=rxNrabGgI3Mo9pAQRpcFD4b1Thov8G/ZsVd9qE/GYTE=; b=owGbwMvMwCRo6H6F97bub03G02pJDOk9z3t3l53cFn72gOrlO+ZsPgufPmw1ttiVXLOq1O37m YKVJf/+dMSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEJE0Y5uc+/CF6Z+HGzIlL yl/y2Rxoaaw/H8+w4MYug//refeXS7j/3PnwU1zQA8e9zAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: dm array: fix releasing a faulty array block twice in dm_array_cursor_end When dm_bm_read_lock() fails due to locking or checksum errors, it releases the faulty block implicitly while leaving an invalid output pointer behind. The caller of dm_bm_read_lock() should not operate on this invalid dm_block pointer, or it will lead to undefined result. For example, the dm_array_cursor incorrectly caches the invalid pointer on reading a faulty array block, causing a double release in dm_array_cursor_end(), then hitting the BUG_ON in dm-bufio cache_put(). Reproduce steps: 1. initialize a cache device dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 65536 linear /dev/sdc 8192" dmsetup create corig --table "0 524288 linear /dev/sdc $262144" dd if=/dev/zero of=/dev/mapper/cmeta bs=4k count=1 dmsetup create cache --table "0 524288 cache /dev/mapper/cmeta \ /dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0" 2. wipe the second array block offline dmsteup remove cache cmeta cdata corig mapping_root=$(dd if=/dev/sdc bs=1c count=8 skip=192 \ 2>/dev/null | hexdump -e '1/8 "%u\n"') ablock=$(dd if=/dev/sdc bs=1c count=8 skip=$((4096*mapping_root+2056)) \ 2>/dev/null | hexdump -e '1/8 "%u\n"') dd if=/dev/zero of=/dev/sdc bs=4k count=1 seek=$ablock 3. try reopen the cache device dmsetup create cmeta --table "0 8192 linear /dev/sdc 0" dmsetup create cdata --table "0 65536 linear /dev/sdc 8192" dmsetup create corig --table "0 524288 linear /dev/sdc $262144" dmsetup create cache --table "0 524288 cache /dev/mapper/cmeta \ /dev/mapper/cdata /dev/mapper/corig 128 2 metadata2 writethrough smq 0" Kernel logs: (snip) device-mapper: array: array_block_check failed: blocknr 0 != wanted 10 device-mapper: block manager: array validator check failed for block 10 device-mapper: array: get_ablock failed device-mapper: cache metadata: dm_array_cursor_next for mapping failed ------------[ cut here ]------------ kernel BUG at drivers/md/dm-bufio.c:638! Fix by setting the cached block pointer to NULL on errors. In addition to the reproducer described above, this fix can be verified using the "array_cursor/damaged" test in dm-unit: dm-unit run /pdata/array_cursor/damaged --kernel-dir The Linux kernel CVE team has assigned CVE-2024-57929 to this issue. Affected and fixed versions =========================== Issue introduced in 4.9 with commit fdd1315aa5f022fe6574efdc2d9535f75a0ee255 and fixed in 6.1.125 with commit e477021d252c007f0c6d45b5d13d341efed03979 Issue introduced in 4.9 with commit fdd1315aa5f022fe6574efdc2d9535f75a0ee255 and fixed in 6.6.72 with commit 6002bec5354f86d1a2df21468f68e3ec03ede9da Issue introduced in 4.9 with commit fdd1315aa5f022fe6574efdc2d9535f75a0ee255 and fixed in 6.12.10 with commit 017c4470bff53585370028fec9341247bad358ff Issue introduced in 4.9 with commit fdd1315aa5f022fe6574efdc2d9535f75a0ee255 and fixed in 6.13-rc7 with commit f2893c0804d86230ffb8f1c8703fdbb18648abc8 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2024-57929 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/md/persistent-data/dm-array.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/e477021d252c007f0c6d45b5d13d341efed03979 https://git.kernel.org/stable/c/6002bec5354f86d1a2df21468f68e3ec03ede9da https://git.kernel.org/stable/c/017c4470bff53585370028fec9341247bad358ff https://git.kernel.org/stable/c/f2893c0804d86230ffb8f1c8703fdbb18648abc8