CVE-2023-45898 Overview
CVE-2023-45898 is a use-after-free vulnerability in the Linux kernel affecting versions before 6.5.4. The flaw exists in the ext4 filesystem implementation, specifically in the fs/ext4/extents_status.c file within the ext4_es_insert_extent() function. This memory corruption vulnerability allows a local attacker with low privileges to potentially achieve arbitrary code execution, compromise system integrity, or cause denial of service conditions.
Critical Impact
Local attackers can exploit this use-after-free condition in the ext4 extents status handling to potentially execute arbitrary code with kernel privileges, leading to full system compromise.
Affected Products
- Linux Kernel versions before 6.5.4
- Systems using ext4 filesystem
Discovery Timeline
- 2023-10-16 - CVE-2023-45898 published to NVD
- 2025-05-05 - Last updated in NVD database
Technical Details for CVE-2023-45898
Vulnerability Analysis
This vulnerability is classified as CWE-416 (Use After Free), a memory corruption flaw that occurs when a program continues to use a pointer after the memory it references has been deallocated. In this case, the issue manifests in the ext4 filesystem's extent status tree handling code.
The vulnerable code path involves preallocated extent structures (es1 and es2) that are used in the ext4_es_insert_extent() function. The original implementation had a flaw where these preallocated extents could be freed at an incorrect point in the execution flow, allowing subsequent operations to access memory that had already been released back to the SLAB allocator.
When triggered, this use-after-free condition can lead to memory corruption within kernel space. An attacker with local access and the ability to perform filesystem operations on an ext4 mounted volume could potentially craft specific operations to trigger this vulnerability, leading to privilege escalation or arbitrary code execution with kernel privileges.
Root Cause
The root cause of this vulnerability lies in improper memory management of preallocated extent structures within the ext4_es_insert_extent() function. The original code freed preallocated extents at the end of the function without properly checking whether they had been consumed by intermediate operations. This created a window where the extent structures could be accessed after being freed, leading to a classic use-after-free condition.
The fix addresses this by immediately freeing preallocated extents after each operation that might consume them, and setting the pointers to NULL to prevent any subsequent accidental access.
Attack Vector
The attack vector is local, requiring an attacker to have authenticated access to the target system with the ability to perform filesystem operations on an ext4-mounted volume. The attacker must be able to trigger specific extent insertion and removal operations that expose the vulnerable code path. While local access is required, the low attack complexity and no user interaction requirement make this vulnerability exploitable once an attacker has basic system access.
The following patch was applied to fix the vulnerability:
err1 = __es_remove_extent(inode, lblk, end, NULL, es1);
if (err1 != 0)
goto error;
+ /* Free preallocated extent if it didn't get used. */
+ if (es1) {
+ if (!es1->es_len)
+ __es_free_extent(es1);
+ es1 = NULL;
+ }
err2 = __es_insert_extent(inode, &newes, es2);
if (err2 == -ENOMEM && !ext4_es_must_keep(&newes))
err2 = 0;
if (err2 != 0)
goto error;
+ /* Free preallocated extent if it didn't get used. */
+ if (es2) {
+ if (!es2->es_len)
+ __es_free_extent(es2);
+ es2 = NULL;
+ }
if (sbi->s_cluster_ratio > 1 && test_opt(inode->i_sb, DELALLOC) &&
(status & EXTENT_STATUS_WRITTEN ||
status & EXTENT_STATUS_UNWRITTEN))
__revise_pending(inode, lblk, len);
-
- /* es is pre-allocated but not used, free it. */
- if (es1 && !es1->es_len)
- __es_free_extent(es1);
Source: GitHub Commit by Torvalds
Detection Methods for CVE-2023-45898
Indicators of Compromise
- Kernel crash logs or oops messages referencing ext4_es_insert_extent or fs/ext4/extents_status.c
- KASAN (Kernel Address Sanitizer) reports indicating slab-use-after-free in ext4 extent status functions
- Unexpected system crashes or instability during heavy ext4 filesystem operations
- Memory corruption artifacts in kernel logs related to SLAB allocator
Detection Strategies
- Enable KASAN in kernel debug builds to detect use-after-free conditions at runtime
- Monitor system logs for kernel oops or panic events related to ext4 filesystem code paths
- Implement file integrity monitoring on critical system binaries to detect post-exploitation activity
- Use kernel live patching status monitoring to verify patch deployment
Monitoring Recommendations
- Configure centralized logging to capture all kernel-level crash reports and memory safety violations
- Deploy endpoint detection and response (EDR) solutions capable of monitoring kernel-level activity
- Monitor for unusual ext4 filesystem operation patterns that could indicate exploitation attempts
- Track kernel version deployments across infrastructure to identify unpatched systems
How to Mitigate CVE-2023-45898
Immediate Actions Required
- Upgrade Linux kernel to version 6.5.4 or later immediately
- Review and apply stable kernel backport patches for supported distributions
- Audit systems for signs of exploitation, particularly kernel crash logs related to ext4
- Prioritize patching on systems with untrusted local users or multi-tenant environments
Patch Information
The vulnerability has been patched in Linux kernel version 6.5.4. The fix is available through the GitHub Commit by Torvalds with commit hash 768d612f79822d30a1e7d132a4d4b05337ce42ec. The patch ensures that preallocated extent structures are freed immediately after the operations that might consume them, and sets the pointers to NULL to prevent subsequent access. Additional details are available in the Linux Kernel ChangeLog 6.5.4 and the LKML Discussion 2023-08-13.
Workarounds
- Restrict local system access to trusted users only until patches can be applied
- Consider temporarily mounting ext4 filesystems with reduced functionality or read-only mode on critical systems
- Implement mandatory access control policies (SELinux, AppArmor) to limit filesystem operations for untrusted processes
- Monitor and limit resource usage for processes interacting with ext4 filesystems
# Check current kernel version
uname -r
# Verify if running a vulnerable kernel version (versions below 6.5.4 are affected)
# Update to patched kernel version through your distribution's package manager
# For Debian/Ubuntu systems:
sudo apt update && sudo apt upgrade linux-image-generic
# For RHEL/CentOS systems:
sudo yum update kernel
# Reboot to apply the new kernel
sudo reboot
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


