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 8DEAB1494A9 for ; Thu, 27 Feb 2025 02:13:28 +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=1740622408; cv=none; b=VeoAsZO7+eL3RuIFpa1GwPos/lj6GkFYyxIvCg7mQu4KpEm/wiqGyOIP2YH7r8KAkk2FNOdJlkak/VZnJLOI1KdEGA4cgcBIvJqlQT0q9BThHP5Phm+cdBiK8RaibN0Z9UDR65FTXYCOPcM27fva/288DnGBi+ndzN8ru4FlrSg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740622408; c=relaxed/simple; bh=0eJLsjpZQBFDP6FE9q+eQrYV1D3fyiDEqM+B2zNvyQE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=a/XTQbtb8CIjXU00tfdkvPvYNcD6F1Zhthq9ZV4AcRt6XsHKXO9V5EorJC1JH2mq5AyOD+Z+FAI0y/l3JvIOxOPVcuN3xVDlMZLZyl0xzKee/AlIim0OUU8MesqyMEcA+vx7ZCp27RvyvnpuVsYhzR+ZsNydH/Iu2Wo8MDnpfU4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=U9bZKbPa; 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="U9bZKbPa" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59FEDC4CED6; Thu, 27 Feb 2025 02:13:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1740622408; bh=0eJLsjpZQBFDP6FE9q+eQrYV1D3fyiDEqM+B2zNvyQE=; h=From:To:Cc:Subject:Date:Reply-to:From; b=U9bZKbPaP2cUIWQ9DYD2OZTwPeE4i6BxJoU7r/Gxr4iLX89nPJf2hQ/MRxSZ1dfQZ p6MzGR/IvR1xAJx2UzTLM6mxCS4KLajr1aWka2TA1DFZlpS4Mm/5wG3RZURitfC8iY WrFmKhOWwph5viGaPa4oqRus6CHbAw5cIPf2eWNs= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-21752: btrfs: don't use btrfs_set_item_key_safe on RAID stripe-extents Date: Wed, 26 Feb 2025 18:11:34 -0800 Message-ID: <2025022602-CVE-2025-21752-5815@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=4993; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=0eJLsjpZQBFDP6FE9q+eQrYV1D3fyiDEqM+B2zNvyQE=; b=owGbwMvMwCRo6H6F97bub03G02pJDOn7T27bkCC0aIW3f1rKy/NfTnTaS1TdCnNud78q0hAQI pP0fqdsRywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAFykgGFBA+MTfWOBI9KPipZ8 tFpa0xJQni3EML+2b8U3l/9d13O8rbhvS/zxniS0sg8A 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: btrfs: don't use btrfs_set_item_key_safe on RAID stripe-extents Don't use btrfs_set_item_key_safe() to modify the keys in the RAID stripe-tree, as this can lead to corruption of the tree, which is caught by the checks in btrfs_set_item_key_safe(): BTRFS info (device nvme1n1): leaf 49168384 gen 15 total ptrs 194 free space 8329 owner 12 BTRFS info (device nvme1n1): refs 2 lock_owner 1030 current 1030 [ snip ] item 105 key (354549760 230 20480) itemoff 14587 itemsize 16 stride 0 devid 5 physical 67502080 item 106 key (354631680 230 4096) itemoff 14571 itemsize 16 stride 0 devid 1 physical 88559616 item 107 key (354631680 230 32768) itemoff 14555 itemsize 16 stride 0 devid 1 physical 88555520 item 108 key (354717696 230 28672) itemoff 14539 itemsize 16 stride 0 devid 2 physical 67604480 [ snip ] BTRFS critical (device nvme1n1): slot 106 key (354631680 230 32768) new key (354635776 230 4096) ------------[ cut here ]------------ kernel BUG at fs/btrfs/ctree.c:2602! Oops: invalid opcode: 0000 [#1] PREEMPT SMP PTI CPU: 1 UID: 0 PID: 1055 Comm: fsstress Not tainted 6.13.0-rc1+ #1464 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014 RIP: 0010:btrfs_set_item_key_safe+0xf7/0x270 Code: RSP: 0018:ffffc90001337ab0 EFLAGS: 00010287 RAX: 0000000000000000 RBX: ffff8881115fd000 RCX: 0000000000000000 RDX: 0000000000000001 RSI: 0000000000000001 RDI: 00000000ffffffff RBP: ffff888110ed6f50 R08: 00000000ffffefff R09: ffffffff8244c500 R10: 00000000ffffefff R11: 00000000ffffffff R12: ffff888100586000 R13: 00000000000000c9 R14: ffffc90001337b1f R15: ffff888110f23b58 FS: 00007f7d75c72740(0000) GS:ffff88813bd00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fa811652c60 CR3: 0000000111398001 CR4: 0000000000370eb0 Call Trace: ? __die_body.cold+0x14/0x1a ? die+0x2e/0x50 ? do_trap+0xca/0x110 ? do_error_trap+0x65/0x80 ? btrfs_set_item_key_safe+0xf7/0x270 ? exc_invalid_op+0x50/0x70 ? btrfs_set_item_key_safe+0xf7/0x270 ? asm_exc_invalid_op+0x1a/0x20 ? btrfs_set_item_key_safe+0xf7/0x270 btrfs_partially_delete_raid_extent+0xc4/0xe0 btrfs_delete_raid_extent+0x227/0x240 __btrfs_free_extent.isra.0+0x57f/0x9c0 ? exc_coproc_segment_overrun+0x40/0x40 __btrfs_run_delayed_refs+0x2fa/0xe80 btrfs_run_delayed_refs+0x81/0xe0 btrfs_commit_transaction+0x2dd/0xbe0 ? preempt_count_add+0x52/0xb0 btrfs_sync_file+0x375/0x4c0 do_fsync+0x39/0x70 __x64_sys_fsync+0x13/0x20 do_syscall_64+0x54/0x110 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7f7d7550ef90 Code: RSP: 002b:00007ffd70237248 EFLAGS: 00000202 ORIG_RAX: 000000000000004a RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f7d7550ef90 RDX: 000000000000013a RSI: 000000000040eb28 RDI: 0000000000000004 RBP: 000000000000001b R08: 0000000000000078 R09: 00007ffd7023725c R10: 00007f7d75400390 R11: 0000000000000202 R12: 028f5c28f5c28f5c R13: 8f5c28f5c28f5c29 R14: 000000000040b520 R15: 00007f7d75c726c8 While the root cause of the tree order corruption isn't clear, using btrfs_duplicate_item() to copy the item and then adjusting both the key and the per-device physical addresses is a safe way to counter this problem. The Linux kernel CVE team has assigned CVE-2025-21752 to this issue. Affected and fixed versions =========================== Fixed in 6.13.3 with commit 1c25eff52ee5a02a2c4be659a44ae972d9989742 Fixed in 6.14-rc1 with commit dc14ba10781bd2629835696b7cc1febf914768e9 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-2025-21752 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/raid-stripe-tree.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/1c25eff52ee5a02a2c4be659a44ae972d9989742 https://git.kernel.org/stable/c/dc14ba10781bd2629835696b7cc1febf914768e9