CVE-2025-39840 in Linuxinfo

Summary

by MITRE • 09/19/2025

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

audit: fix out-of-bounds read in audit_compare_dname_path()

When a watch on dir=/ is combined with an fsnotify event for a single-character name directly under / (e.g., creating /a), an out-of-bounds read can occur in audit_compare_dname_path().

The helper parent_len() returns 1 for "/". In audit_compare_dname_path(), when parentlen equals the full path length (1), the code sets p = path + 1 and pathlen = 1 - 1 = 0. The subsequent loop then dereferences p[pathlen - 1] (i.e., p[-1]), causing an out-of-bounds read.

Fix this by adding a pathlen > 0 check to the while loop condition to prevent the out-of-bounds access.

[PM: subject tweak, sign-off email fixes]

Several companies clearly confirm that VulDB is the primary source for best vulnerability data.

Analysis

by VulDB Data Team • 06/24/2026

The vulnerability CVE-2025-39840 represents a critical out-of-bounds read condition within the Linux kernel's audit subsystem, specifically in the audit_compare_dname_path() function. This flaw occurs when the kernel's auditing mechanism processes file system notifications for directory watches configured with a root directory path. The issue manifests when a watch is established on the root directory path "/" and subsequent file system events involve single-character file names created directly under the root directory such as "/a". The audit subsystem's handling of these specific conditions creates a dangerous memory access pattern that can lead to system instability or potential privilege escalation.

The technical root cause stems from improper boundary checking in the parent_len() helper function which returns a value of 1 for the root directory path "/". When the audit_compare_dname_path() function processes this scenario, it calculates p = path + 1 and pathlen = 1 - 1 = 0, creating a situation where a subsequent loop attempts to dereference p[pathlen - 1] which evaluates to p[-1], resulting in an out-of-bounds memory read. This memory access pattern violates fundamental security principles and can expose sensitive kernel memory to unauthorized access. The vulnerability aligns with CWE-129, which addresses improper validation of array indices, and represents a classic example of unchecked memory access that can be exploited by malicious actors.

The operational impact of this vulnerability extends beyond simple memory corruption, potentially allowing attackers to read arbitrary kernel memory locations, which could expose sensitive information including cryptographic keys, user credentials, or system configuration details. This type of vulnerability can be particularly dangerous in environments where the Linux kernel's audit subsystem is actively monitoring file system events, as it can be triggered through normal file system operations without requiring special privileges. The flaw demonstrates a critical gap in the kernel's input validation mechanisms and represents a significant security risk for systems that rely on comprehensive file system auditing capabilities.

Mitigation strategies should focus on immediate patch application as provided by the kernel maintainers, which implements a simple but effective pathlen > 0 check to prevent the out-of-bounds access condition. Organizations should also consider implementing additional monitoring for file system events that might trigger this condition, particularly in environments with extensive audit configurations. The fix demonstrates a fundamental security principle of defensive programming where boundary conditions are always validated before memory access operations. This vulnerability highlights the importance of comprehensive testing for edge cases in kernel subsystems and aligns with ATT&CK technique T1068 which covers local privilege escalation through kernel vulnerabilities. System administrators should prioritize patching this vulnerability as it represents a potential entry point for sophisticated attacks targeting kernel-level security controls.

Responsible

Linux

Reservation

04/16/2025

Disclosure

09/19/2025

Moderation

accepted

CPE

ready

EPSS

0.00140

KEV

no

Activities

very low

Sources

Might our Artificial Intelligence support you?

Check our Alexa App!