ocfs2: harden inode validators against forged metadata
Status from this message: [merged mm-nonmm-stable] ocfs2-reject-non-inline-dinodes-with-i_size-and-zero-i_clusters.patch removed from -mm tree
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest3 patches 5 repliesApplied 3/3
- v13 patches 6 repliesSuperseded
Changes in v2 from the cover letter
- Patch 1 drops the tautological S_IFMT|07777 mask check and reuses fs_umode_to_ftype() for the canonical file-type predicate.
- Patch 1 mirrors the i_mode check in the online filecheck path.
- Patch 2 factors the i_rdev cross-check into a shared predicate.
- Patch 2 mirrors the i_rdev check in the online filecheck path.
- Patch 3 factors the size/cluster invariant into a shared predicate.
- Patch 3 extends the zero-cluster rejection to non-inline directories, while preserving the sparse regular-file carveout.
- Patch 3 mirrors the size/cluster check in the online filecheck path.
- Patches 1 and 3 add Link trailers to the Sashiko review Andrew pointed out.
Patches in v2 All 3 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | ocfs2: reject dinodes with non-canonical i_mode typefs/ | +34 | 2 replies | Applied |
| 2/3 | ocfs2: reject dinodes whose i_rdev disagrees with the file typefs/ | +55 | 2 replies | Applied |
| 3/3 | ocfs2: reject non-inline dinodes with i_size and zero i_clustersfs/ | +60 | 1 reply | Applied |
Reviews trailers per patch
All 3 patches have a Reviewed-by or Acked-by.
| Patch | Joseph Qi | Joel Becker |
|---|---|---|
| 1/3 | R-b | R-b |
| 2/3 | R-b | R-b |
| 3/3 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH v2 0/3] ocfs2: harden inode validators against forged metadata
This series adds three structural checks to OCFS2 dinode validation so malformed on-disk fields are rejected before ocfs2_populate_inode() copies them into the in-core inode.
The checks cover:
- i_mode values whose type bits do not name a canonical POSIX file
type;
- non-device dinodes whose id1.dev1.i_rdev field is non-zero; and
- non-inline dinodes that claim non-zero i_size while i_clusters is zero, covering directories unconditionally and regular files on non-sparse volumes.
The normal read path reports these through ocfs2_error(), matching the existing suballoc-slot, inline-data, chain-list, and refcount checks. The online filecheck path uses the same structural predicates but keeps its own reporting contract, returning OCFS2_FILECHECK_ERR_INVALIDINO instead of calling ocfs2_error().
Validation from v1 still applies to the unchanged reachability model.
---
Changes in v2:
- Patch 1 drops the tautological S_IFMT|07777 mask check and reuses fs_umode_to_ftype() for the canonical file-type predicate.
- Patch 1 mirrors the i_mode check in the online filecheck path.
- Patch 2 factors the i_rdev cross-check into a shared predicate.
- Patch 2 mirrors the i_rdev check in the online filecheck path.
- Patch 3 factors the size/cluster invariant into a shared predicate.
- Patch 3 extends the zero-cluster rejection to non-inline directories, while preserving the sparse regular-file carveout.
- Patch 3 mirrors the size/cluster check in the online filecheck path.
- Patches 1 and 3 add Link trailers to the Sashiko review Andrew pointed out.
Testing after v2:
- Replayed all three patches onto the original base, checked with checkpatch --strict, and applied cleanly with git am.
- Rebuilt a fresh bzImage from the v2-applied tree.
- Booted that v2 kernel five times under QEMU: sparse regular-file regression, non-sparse no-forge regression, forged non-canonical i_mode, forged non-device i_rdev, and forged non-zero i_size with zero i_clusters.
- The three forged dinodes were rejected by ocfs2_validate_inode_block(); the two unforged regression cases completed without validator errors.
Michael Bommarito (3):
ocfs2: reject dinodes with non-canonical i_mode type
ocfs2: reject dinodes whose i_rdev disagrees with the file type
ocfs2: reject non-inline dinodes with i_size and zero i_clusters
fs/ocfs2/inode.c | 151 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 149 insertions(+), 2 deletions(-)
Signature · 1 line
2.53.0