CVE-2025-38218

Source
https://cve.org/CVERecord?id=CVE-2025-38218
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-38218.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2025-38218
Downstream
Related
Published
2025-07-04T13:37:35.157Z
Modified
2026-03-09T23:50:18.390247Z
Summary
f2fs: fix to do sanity check on sit_bitmap_size
Details

In the Linux kernel, the following vulnerability has been resolved:

f2fs: fix to do sanity check on sitbitmapsize

w/ below testcase, resize will generate a corrupted image which contains inconsistent metadata, so when mounting such image, it will trigger kernel panic:

touch img truncate -s $((512102410241024)) img mkfs.f2fs -f img $((25610241024)) resize.f2fs -s -i img -t $((10241024*1024)) mount img /mnt/f2fs

------------[ cut here ]------------ kernel BUG at fs/f2fs/segment.h:863! Oops: invalid opcode: 0000 [#1] SMP PTI CPU: 11 UID: 0 PID: 3922 Comm: mount Not tainted 6.15.0-rc1+ #191 PREEMPT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:f2fsrameta_pages+0x47c/0x490

Call Trace: f2fsbuildsegmentmanager+0x11c3/0x2600 f2fsfillsuper+0xe97/0x2840 mountbdev+0xf4/0x140 legacygettree+0x2b/0x50 vfsgettree+0x29/0xd0 path_mount+0x487/0xaf0 __x64sysmount+0x116/0x150 dosyscall64+0x82/0x190 entrySYSCALL64afterhwframe+0x76/0x7e RIP: 0033:0x7fdbfde1bcfe

The reaseon is:

siti->bitmapsize is 192, so size of sit bitmap is 192*8=1536, at maximum there are 1536 sit blocks, however MAINSEGS is 261893, so that sitblkcnt is 4762, buildsitentries() -> currentsitaddr() tries to access out-of-boundary in sitbitmap at offset from [1536, 4762), once sitbitmap and sitbitmapmirror is not the same, it will trigger f2fsbug_on().

Let's add sanity check in f2fssanitycheck_ckpt() to avoid panic.

Database specific
{
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/38xxx/CVE-2025-38218.json",
    "cna_assigner": "Linux"
}
References

Affected packages

Git / git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git

Affected ranges

Type
GIT
Repo
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
Events
Introduced
98e4da8ca301e062d79ae168c67e56f3c3de3ce4
Fixed
82f51bff393e4c12cf4de553120ca831cfa4ef19
Fixed
38ef48a8afef8df646b6f6ae7abb872f18b533c1
Fixed
ad862f71016ba38039df1c96ed55c0a4314cc183
Fixed
79ef8a6c4ec53d327580fd7d2b522cf4f1d05b0c
Fixed
ee1b421c469876544e297ec1090574bd76100247
Fixed
3e5ac62a56a24f4d88ce8ffd7bc452428b235868
Fixed
5db0d252c64e91ba1929c70112352e85dc5751e7

Database specific

source
"https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-38218.json"