CVE-2023-52900: nilfs2: fix general protection fault in nilfs_btree_insert()

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/...

Classification

CVE ID: CVE-2023-52900

Affected Products

Vendor: Linux

Product: Linux

Exploit Prediction Scoring System (EPSS)

EPSS Score: 0.04% (probability of being exploited)

EPSS Percentile: 5.08% (scored less or equal to compared to others)

EPSS Date: 2025-02-04 (when was this score calculated)

References

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

Timeline