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 5FD69280027 for ; Wed, 18 Jun 2025 09:36:40 +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=1750239400; cv=none; b=lSrukkA0jLl7rYHXOCWFDoXTdBTlItPo4/wcu90tcKq12uiKPIOCgOrZ4EtSXL1M+pUoOS1Z4PiGrPaLTzdcojwjUu7ZcP/5SNeyLxQiPEMCZg1AoIunn80+3pb7ARoKbVwRTqzGgdpFkbBPfSa31ZVrjNnadHip5AUZydeEu9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750239400; c=relaxed/simple; bh=Ej9bJ8mwuwxXGfo/SgIFnbO3sjoyxSKs7GTWvBTL4PM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EACr3tQR+O34UAcavDls3VkPWILbOG+103aXDr+OSi9UXl0QU9WZPthiP1IF22qI/Coz0UpyPhslOgGyuxMYdUTaXc0Udm9LiR6BKPh9nCKIy4HnNdg7q4Vyc24566tbLQy85PpWRCCCah9S1pjm/5vvbQ+rA0rse4Y2N9ip1/E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=P6T5sFjJ; 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="P6T5sFjJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70820C4CEED; Wed, 18 Jun 2025 09:36:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750239399; bh=Ej9bJ8mwuwxXGfo/SgIFnbO3sjoyxSKs7GTWvBTL4PM=; h=From:To:Cc:Subject:Date:Reply-to:From; b=P6T5sFjJCBft/2dEOnaWTeipPjWB7V3vva2rRnly2V6oND7okHrzoShZs2AsgzIOR CBqTnamsQZawpR2bHMdKeAH8mSx+RjoVg37JSgSpbG2jv9P4vAJ3bC1BmWZvGCbRQR aZ+w4Hf/5/dO9KppMw3i8OWC57P0XBoJ4lRdu8s0= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2025-38059: btrfs: avoid NULL pointer dereference if no valid csum tree Date: Wed, 18 Jun 2025 11:33:54 +0200 Message-ID: <2025061834-CVE-2025-38059-4697@gregkh> X-Mailer: git-send-email 2.49.0 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=3357; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=DbJm9cnSey+F5kRafRABo0PTUZb3tHfNgyCJus7vJMw=; b=owGbwMvMwCRo6H6F97bub03G02pJDBlB7e/uHFRdKnRf5Z6bSgm7zu/5fS812tdP2ntHas5pf /PbXxO2dsSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEnMwZFmzn5LvJGx1lc3XJ d8eb9jWlLtuuuTMs6NdSnqeukLW/ovRy/rv9IjYJSgXxAA== 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: avoid NULL pointer dereference if no valid csum tree [BUG] When trying read-only scrub on a btrfs with rescue=idatacsums mount option, it will crash with the following call trace: BUG: kernel NULL pointer dereference, address: 0000000000000208 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page CPU: 1 UID: 0 PID: 835 Comm: btrfs Tainted: G O 6.15.0-rc3-custom+ #236 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022 RIP: 0010:btrfs_lookup_csums_bitmap+0x49/0x480 [btrfs] Call Trace: scrub_find_fill_first_stripe+0x35b/0x3d0 [btrfs] scrub_simple_mirror+0x175/0x290 [btrfs] scrub_stripe+0x5f7/0x6f0 [btrfs] scrub_chunk+0x9a/0x150 [btrfs] scrub_enumerate_chunks+0x333/0x660 [btrfs] btrfs_scrub_dev+0x23e/0x600 [btrfs] btrfs_ioctl+0x1dcf/0x2f80 [btrfs] __x64_sys_ioctl+0x97/0xc0 do_syscall_64+0x4f/0x120 entry_SYSCALL_64_after_hwframe+0x76/0x7e [CAUSE] Mount option "rescue=idatacsums" will completely skip loading the csum tree, so that any data read will not find any data csum thus we will ignore data checksum verification. Normally call sites utilizing csum tree will check the fs state flag NO_DATA_CSUMS bit, but unfortunately scrub does not check that bit at all. This results in scrub to call btrfs_search_slot() on a NULL pointer and triggered above crash. [FIX] Check both extent and csum tree root before doing any tree search. The Linux kernel CVE team has assigned CVE-2025-38059 to this issue. Affected and fixed versions =========================== Fixed in 6.6.93 with commit 50d0de59f66cbe6d597481e099bf1c70fd07e0a9 Fixed in 6.12.31 with commit 6e9770de024964b1017f99ee94f71967bd6edaeb Fixed in 6.14.9 with commit d35bed14b0bc95c6845863a3744ecd10b888c830 Fixed in 6.15 with commit f95d186255b319c48a365d47b69bd997fecb674e 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-38059 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/scrub.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/50d0de59f66cbe6d597481e099bf1c70fd07e0a9 https://git.kernel.org/stable/c/6e9770de024964b1017f99ee94f71967bd6edaeb https://git.kernel.org/stable/c/d35bed14b0bc95c6845863a3744ecd10b888c830 https://git.kernel.org/stable/c/f95d186255b319c48a365d47b69bd997fecb674e