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 F0ECC2D5957 for ; Tue, 30 Dec 2025 12:12:12 +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=1767096733; cv=none; b=nJG5/fCgGqAKoT4rutOYFJ5K95CnnXyta5TbKq55AqQv2ccmuzSukBi+WPRxrtcTdiOP6VS5VeTndIV4QWkqd65G4FRwX2vnyojJjQdC4FB83mNkA8GZth4iP1riEi/xQ+i7vtDdlF0XPcquLpf4KCnheehsGu6glgnvXok7gyM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767096733; c=relaxed/simple; bh=osQKvBrXwImbvAt9RGmOjX1vC2glR123ZRPEJFzH3Jo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=C9AuYW7KVum8hqHbinfUs4NryrAvRib5HcPQnyMp2YNdHe6lJMOJe4W7lHcbmvDESOh03B6gB8yCwsQNIv7ituwMXN8nftBNL8lp8yfiqVSknBV7fUrC309yOCu6A+fHPGEhCkTKTahgy8WDOxADj3CYia4b2G6J1icjIRitcSU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FtfVxe0i; 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="FtfVxe0i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F6F8C4CEFB; Tue, 30 Dec 2025 12:12:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767096732; bh=osQKvBrXwImbvAt9RGmOjX1vC2glR123ZRPEJFzH3Jo=; h=From:To:Cc:Subject:Date:Reply-To:From; b=FtfVxe0iJsOQdPnutIAwO7HbRLESD04zv9A4YkIi6S14dhyHdSsijkbH2JpotYwxu KLxb5zw8QbbzGjXOV/Bt2uP0QegBL9B3VMgS2AUX8vp3+RCLEWZJy7VL2IaPhftZXJ /6a5LCqDJix6K6JF4CwN9yL7ePeWckgIHRF0D8Xc= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-54180: btrfs: handle case when repair happens with dev-replace Date: Tue, 30 Dec 2025 13:09:48 +0100 Message-ID: <2025123024-CVE-2023-54180-8b91@gregkh> X-Mailer: git-send-email 2.52.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4283; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=a+J4k9GLnAe+aCMspnrOQr4C2RG4gPIc13JLCy9gNkQ=; b=owGbwMvMwCRo6H6F97bub03G02pJDJnBB76IzjOPlmNf6jCh1FO283LubbvpUQdO8G+dknj1k /CWLH/VjlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZhIaCvDguU8Si5dO6csOfX1 tOMXiUNnV32fb8IwPynxmpVp2j05JpPNiw884pt1s/rEKgA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: btrfs: handle case when repair happens with dev-replace [BUG] There is a bug report that a BUG_ON() in btrfs_repair_io_failure() (originally repair_io_failure() in v6.0 kernel) got triggered when replacing a unreliable disk: BTRFS warning (device sda1): csum failed root 257 ino 2397453 off 39624704 csum 0xb0d18c75 expected csum 0x4dae9c5e mirror 3 kernel BUG at fs/btrfs/extent_io.c:2380! invalid opcode: 0000 [#1] PREEMPT SMP NOPTI CPU: 9 PID: 3614331 Comm: kworker/u257:2 Tainted: G OE 6.0.0-5-amd64 #1 Debian 6.0.10-2 Hardware name: Micro-Star International Co., Ltd. MS-7C60/TRX40 PRO WIFI (MS-7C60), BIOS 2.70 07/01/2021 Workqueue: btrfs-endio btrfs_end_bio_work [btrfs] RIP: 0010:repair_io_failure+0x24a/0x260 [btrfs] Call Trace: clean_io_failure+0x14d/0x180 [btrfs] end_bio_extent_readpage+0x412/0x6e0 [btrfs] ? __switch_to+0x106/0x420 process_one_work+0x1c7/0x380 worker_thread+0x4d/0x380 ? rescuer_thread+0x3a0/0x3a0 kthread+0xe9/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x22/0x30 [CAUSE] Before the BUG_ON(), we got some read errors from the replace target first, note the mirror number (3, which is beyond RAID1 duplication, thus it's read from the replace target device). Then at the BUG_ON() location, we are trying to writeback the repaired sectors back the failed device. The check looks like this: ret = btrfs_map_block(fs_info, BTRFS_MAP_WRITE, logical, &map_length, &bioc, mirror_num); if (ret) goto out_counter_dec; BUG_ON(mirror_num != bioc->mirror_num); But inside btrfs_map_block(), we can modify bioc->mirror_num especially for dev-replace: if (dev_replace_is_ongoing && mirror_num == map->num_stripes + 1 && !need_full_stripe(op) && dev_replace->tgtdev != NULL) { ret = get_extra_mirror_from_replace(fs_info, logical, *length, dev_replace->srcdev->devid, &mirror_num, &physical_to_patch_in_first_stripe); patch_the_first_stripe_for_dev_replace = 1; } Thus if we're repairing the replace target device, we're going to trigger that BUG_ON(). But in reality, the read failure from the replace target device may be that, our replace hasn't reached the range we're reading, thus we're reading garbage, but with replace running, the range would be properly filled later. Thus in that case, we don't need to do anything but let the replace routine to handle it. [FIX] Instead of a BUG_ON(), just skip the repair if we're repairing the device replace target device. The Linux kernel CVE team has assigned CVE-2023-54180 to this issue. Affected and fixed versions =========================== Fixed in 6.0.19 with commit a7018b40b49c37fb55736499f790ec0d2b381ae4 Fixed in 6.1.5 with commit 53e9d6851b56626885476a2966194ba994f8bb4b Fixed in 6.2 with commit d73a27b86fc722c28a26ec64002e3a7dc86d1c07 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-2023-54180 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: fs/btrfs/bio.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/a7018b40b49c37fb55736499f790ec0d2b381ae4 https://git.kernel.org/stable/c/53e9d6851b56626885476a2966194ba994f8bb4b https://git.kernel.org/stable/c/d73a27b86fc722c28a26ec64002e3a7dc86d1c07