CVE-2025-40138

Source
https://cve.org/CVERecord?id=CVE-2025-40138
Import Source
https://storage.googleapis.com/osv-test-cve-osv-conversion/osv-output/CVE-2025-40138.json
JSON Data
https://api.test.osv.dev/v1/vulns/CVE-2025-40138
Downstream
Published
2025-11-12T10:23:23.912Z
Modified
2025-12-02T23:32:00.664334Z
Summary
f2fs: fix to avoid NULL pointer dereference in f2fs_check_quota_consistency()
Details

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

f2fs: fix to avoid NULL pointer dereference in f2fscheckquota_consistency()

syzbot reported a f2fs bug as below:

Oops: gen[ 107.736417][ T5848] Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] CPU: 1 UID: 0 PID: 5848 Comm: syz-executor263 Tainted: G W 6.17.0-rc1-syzkaller-00014-g0e39a731820a #0 PREEMPT{RT,(full)} RIP: 0010:strcmp+0x3c/0xc0 lib/string.c:284 Call Trace: <TASK> f2fscheckquotaconsistency fs/f2fs/super.c:1188 [inline] f2fscheckoptconsistency+0x1378/0x2c10 fs/f2fs/super.c:1436 _f2fsremount fs/f2fs/super.c:2653 [inline] f2fsreconfigure+0x482/0x1770 fs/f2fs/super.c:5297 reconfiguresuper+0x224/0x890 fs/super.c:1077 doremount fs/namespace.c:3314 [inline] pathmount+0xd18/0xfe0 fs/namespace.c:4112 domount fs/namespace.c:4133 [inline] _dosysmount fs/namespace.c:4344 [inline] _sesysmount+0x317/0x410 fs/namespace.c:4321 dosyscallx64 arch/x86/entry/syscall64.c:63 [inline] dosyscall64+0xfa/0x3b0 arch/x86/entry/syscall64.c:94 entrySYSCALL64afterhwframe+0x77/0x7f

The direct reason is f2fscheckquota_consistency() may suffer null-ptr-deref issue in strcmp().

The bug can be reproduced w/ below scripts: mkfs.f2fs -f /dev/vdb mount -t f2fs -o usrquota /dev/vdb /mnt/f2fs quotacheck -uc /mnt/f2fs/ umount /mnt/f2fs mount -t f2fs -o usrjquota=aquota.user,jqfmt=vfsold /dev/vdb /mnt/f2fs mount -t f2fs -o remount,usrjquota=,jqfmt=vfsold /dev/vdb /mnt/f2fs umount /mnt/f2fs

So, before oldqname and newqname comparison, we need to check whether they are all valid pointers, fix it.

Database specific
{
    "cna_assigner": "Linux",
    "osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/40xxx/CVE-2025-40138.json"
}
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
d185351325237da688de006a2c579e82ea97bdfe
Fixed
3f3458852bbfe79c60f2412b8b04677b96688b6e
Fixed
930a9a6ee8e7ffa20af4bffbfc2bbd21d83bf81c

Affected versions

v6.*
v6.16
v6.16-rc4
v6.16-rc5
v6.16-rc6
v6.16-rc7
v6.17
v6.17-rc1
v6.17-rc2
v6.17-rc3
v6.17-rc4
v6.17-rc5
v6.17-rc6
v6.17-rc7
v6.17.1
v6.17.2

Database specific

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

Linux / Kernel

Package

Name
Kernel

Affected ranges

Type
ECOSYSTEM
Events
Introduced
6.17.0
Fixed
6.17.3

Database specific

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