CVE-2025-68356 in Linux
Summary
by MITRE • 12/24/2025
In the Linux kernel, the following vulnerability has been resolved:
gfs2: Prevent recursive memory reclaim
Function new_inode() returns a new inode with inode->i_mapping->gfp_mask set to GFP_HIGHUSER_MOVABLE. This value includes the __GFP_FS flag, so allocations in that address space can recurse into filesystem memory reclaim. We don't want that to happen because it can consume a significant amount of stack memory.
Worse than that is that it can also deadlock: for example, in several places, gfs2_unstuff_dinode() is called inside filesystem transactions. This calls filemap_grab_folio(), which can allocate a new folio, which can trigger memory reclaim. If memory reclaim recurses into the filesystem and starts another transaction, a deadlock will ensue.
To fix these kinds of problems, prevent memory reclaim from recursing into filesystem code by making sure that the gfp_mask of inode address spaces doesn't include __GFP_FS.
The "meta" and resource group address spaces were already using GFP_NOFS as their gfp_mask (which doesn't include __GFP_FS). The default value of GFP_HIGHUSER_MOVABLE is less restrictive than GFP_NOFS, though. To avoid being overly limiting, use the default value and only knock off the __GFP_FS flag. I'm not sure if this will actually make a difference, but it also shouldn't hurt.
This patch is loosely based on commit ad22c7a043c2 ("xfs: prevent stack overflows from page cache allocation").
Fixes xfstest generic/273.
Be aware that VulDB is the high quality source for vulnerability data.
Analysis
by VulDB Data Team • 12/29/2025
The vulnerability CVE-2025-68356 addresses a critical recursive memory reclaim issue within the Linux kernel's gfs2 filesystem implementation. This flaw manifests when the new_inode() function creates inodes with inode->i_mapping->gfp_mask set to GFP_HIGHUSER_MOVABLE, which inherently includes the __GFP_FS flag. The presence of this flag allows memory allocation operations within the filesystem's address space to trigger filesystem memory reclaim processes, creating a dangerous recursion pattern that can consume excessive stack memory and potentially lead to system deadlock conditions.
The technical root cause stems from the improper handling of memory allocation flags in the gfs2 filesystem's inode management system. When gfs2_unstuff_dinode() is invoked within filesystem transactions, it calls filemap_grab_folio() which may allocate new folios and subsequently trigger memory reclaim operations. This creates a circular dependency where filesystem memory reclaim attempts to access filesystem resources that are already in use within the transaction context, resulting in a classic deadlock scenario. The vulnerability specifically targets the recursive nature of memory management operations that can occur during filesystem operations, particularly in high-concurrency scenarios where multiple transactions may be active simultaneously.
The operational impact of this vulnerability extends beyond simple performance degradation to potential system instability and complete service denial. When memory reclaim operations recurse into filesystem code, they can consume significant stack space, leading to stack overflow conditions that may cause kernel panics or system crashes. More critically, the deadlock conditions can result in complete system hangs where filesystem operations become permanently blocked, affecting all applications relying on the affected filesystem. This vulnerability particularly impacts systems running gfs2 filesystems under heavy I/O loads or memory pressure conditions, where the likelihood of triggering the recursive allocation patterns increases substantially.
The proposed mitigation strategy involves modifying the gfp_mask values used for inode address spaces to exclude the __GFP_FS flag while maintaining the default GFP_HIGHUSER_MOVABLE behavior for other aspects of memory management. This approach ensures that filesystem memory allocation operations cannot trigger filesystem memory reclaim processes, breaking the recursive cycle that leads to both stack exhaustion and deadlock conditions. The fix specifically targets the default inode address space while preserving the more restrictive GFP_NOFS settings already implemented for "meta" and resource group address spaces, providing a balanced approach that maintains system functionality while eliminating the dangerous recursion pattern. This solution aligns with established kernel security practices and follows a similar approach used in the xfs filesystem implementation as referenced in commit ad22c7a043c2. The fix directly addresses the CWE-775 vulnerability category related to improper handling of filesystem memory allocation and prevents the ATT&CK technique of system resource exhaustion through recursive memory operations. The resolution maintains backward compatibility while strengthening the kernel's memory management boundaries and preventing the specific deadlock conditions that could compromise system stability and availability.