CVE-2025-40295: fscrypt: fix left shift underflow when inode->i_blkbits > PAGE_SHIFT

Published Dec 8, 2025
·
Updated

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

fscrypt: fix left shift underflow when inode->iblkbits > PAGESHIFT

When simulating an nvme device on qemu with both logicalblocksize and physicalblocksize set to 8 KiB, an error trace appears during partition table reading at boot time. The issue is caused by inode->iblkbits being larger than PAGESHIFT, which leads to a left shift of -1 and triggering a UBSAN warning.

[ 2.697306] ------------[ cut here ]------------ [ 2.697309] UBSAN: shift-out-of-bounds in fs/crypto/inlinecrypt.c:336:37 [ 2.697311] shift exponent -1 is negative [ 2.697315] CPU: 3 UID: 0 PID: 274 Comm: (udev-worker) Not tainted 6.18.0-rc2+ #34 PREEMPT(voluntary) [ 2.697317] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014 [ 2.697320] Call Trace: [ 2.697324] <TASK> [ 2.697325] dumpstacklvl+0x76/0xa0 [ 2.697340] dumpstack+0x10/0x20 [ 2.697342] ubsanhandleshiftoutofbounds+0x1e3/0x390 [ 2.697351] bhgetinodeandlblknum.cold+0x12/0x94 [ 2.697359] fscryptsetbiocryptctxbh+0x44/0x90 [ 2.697365] submitbhwbc+0xb6/0x190 [ 2.697370] blockreadfullfolio+0x194/0x270 [ 2.697371] ? pfxblkdevgetblock+0x10/0x10 [ 2.697375] ? pfxblkdevreadfolio+0x10/0x10 [ 2.697377] blkdevreadfolio+0x18/0x30 [ 2.697379] filemapreadfolio+0x40/0xe0 [ 2.697382] filemapgetpages+0x5ef/0x7a0 [ 2.697385] ? mmapregion+0x63/0xd0 [ 2.697389] filemapread+0x11d/0x520 [ 2.697392] blkdevreaditer+0x7c/0x180 [ 2.697393] vfsread+0x261/0x390 [ 2.697397] ksysread+0x71/0xf0 [ 2.697398] x64sysread+0x19/0x30 [ 2.697399] x64syscall+0x1e88/0x26a0 [ 2.697405] dosyscall64+0x80/0x670 [ 2.697410] ? x64sysnewfstat+0x15/0x20 [ 2.697414] ? x64syscall+0x204a/0x26a0 [ 2.697415] ? dosyscall64+0xb8/0x670 [ 2.697417] ? irqentryexittousermode+0x2e/0x2a0 [ 2.697420] ? irqentryexit+0x43/0x50 [ 2.697421] ? excpagefault+0x90/0x1b0 [ 2.697422] entrySYSCALL64afterhwframe+0x76/0x7e [ 2.697425] RIP: 0033:0x75054cba4a06 [ 2.697426] Code: 5d e8 41 8b 93 08 03 00 00 59 5e 48 83 f8 fc 75 19 83 e2 39 83 fa 08 75 11 e8 26 ff ff ff 66 0f 1f 44 00 00 48 8b 45 10 0f 05 <48> 8b 5d f8 c9 c3 0f 1f 40 00 f3 0f 1e fa 55 48 89 e5 48 83 ec 08 [ 2.697427] RSP: 002b:00007fff973723a0 EFLAGS: 00000202 ORIGRAX: 0000000000000000 [ 2.697430] RAX: ffffffffffffffda RBX: 00005ea9a2c02760 RCX: 000075054cba4a06 [ 2.697432] RDX: 0000000000002000 RSI: 000075054c190000 RDI: 000000000000001b [ 2.697433] RBP: 00007fff973723c0 R08: 0000000000000000 R09: 0000000000000000 [ 2.697434] R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000000 [ 2.697434] R13: 00005ea9a2c027c0 R14: 00005ea9a2be5608 R15: 00005ea9a2be55f0 [ 2.697436] </TASK> [ 2.697436] ---[ end trace ]---

This situation can happen for block devices because when CONFIGTRANSPARENTHUGEPAGE is enabled, the maximum logicalblocksize is 64 KiB. setinitblocksize() then sets the block device inode->iblkbits to 13, which is within this limit.

File I/O does not trigger this problem because for filesystems that do not support the FSLBS feature, sbsetblocksize() prevents sb->sblocksizebits from being larger than PAGESHIFT. During inode allocation, allocinode()->inodeinitalways() assigns inode->iblkbits from sb->sblocksizebits. Currently, only xfsfstype has the FSLBS flag, and since xfs I/O paths do not reach submitbhwbc(), it does not hit the left-shift underflow issue.

[EB: use foliopos() and consolidate the two shifts by iblkbits]

Affected Software

1 affected component
Linux Linux kernel

Event History

Dec 8, 2025
CVE Published
via MITRE·12:46 AM
Data Sourced
via MITRE·12:46 AM
Description
Data Sourced
via NVD·01:16 AM
Description

Frequently Asked Questions

1

What is the severity of CVE-2025-40295?

The severity of CVE-2025-40295 is categorized as moderate due to its impact on the file system handling in the Linux kernel.

2

How do I fix CVE-2025-40295?

To fix CVE-2025-40295, update your Linux kernel to the latest stable version that includes the patch for this vulnerability.

3

What systems are affected by CVE-2025-40295?

CVE-2025-40295 affects systems running the Linux kernel, particularly those using certain nvme device configurations.

4

Are any Linux kernel versions vulnerable to CVE-2025-40295?

Yes, earlier versions of the Linux kernel prior to the fix implementation are vulnerable to CVE-2025-40295.

5

What does CVE-2025-40295 involve?

CVE-2025-40295 involves a left shift underflow issue when inode->i_blkbits exceeds PAGE_SHIFT in the Linux kernel.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203