From mboxrd@z Thu Jan 1 00:00:00 1970 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 84DE6149C5D for ; Wed, 3 Apr 2024 14:58:06 +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=1712156286; cv=none; b=jAfFNyPRvK0TfqzeAkw4vxOV/jcXNuHeDxTEegoPzvFpG6IC//2J5PNxGdCh/hIblE/36utF+B5Mc+3VtngGqn31F+pHCWMj8MbniYWKUi5F/j4b9dThZaMVvy1LTiRzUkTdhnBLe6eLhGvZBSaD7hcT/RsDAO9NnnNDYjn9QiM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712156286; c=relaxed/simple; bh=qBBSvKXAl7rIOtwKl+hq7vC6nWLicPNLVhBKcZFyUPo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MKeaqjBbq7cFQTN0xME4DC7VNedoLSnog/Yv0LqE3J8mXXpw6pxOgN7VwU5OOKOAGp5ilFvc5lzJ5PJNZiaknVvUXLmSvp2pb3HKfZ8peX0ycl6g/Ib5isNNxQrNUybhRq3yfWjjrvezHb0Kxwz0PDTQtehEE9ll6na/FQyuCic= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=iBXcrmXQ; 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="iBXcrmXQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE8CEC433F1; Wed, 3 Apr 2024 14:58:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712156286; bh=qBBSvKXAl7rIOtwKl+hq7vC6nWLicPNLVhBKcZFyUPo=; h=From:To:Cc:Subject:Date:Reply-to:From; b=iBXcrmXQmABfJw9XAlSams4g8if4cdiygY3LNHRxlQd/NjqJlOmYbCKwMBFO65gax 7fVI8L6IvVlrUrOdEadIpzNW2VZbKcN35i713Kb+sXcBqb9fgy28Y3PP+gxobX9F5b 4/S3uwyRQQa5IHEn5qU9DNwMKJGqXRqmvQrFAmAE= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-26727: btrfs: do not ASSERT() if the newly created subvolume already got read Date: Wed, 3 Apr 2024 16:56:18 +0200 Message-ID: <2024040346-CVE-2024-26727-3ec3@gregkh> X-Mailer: git-send-email 2.44.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=4187; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=qBBSvKXAl7rIOtwKl+hq7vC6nWLicPNLVhBKcZFyUPo=; b=owGbwMvMwCRo6H6F97bub03G02pJDGm8uZ9KMxzvcbCoOhjeOHVFQbL1Q/EFh77LXl9vT7wfs Y4herp0RywLgyATg6yYIsuXbTxH91ccUvQytD0NM4eVCWQIAxenAEyk5gjDgonfL/64t651Rpn3 83LFhXyRYTvn+DIsuLyocJq/qIbopp8pU6NfPnA7nXveCAA= 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: do not ASSERT() if the newly created subvolume already got read [BUG] There is a syzbot crash, triggered by the ASSERT() during subvolume creation: assertion failed: !anon_dev, in fs/btrfs/disk-io.c:1319 ------------[ cut here ]------------ kernel BUG at fs/btrfs/disk-io.c:1319! invalid opcode: 0000 [#1] PREEMPT SMP KASAN RIP: 0010:btrfs_get_root_ref.part.0+0x9aa/0xa60 btrfs_get_new_fs_root+0xd3/0xf0 create_subvol+0xd02/0x1650 btrfs_mksubvol+0xe95/0x12b0 __btrfs_ioctl_snap_create+0x2f9/0x4f0 btrfs_ioctl_snap_create+0x16b/0x200 btrfs_ioctl+0x35f0/0x5cf0 __x64_sys_ioctl+0x19d/0x210 do_syscall_64+0x3f/0xe0 entry_SYSCALL_64_after_hwframe+0x63/0x6b ---[ end trace 0000000000000000 ]--- [CAUSE] During create_subvol(), after inserting root item for the newly created subvolume, we would trigger btrfs_get_new_fs_root() to get the btrfs_root of that subvolume. The idea here is, we have preallocated an anonymous device number for the subvolume, thus we can assign it to the new subvolume. But there is really nothing preventing things like backref walk to read the new subvolume. If that happens before we call btrfs_get_new_fs_root(), the subvolume would be read out, with a new anonymous device number assigned already. In that case, we would trigger ASSERT(), as we really expect no one to read out that subvolume (which is not yet accessible from the fs). But things like backref walk is still possible to trigger the read on the subvolume. Thus our assumption on the ASSERT() is not correct in the first place. [FIX] Fix it by removing the ASSERT(), and just free the @anon_dev, reset it to 0, and continue. If the subvolume tree is read out by something else, it should have already get a new anon_dev assigned thus we only need to free the preallocated one. The Linux kernel CVE team has assigned CVE-2024-26727 to this issue. Affected and fixed versions =========================== Issue introduced in 5.9 with commit 2dfb1e43f57d and fixed in 5.10.210 with commit 3f5d47eb163b Issue introduced in 5.9 with commit 2dfb1e43f57d and fixed in 5.15.149 with commit e31546b0f34a Issue introduced in 5.9 with commit 2dfb1e43f57d and fixed in 6.1.79 with commit 66b317a2fc45 Issue introduced in 5.9 with commit 2dfb1e43f57d and fixed in 6.6.18 with commit 833775656d44 Issue introduced in 5.9 with commit 2dfb1e43f57d and fixed in 6.7.6 with commit 5a172344bfda Issue introduced in 5.9 with commit 2dfb1e43f57d and fixed in 6.8 with commit e03ee2fe873e Issue introduced in 5.8.3 with commit 917d608fe375 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-26727 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/disk-io.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/3f5d47eb163bceb1b9e613c9003bae5fefc0046f https://git.kernel.org/stable/c/e31546b0f34af21738c4ceac47d662c00ee6382f https://git.kernel.org/stable/c/66b317a2fc45b2ef66527ee3f8fa08fb5beab88d https://git.kernel.org/stable/c/833775656d447c545133a744a0ed1e189ce61430 https://git.kernel.org/stable/c/5a172344bfdabb46458e03708735d7b1a918c468 https://git.kernel.org/stable/c/e03ee2fe873eb68c1f9ba5112fee70303ebf9dfb