Corrupted ext4 Directories Can Expose Kernel Memory or Crash Linux
The article's text, from Joho no Todai's page.
On December 6, 2026, two reports and proposed fixes for directory metadata bugs in ext4 appeared on the Linux kernel development mailing list. Piyus Kedia and Kapil Vaswani examined directory reads and indexing.
An ext4 directory maps file names to inode numbers that identify file metadata. Directory entries also record their length. ext4 can use an index called an HTree, based on hashes of file names, to keep lookups efficient as the directory grows.
The first block of the index, called the root block, stores the standard entries . for the directory itself and .. for its parent. The issue concerns how ext4 handles these special entries.
According to the report, directory reads validate index metadata, but bounds checking was incomplete for the special entries. With corrupted metadata, the kernel could read beyond the directory block and return some of that memory as directory data.
In the researchers’ tests, an unprivileged user received kernel address information. The results included pointers into dynamically allocated memory and addresses in the kernel’s code region. Those addresses could reveal information about the kernel’s memory layout.
Before patching, the researchers attempted 29 directory reads across six boots. None returned a valid .. entry. Each returned unexpected data or failed. Kernel Address Sanitizer (KASAN), a detector for invalid kernel memory accesses, reported issues on four boots. On the other two, the researchers said KASAN had not marked the memory that was read as inaccessible.
The out-of-bounds read also occurred with metadata checksums enabled and after checksum verification succeeded. A valid checksum does not establish that the positions and lengths in metadata are within bounds.
The proposed patch extends the checks used for ordinary directory entries to the special entries in the index. If a check fails, ext4 returns a filesystem corruption error.
After applying the patch, the researchers performed 29 reads across three boots. Corrupted metadata produced errors, and KASAN reported no invalid accesses. Reads of valid directories succeeded before and after patching.
Two ext4 directory bugs: Causes and effects
| Comparison | Directory reads | Indexing |
|---|---|---|
| Shared prerequisite: A malformed ext4 image mounted with administrative privileges | ||
| Affected case | Indexed directory | Checksums enabled Before indexing |
| Cause | Special entries were insufficiently checked | Validation and copy bounds did not match |
| Test results | Kernel address data disclosed | Under some test conditions, memory corruption and a kernel panic |
| Ordinary user permissions | Read | Write and search |
| Proposed fix | Apply standard checks to special entries | Use the start of reserved checksum storage as the validation boundary |
Indexing and checksum storage used different bounds
The second issue occurs when ext4 creates a directory index. A regular directory with metadata checksums enabled reserves 12 bytes at the end of its block for the checksum.
When an existing directory needs an index, ext4 redistributes its entries and converts the original block into the root of the index.
The researchers’ analysis found that adding checksum storage changed the bounds for moving data, while some entry validation still used the end of the block as its boundary.
On corrupted input, the inconsistent bounds could produce an invalid length calculation. An unsigned integer underflow could make the resulting length far larger than the valid range.
Before patching, KASAN detected an out-of-bounds read request on all six boots. The requested length was about 4 GiB, the result of the invalid calculation.
In four tests configured to report only the first KASAN error, the invalid copy stopped, but subsequent memory initialization still ran. It affected other kernel memory, and a kernel panic stopped the system in all four tests.
The patch makes validation respect the reserved checksum storage when checksums are enabled. It aligns the bounds used by validation with those used when moving data.
After patching, KASAN reported no issues across three boots and the kernel issued no warnings. Creating a file in the corrupted directory returned an error. File creation and indexing succeeded in valid directories both before and after patching.
Mount privileges and who can be affected
The researchers reproduced the issues on Linux 7.4.0-rc5 and on a development branch whose ext4 code matched upstream mainline. Both issues required a malformed ext4 image to have already been mounted.
The researchers said mounting ext4 requires administrative privileges in the initial user namespace. After mounting, they confirmed that ordinary users with the relevant directory permissions could encounter the issues. They did not test whether automatic mounting of removable media could create the required conditions.
The user who mounts the image and the user affected may be different. Someone with no mount privileges can still be affected by later file operations when an administrator or a service mounts an image on their behalf.
The Linux kernel’s threat model defines what counts as a vulnerability. It treats bugs requiring a privileged mount of a malformed filesystem as ordinary bugs, even though some users may face security consequences.
Under that threat model, the classification also applies when unchecked filesystems are mounted automatically. The automount system is responsible for checking a filesystem before mounting it. If the checks miss a problem, the filesystem checking tools should be fixed.
Another researcher working on LLM-assisted test generation reported the read issue on November 17. In a December 4 reply, ext4 maintainer Theodore Ts’o said the volume of AI-discovered and other bug reports was keeping him busy and that issues involving malformed filesystems were low priority. He said performance and maintainability would factor into decisions about accepting patches.
Risk depends on which conditions can arise in a given environment and what consequences follow. Mounting filesystem images from sources you do not trust warrants particular caution.
AI reviews a proposed fix for a bug discovered with AI
The researcher who reported the read issue on November 17 submitted a revised patch on December 5. It adds a consistency check for the parent directory entry. After feedback from an AI code review, the revision validates the entry before saving it.
At 13:14 UTC on December 6, the AI code reviewer Sashiko identified two potential issues in the read-side patch from Kedia and Vaswani. It flagged the possibility of a remaining out-of-bounds read and the possibility that data saved before validation could survive a failed check.
Sashiko reported no findings in the indexing patch. A potential issue flagged in code review differs from a reproduced failure. A patch with no review findings still needs independent validation.
Two ext4 patches: Testing and AI review
| What was checked | Directory reads | Indexing |
|---|---|---|
| Malformed ext4 image mounted with administrative privileges KASAN used to detect invalid memory access | ||
| Before the patches: KASAN reports | 4 of 6 boots | 6 of 6 boots |
| After the patches: KASAN reports | 0 of 3 boots | 0 of 3 boots |
| Before the patches: Operation results | All 29 reads returned unexpected data or errors | In tests that report only the first KASAN error, all four boots ended in a panic a kernel panic |
| After the patches: Operation results | All 29 reads Returned an error | when creating a file Returned an error |
| Valid directories (before and after) | Reads succeeded | File creation and indexing succeeded |
| AI code review on December 6, 2026 | ||
| Findings | Two concerns Out-of-bounds read Unvalidated data may persist | No findings |
Kedia and Vaswani discovered both bugs with an AI-assisted fuzzing environment based on syzkaller, which tests software with varied inputs to find unexpected behavior. In the read-side report, they said people checked the AI analysis against the code and reproduced the reported accesses.
Both proposed fixes were also sent to the stable kernel mailing list. The before-and-after testing is useful. A remaining question is whether the new validation can itself handle corrupted metadata safely.
AI discovery can start an investigation, and another AI can raise questions about the proposed fix. Has the bug been fixed safely? Users need a patch that rejects corrupted metadata while preserving normal file operations.
