CVE-2024-40943: ocfs2: fix races between hole punching and AIO+DIO
In the Linux kernel, the following vulnerability has been resolved:
ocfs2: fix races between hole punching and AIO+DIO
After commit "ocfs2: return real error code in ocfs2_dio_wr_get_block",
fstests/generic/300 become from always failed to sometimes failed:
========================================================================
[ 473.293420 ] run fstests generic/300
[ 475.296983 ] JBD2: Ignoring recovery information on journal
[ 475.302473 ] ocfs2: Mounting device (253,1) on (node local, slot 0) with ordered data mode.
[ 494.290998 ] OCFS2: ERROR (device dm-1): ocfs2_change_extent_flag: Owner 5668 has an extent at cpos 78723 which can no longer be found
[ 494.291609 ] On-disk corruption discovered. Please run fsck.ocfs2 once the filesystem is unmounted.
[ 494.292018 ] OCFS2: File system is now read-only.
[ 494.292224 ] (kworker/19:11,2628,19):ocfs2_mark_extent_written:5272 ERROR: status = -30
[ 494.292602 ] (kworker/19:11,2628,19):ocfs2_dio_end_io_write:2374 ERROR: status = -3
fio: io_u error on file /mnt/scratch/racer: Read-only file system: write offset=460849152, buflen=131072
=========================================================================
In __blockdev_direct_IO, ocfs2_dio_wr_get_block is called to add unwritten
extents to a list. extents are also inserted into extent tree in
ocfs2_write_begin_nolock. Then another thread call fallocate to puch a
hole at one of the unwritten extent. The extent at cpos was removed by
ocfs2_remove_extent(). At end io worker thread, ocfs2_search_extent_list
found there is no such extent at the cpos.
T1 T2 T3
inode lock
...
insert extents
...
inode unlock
ocfs2_fallocate
__ocfs2_change_file_space
inode lock
lock ip_alloc_sem
ocfs2_remove_inode_range inode
ocfs2_remove_btree_range
ocfs2_remove_extent
^---remove the extent at cpos 78723
...
unlock ip_alloc_sem
inode unlock
ocfs2_dio_end_io
ocfs2_dio_end_io_write
lock ip_alloc_sem
ocfs2_mark_extent_written
ocfs2_change_extent_flag
ocfs2_search_extent_list
^---failed to find extent
...
unlock ip_alloc_sem
In most filesystems, fallocate is not compatible with racing with AIO+DIO,
so fix it by adding to wait for all dio before fallocate/punch_hole like
ext4.
Security readout for executives and security teams
Plain-English summary
A race condition in Linux OCFS2 can corrupt filesystem metadata when hole punching overlaps asynchronous direct I/O. The filesystem may protect itself by becoming read-only, interrupting writes and requiring offline repair. Exploitation requires local, low-privileged access and a system using OCFS2.
Executive priority
Prioritize affected shared or business-critical OCFS2 systems because successful triggering can corrupt data and stop writes. Patch through normal emergency-change procedures after identifying exposure. Lower priority for systems that do not mount OCFS2 or lack relevant local workload access.
Technical view
Concurrent fallocate hole punching can remove an unwritten OCFS2 extent before the direct-I/O completion worker marks it written. The worker then cannot locate the extent, producing on-disk corruption and potentially forcing the filesystem read-only. The kernel fix waits for outstanding direct I/O before fallocate or hole-punch processing.
Likely exposure
Exposure is limited to Linux systems using OCFS2 on affected kernel versions, particularly where local users or workloads can perform concurrent asynchronous direct I/O and hole punching. Systems not using OCFS2 are not implicated by the supplied evidence.
Exploitation context
The CVSS 3.1 score is 7.8 with local access, low complexity, low privileges, and no user interaction. The supplied record is not in KEV and provides no evidence of active exploitation. Demonstrated impact comes from filesystem regression testing that produced corruption and read-only operation.
Researcher notes
The failure involves synchronization between extent removal and direct-I/O completion, specifically around ip_alloc_sem and inode locking. The supplied trace shows ocfs2_search_extent_list failing after ocfs2_remove_extent removed the target extent. No CWE classification or public exploitation evidence is supplied.
Mitigation direction
Install a vendor-supported kernel containing the referenced OCFS2 fix.
Consult the Linux distribution's advisory to map fixed packages to deployed kernels.
Until patched, restrict untrusted local access to affected OCFS2 filesystems.
Back up important OCFS2 data before maintenance or recovery operations.
Validation and detection
Inventory running kernel versions and systems with mounted OCFS2 filesystems.
Confirm the installed kernel includes the applicable referenced stable-kernel fix.
Review kernel logs for OCFS2 corruption, missing extents, or read-only transitions.
Run vendor-approved regression testing only on disposable, backed-up test filesystems.
Generated from the cited source records. This long-tail analysis has not been individually reviewed by a named human.
Potential ATT&CK relevance
Conservative CVE-to-ATT&CK context
These mappings and lookup hints may be relevant to the vulnerability behavior, CWE, affected product, or exposure path. Glexia-inferred context is not an official MITRE, ATT&CK, CWE, or CVE Program mapping.
ATT&CK lookup starting points
Use these exact CWE pages and searches to review the Glexia ATT&CK library from this CVE's weakness and description context.
cve · low confidence lookup
CVE-2024-40943 mapping review
Open the CVE-to-ATT&CK bridge for reviewed, inferred, or future official mappings tied to this CVE.
These fields come from the CVE record and ADP containers, not from Glexia's Take. They preserve time-varying source decisions such as CISA SSVC, KEV status, CVSS metrics, and provider references.
We collect every scored CVSS vector available in the official CNA and ADP containers. When more than one version is present, the table keeps the source vectors side by side instead of collapsing them into the highest score.