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 6A8FD16C6BD for ; Wed, 21 Aug 2024 06:13:08 +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=1724220788; cv=none; b=cB0rVf60/HieFb20OocbNJ52yRNpuyg+zNnQBOc+BSZ+d1enrTV3edzP8Q/mMpUTbTm9zpzdMb8vW06vR9Johow3TNhoNuvqVwgWCNg/W/96CDFEsDtXMiZETlU6Vq4PgiIOChBRyX9jQ9i9A2dn/aWCV38CKbqaIV1fQXy/i/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724220788; c=relaxed/simple; bh=1Raue/aK57Ze73BGjn2PKS4rw5W7fdIO8xkJW7mKTVA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=uoAP/DYNYX8l+ZkJt0AWAL8B9Mvubj5NsKlhEcC2a/zKwikN/x3XZJWg63Fg/bLEOzvX4oVwomFJ/286x2+kVIbTtNjndJm2zDdMC8P5/dsHbhkf1Z4T1w30DcOhuMUNvMULkytClXhEaxT9LDiG3Wrhx/c+lT7xqXBhdWzSP6U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BlovEsKB; 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="BlovEsKB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E2FAAC32782; Wed, 21 Aug 2024 06:13:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1724220788; bh=1Raue/aK57Ze73BGjn2PKS4rw5W7fdIO8xkJW7mKTVA=; h=From:To:Cc:Subject:Date:Reply-to:From; b=BlovEsKBOf19NrV4ha+kM5V0M8ehS96nYWUq8RnE8Us0kpmKKB9oQrNhLye+SFWwB 6DOUS/PrtUVZUN7KYXqWnVpqNNxgfscIWQMIzVVCu9mqb7YSDJydeGql6QVo+mREPB Malctl8Yf1beUTHZv3T0S3k8zXh7WvZijzekQfnc= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-52900: nilfs2: fix general protection fault in nilfs_btree_insert() Date: Wed, 21 Aug 2024 14:11:41 +0800 Message-ID: <2024082112-CVE-2023-52900-32f2@gregkh> X-Mailer: git-send-email 2.46.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=4946; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=1Raue/aK57Ze73BGjn2PKS4rw5W7fdIO8xkJW7mKTVA=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlHWxn/r9v7xCyp6I3g64Mr0/Q8Kj9/5DJy/Hmv79YXT 5cW5fJzHbEsDIJMDLJiiixftvEc3V9xSNHL0PY0zBxWJpAhDFycAjCRprkM8yyNZzhMVWjRiXxe 8vvvMY634t7Jfgxz5aoWTxF6mFF/5TsbS8xWBuEo9zwBAA== 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: nilfs2: fix general protection fault in nilfs_btree_insert() If nilfs2 reads a corrupted disk image and tries to reads a b-tree node block by calling __nilfs_btree_get_block() against an invalid virtual block address, it returns -ENOENT because conversion of the virtual block address to a disk block address fails. However, this return value is the same as the internal code that b-tree lookup routines return to indicate that the block being searched does not exist, so functions that operate on that b-tree may misbehave. When nilfs_btree_insert() receives this spurious 'not found' code from nilfs_btree_do_lookup(), it misunderstands that the 'not found' check was successful and continues the insert operation using incomplete lookup path data, causing the following crash: general protection fault, probably for non-canonical address 0xdffffc0000000005: 0000 [#1] PREEMPT SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f] ... RIP: 0010:nilfs_btree_get_nonroot_node fs/nilfs2/btree.c:418 [inline] RIP: 0010:nilfs_btree_prepare_insert fs/nilfs2/btree.c:1077 [inline] RIP: 0010:nilfs_btree_insert+0x6d3/0x1c10 fs/nilfs2/btree.c:1238 Code: bc 24 80 00 00 00 4c 89 f8 48 c1 e8 03 42 80 3c 28 00 74 08 4c 89 ff e8 4b 02 92 fe 4d 8b 3f 49 83 c7 28 4c 89 f8 48 c1 e8 03 <42> 80 3c 28 00 74 08 4c 89 ff e8 2e 02 92 fe 4d 8b 3f 49 83 c7 02 ... Call Trace: nilfs_bmap_do_insert fs/nilfs2/bmap.c:121 [inline] nilfs_bmap_insert+0x20d/0x360 fs/nilfs2/bmap.c:147 nilfs_get_block+0x414/0x8d0 fs/nilfs2/inode.c:101 __block_write_begin_int+0x54c/0x1a80 fs/buffer.c:1991 __block_write_begin fs/buffer.c:2041 [inline] block_write_begin+0x93/0x1e0 fs/buffer.c:2102 nilfs_write_begin+0x9c/0x110 fs/nilfs2/inode.c:261 generic_perform_write+0x2e4/0x5e0 mm/filemap.c:3772 __generic_file_write_iter+0x176/0x400 mm/filemap.c:3900 generic_file_write_iter+0xab/0x310 mm/filemap.c:3932 call_write_iter include/linux/fs.h:2186 [inline] new_sync_write fs/read_write.c:491 [inline] vfs_write+0x7dc/0xc50 fs/read_write.c:584 ksys_write+0x177/0x2a0 fs/read_write.c:637 do_syscall_x64 arch/x86/entry/common.c:50 [inline] do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80 entry_SYSCALL_64_after_hwframe+0x63/0xcd ... This patch fixes the root cause of this problem by replacing the error code that __nilfs_btree_get_block() returns on block address conversion failure from -ENOENT to another internal code -EINVAL which means that the b-tree metadata is corrupted. By returning -EINVAL, it propagates without glitches, and for all relevant b-tree operations, functions in the upper bmap layer output an error message indicating corrupted b-tree metadata via nilfs_bmap_convert_error(), and code -EIO will be eventually returned as it should be. The Linux kernel CVE team has assigned CVE-2023-52900 to this issue. Affected and fixed versions =========================== Fixed in 4.14.304 with commit 3c2a2ff67d46 Fixed in 4.19.271 with commit d9fde9eab176 Fixed in 5.4.230 with commit b0ba060d3287 Fixed in 5.10.165 with commit 712bd74eccb9 Fixed in 5.15.90 with commit 45627a1a6450 Fixed in 6.1.8 with commit 0bf463939c09 Fixed in 6.2 with commit 7633355e5c7f 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-52900 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/nilfs2/btree.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/3c2a2ff67d46106715c2132021b98bd057c27545 https://git.kernel.org/stable/c/d9fde9eab1766170ff2ade67d09178d2cfd78749 https://git.kernel.org/stable/c/b0ba060d3287108eba17603bee3810e4cf2c272d https://git.kernel.org/stable/c/712bd74eccb9d3626a0a236641962eca8e11a243 https://git.kernel.org/stable/c/45627a1a6450662e1e0f8174ef07b05710a20062 https://git.kernel.org/stable/c/0bf463939c09e5b2c35c71ed74a5fd60a74d6a04 https://git.kernel.org/stable/c/7633355e5c7f29c049a9048e461427d1d8ed3051