From: Michael Bommarito <michael.bommarito@gmail.com>
To: Joseph Qi <joseph.qi@linux.alibaba.com>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>
Cc: ZhengYuan Huang <gality369@gmail.com>,
ocfs2-devel@lists.linux.dev, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH v2 0/3] ocfs2: harden inode validators against forged metadata
Date: Tue, 19 May 2026 07:04:01 -0400 [thread overview]
Message-ID: <20260519110404.1803902-1-michael.bommarito@gmail.com> (raw)
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(-)
--
2.53.0
next reply other threads:[~2026-05-19 11:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 11:04 Michael Bommarito [this message]
2026-05-19 11:04 ` [PATCH v2 1/3] ocfs2: reject dinodes with non-canonical i_mode type Michael Bommarito
2026-05-19 12:21 ` Joseph Qi
2026-06-01 18:19 ` Joel Becker
2026-05-19 11:04 ` [PATCH v2 2/3] ocfs2: reject dinodes whose i_rdev disagrees with the file type Michael Bommarito
2026-05-19 12:21 ` Joseph Qi
2026-06-01 18:21 ` Joel Becker
2026-05-19 11:04 ` [PATCH v2 3/3] ocfs2: reject non-inline dinodes with i_size and zero i_clusters Michael Bommarito
2026-05-19 12:22 ` Joseph Qi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260519110404.1803902-1-michael.bommarito@gmail.com \
--to=michael.bommarito@gmail.com \
--cc=gality369@gmail.com \
--cc=jlbec@evilplan.org \
--cc=joseph.qi@linux.alibaba.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome