Skip to contentSkip to conversation

CVE-2026-31452: ext4: convert inline data to extents when truncate exceeds inline size

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Apr 22

lore
Share & tools
lore
#0 lore raw

From: Greg Kroah-Hartman <[email protected]>

Description
===========

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

ext4: convert inline data to extents when truncate exceeds inline size

Add a check in ext4_setattr() to convert files from inline data storage to extent-based storage when truncate() grows the file size beyond the inline capacity. This prevents the filesystem from entering an inconsistent state where the inline data flag is set but the file size exceeds what can be stored inline.

Without this fix, the following sequence causes a kernel BUG_ON():

1. Mount filesystem with inode that has inline flag set and small size
2. truncate(file, 50MB) - grows size but inline flag remains set
3. sendfile() attempts to write data
4. ext4_write_inline_data() hits BUG_ON(write_size > inline_capacity)

The crash occurs because ext4_write_inline_data() expects inline storage to accommodate the write, but the actual inline capacity (~60 bytes for i_block + ~96 bytes for xattrs) is far smaller than the file size and write request.

The fix checks if the new size from setattr exceeds the inode's actual inline capacity (EXT4_I(inode)->i_inline_size) and converts the file to extent-based storage before proceeding with the size change.

This addresses the root cause by ensuring the inline data flag and file size remain consistent during truncate operations.

The Linux kernel CVE team has assigned CVE-2026-31452 to this issue.

Affected and fixed versions
===========================

	Fixed in 5.10.253 with commit 110d7ef602659ce4d7947c5480f7ca2779696aaf
	Fixed in 5.15.203 with commit f53a5d9f32924bc2a810d2df243b7714da58b636
	Fixed in 6.1.168 with commit c047332be7195833a5c5126816c2502df8269fe4
	Fixed in 6.6.131 with commit 699bac4d4c951974d55b045c983d1de777215949
	Fixed in 6.12.80 with commit 7920dcc571cef3d8aa9ee109c136125d61d41669
	Fixed in 6.18.21 with commit 93cb2d103e5c707de0f7ad58a39b7f0fddc27aa6
	Fixed in 6.19.11 with commit 07c1a31af18290054da3d18221b8bf58983c5d3a
	Fixed in 7.0 with commit ed9356a30e59c7cc3198e7fc46cfedf3767b9b17

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-2026-31452

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/ext4/inode.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/110d7ef602659ce4d7947c5480f7ca2779696aaf
	https://git.kernel.org/stable/c/f53a5d9f32924bc2a810d2df243b7714da58b636
	https://git.kernel.org/stable/c/c047332be7195833a5c5126816c2502df8269fe4
	https://git.kernel.org/stable/c/699bac4d4c951974d55b045c983d1de777215949
	https://git.kernel.org/stable/c/7920dcc571cef3d8aa9ee109c136125d61d41669
	https://git.kernel.org/stable/c/93cb2d103e5c707de0f7ad58a39b7f0fddc27aa6
	https://git.kernel.org/stable/c/07c1a31af18290054da3d18221b8bf58983c5d3a
	https://git.kernel.org/stable/c/ed9356a30e59c7cc3198e7fc46cfedf3767b9b17