Programming · free software · the open webSubscribe via RSS

Corrupt filesystem metadata is still input to validate

A Linux 7.3.6 OCFS2 fix illustrates why on-disk metadata needs semantic checks before internal code treats it as impossible. The useful design boundary is between rejecting malformed state and asserting an invariant.

A disk structure crosses a trust boundary

Linux 7.3.6 was released on 23 November 2026. Its changelog includes an OCFS2 fix for inconsistent local extended-attribute entries. The report describes an on-disk entry that sets the local-value flag while claiming a value larger than the filesystem’s inline-value capacity. A later cleanup path reached an assertion that assumed this combination could not exist, and the kernel hit a BUG and emitted an oops. The backport validates the relationship in metadata checks and before selected entries are consumed, returning a filesystem-corruption error instead. [1]

The release date and the fix’s development date are different facts. The stable changelog labels the original upstream commit as dated 6 August; 7.3.6 is the release that includes it on 23 November. That distinction matters in a release report: a recent package can carry an older fix, and “included in this release” does not mean “introduced yesterday.” The event covered here is the 7.3.6 release, while the patch itself is an upstream backport. [1]

A storage bound is not a semantic invariant

A parser can establish that a byte range fits inside a block and still accept a nonsensical record. OCFS2’s problematic entry satisfied a broad storage-region check, but its flag and value size contradicted one another: local storage is inline, so its declared size must not exceed the inline limit. The code that later computed name-and-value storage relied on that stronger fact. When validation checked only the weaker bound, an impossible-looking state crossed the boundary into ordinary filesystem operations.

This is a common parsing mistake in systems code. Bounds checks answer “can these bytes be read safely from this buffer?” Semantic checks answer “does this combination of fields describe a state the format permits?” A record may pass the first and fail the second. For each flag that selects a representation, list the permitted size range, alignment, ownership and pointer relationships. Then check those relationships where data enters the trusted in-memory representation, before helpers rely on them.

Assertions belong after validation, not in place of it

An assertion is useful when it checks a condition the program’s own control flow guarantees. It is a poor substitute for checking bytes that came from a disk, peer, device or other external source. Those bytes can be truncated, stale, corrupted or intentionally malformed. A kernel BUG can disrupt more than the filesystem operation. The Linux coding-style guidance says not to add BUG variants without strong justification. It recommends WARN variants for unexpected kernel conditions where recovery may be possible, while cautioning that warnings are unsuitable for conditions expected through ordinary user actions. Malformed on-disk state should follow the filesystem’s corruption/error path; the OCFS2 fix does exactly that. [2] [1]

The distinction is not “assertions are bad.” After a parser has established an invariant, an internal assertion can document an assumption and expose a programming mistake during development. The design failure occurs when untrusted representation data reaches that assertion without a recoverable validation step. A filesystem should generally identify corrupt metadata, stop the operation that depends on it, and return the subsystem’s corruption error rather than convert damaged input into a system-wide failure. The precise recovery choice depends on whether the code can safely continue; the coding guidance does not require continuing after every error.

Validate at boundaries and again at risky consumers

The 7.3.6 changelog describes checks in the existing flat and bucket metadata validators, plus checks before accepting matched entries or traversing bucket entries on paths that call the size helper. That is a useful layered pattern. The main validators prevent malformed state from becoming the normal representation. Local checks at sensitive consumers protect operations that can also encounter cached entries or less common traversal paths. One layer defines the format; the other makes a critical assumption explicit where it matters. [1]

For a worked review, write the invariant as a small table. If the local flag is clear, identify the external-value representation and its legal bounds. If it is set, require the inline representation and a size at or below the inline capacity. Test both valid forms, the exact maximum, one byte beyond the maximum, contradictory flags, truncated metadata and entries found through each supported bucket path. A malformed case should produce the documented corruption result before any helper indexes, copies or removes the value. These are test cases derived from the changelog’s invariant, not a claim that the article ran them against a kernel build.

Treat corruption handling as part of the format contract

The same reasoning applies to network frames, compiler object files, database pages and serialized caches. A format is not fully specified by field offsets. It also defines which field combinations are legal and what the program does when they are not. If validation is spread across distant consumers, one code path will eventually assume more than another has proved. Centralize the structural checks, document representation-specific invariants, and make consumers that can receive partially validated or cached state state their preconditions clearly.

Linux 7.3.6 is a recent, dated example of this maintenance work, not evidence that every filesystem corruption bug is exploitable or that the release fixed a vulnerability with a particular threat model. The changelog says that malformed OCFS2 metadata could reach a kernel BUG and that the fix returns a corruption error after strengthening validation. That is enough to extract a useful engineering rule: data does not become trustworthy merely because a later helper expects a particular shape. Validate the shape at the boundary, preserve the invariant through caches and alternate paths, and reserve fatal assertions for conditions the program can actually prove impossible. [1] [2]

References

  1. Linux 7.3.6 stable changelog: OCFS2 local xattr validation
  2. Linux kernel coding style: avoid crashing the kernel

Suggest a correction · All posts