In the Linux kernel, the following vulnerability has been resolved:
ocfs2: validate directory-index entry counts when reading metadata
ocfs2_validate_dx_leaf() and ocfs2_validate_dx_root() check the ECC and
signature of an indexed-directory block before it reaches higher-level
callers, but neither validator bounds the ocfs2_dx_entry_list counts
against the capacity of the block that holds them.
ocfs2_dx_dir_search() then walks
<pre>
for (i = 0; i < le16_to_cpu(entry_list->de_num_used); i++)
dx_entry = &entry_list->de_entries[i];
</pre>
over de_num_used entries with no bounds check. entry_list is either
dx_leaf->dl_list (from ocfs2_read_dx_leaf) or, for an inline root,
dx_root->dr_entries. A crafted on-disk image can set de_num_used (and
de_count, which is the __counted_by_le() bound of de_entries) to 0xffff
and make the walk read far past the end of the 4KB metadata block, giving
a slab out-of-bounds read reachable from any path lookup, stat() or open()
on an indexed directory once the image is mounted.
Commit 775c17386a6f ("ocfs2: validate dx_root extent list fields during
block read") already bounds dr_list for the non-inline dx_root, but left
the inline dr_entries path and the dx_leaf dl_list unchecked. Add the
same read-time validation for both entry lists: de_count must equal the
capacity of the block (ocfs2_dx_entries_per_leaf()/per_root()) and
de_num_used must not exceed de_count, rejecting corrupted metadata with
-EFSCORRUPTED before ocfs2_dx_dir_search() can walk an out-of-range entry
array.
de_count is always written as exactly the block capacity when a leaf or
inline root is formatted, so the equality check does not reject any valid
image.
Found by 0sec automated security-research tooling (https://0sec.ai).
CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
CVSS Score: 9.8
AV:N - OCFS2 sets s_export_op to ocfs2_export_ops and is commonly NFS-exported on shared cluster LUNs; remote nfsd LOOKUP/GETATTR/CREATE reach ocfs2_lookup→ocfs2_find_entry_dx→ocfs2_dx_dir_search (and create→ocfs2_dx_entry_list_insert) over the network with no local syscall on the server.
AC:L - The attacker fully controls on-disk de_num_used and de_count in a dx_root or dx_leaf; inflating them above the fixed 4K-block capacity (e.g. 0xffff with de_num_used still below de_count) deterministically overflows the entry walk and insert with no race or attacker-uncontrollable layout.
PR:N - Triggering needs only NFS LOOKUP or CREATE on an exported directory, including guest or anonymous NFS, or any unprivileged accessor of a mounted volume holding the forged index; planting malformed directory-index metadata on shared cluster storage does not require init-namespace root on the victim.
UI:N - Once the OCFS2 volume is mounted and NFS-exported as a normal cluster or NAS deployment, the attacker triggers the overflow by their own LOOKUP, stat, open, or CREATE; no additional victim action such as mounting an image or opening a file is required.
S:U - The overflow corrupts kernel memory and OCFS2 metadata on the host that parses the forged directory index; it does not escape a VM, bypass an IOMMU, or otherwise cross into a separate security authority.
C:H - ocfs2_dx_dir_search walks de_num_used with no capacity check, so de_num_used of 0xffff reads far past the 4KB metadata block (up to about 1 MiB of adjacent kernel memory), an unbounded out-of-bounds read that enables high-impact disclosure.
I:H - When de_count is inflated past block capacity and de_num_used is still less than de_count, create/mkdir calls ocfs2_dx_entry_list_insert and writes a dx_entry at de_entries[de_num_used] past the block; unlink memmove is similarly unbounded, yielding an attacker-triggered kernel out-of-bounds write.
A:H - The unbounded out-of-bounds read on lookup and out-of-bounds write on create against kernel metadata buffers cause a kernel oops or panic, fully denying availability of the OCFS2 node until reboot.
| Attack Vector |
Network |
Scope |
Unchanged |
| Attack Complexity |
Low |
Confidentiality Impact |
High |
| Privileges Required |
None |
Integrity Impact |
High |
| User Interaction |
None |
Availability Impact |
High |
AV:N - OCFS2 sets s_export_op to ocfs2_export_ops and is commonly NFS-exported on shared cluster LUNs; remote nfsd LOOKUP/GETATTR/CREATE reach ocfs2_lookup→ocfs2_find_entry_dx→ocfs2_dx_dir_search (and create→ocfs2_dx_entry_list_insert) over the network with no local syscall on the server.
AC:L - The attacker fully controls on-disk de_num_used and de_count in a dx_root or dx_leaf; inflating them above the fixed 4K-block capacity (e.g. 0xffff with de_num_used still below de_count) deterministically overflows the entry walk and insert with no race or attacker-uncontrollable layout.
PR:N - Triggering needs only NFS LOOKUP or CREATE on an exported directory, including guest or anonymous NFS, or any unprivileged accessor of a mounted volume holding the forged index; planting malformed directory-index metadata on shared cluster storage does not require init-namespace root on the victim.
UI:N - Once the OCFS2 volume is mounted and NFS-exported as a normal cluster or NAS deployment, the attacker triggers the overflow by their own LOOKUP, stat, open, or CREATE; no additional victim action such as mounting an image or opening a file is required.
S:U - The overflow corrupts kernel memory and OCFS2 metadata on the host that parses the forged directory index; it does not escape a VM, bypass an IOMMU, or otherwise cross into a separate security authority.
C:H - ocfs2_dx_dir_search walks de_num_used with no capacity check, so de_num_used of 0xffff reads far past the 4KB metadata block (up to about 1 MiB of adjacent kernel memory), an unbounded out-of-bounds read that enables high-impact disclosure.
I:H - When de_count is inflated past block capacity and de_num_used is still less than de_count, create/mkdir calls ocfs2_dx_entry_list_insert and writes a dx_entry at de_entries[de_num_used] past the block; unlink memmove is similarly unbounded, yielding an attacker-triggered kernel out-of-bounds write.
A:H - The unbounded out-of-bounds read on lookup and out-of-bounds write on create against kernel metadata buffers cause a kernel oops or panic, fully denying availability of the OCFS2 node until reboot.
CVSS 3.1