Re: [PATCH] ext4: fix OOB write in fast-commit replay

From: Jan Kara

Date: Tue Nov 10 2026 - 07:33:52 EST


On Mon 09-11-26 21:47:51, Jérémy Jean wrote:
> On 2026-11-09 14:19, Jan Kara wrote:
> > On Sun 08-11-26 20:43:46, Jérémy Jean wrote:
> > > Fast-commit recovery checks record bounds and lengths during scan.
> > > Replay reads the records again without these checks. A corrupt
> > > filesystem
> > > can make an earlier replay operation overwrite a later record. Its new
> >
> > This fact looks like the real problem. I think we should validate the
> > replay does not corrupt the journal. How does this happen? Otherwise we
> > have to fully redo the validation of each record done in
> > ext4_fc_replay_scan().
>
> The replay can corrupt the journal because a corrupted image can make
> metadata blocks used during replay overlap with fast-commit blocks. I
> agree that making sure that replay does not corrupt the journal would
> be a stronger fix, but I'm not sure I see a simple way to fix this
> properly. Rechecking bounds as I proposed fixes a memory issue but it
> indeed does not address the root cause.

OK, I suspected that. So it would mean making sure jbd2 does not corrupt
the journal under itself. In ext4 we have "system blocks" infrastructure
for things like that - see ext4_setup_system_zone(). In jbd2 I guess we
could create something similar just for the time of replay - during the
scan pass we'd build a list of blocks belonging to the journal (just a
simple rb-tree with extents should be enough, under normal circumstances
there shouldn't be more than one or two extents there). During the replay
pass we'd verify the target locations of metadata blocks are not in the
journal. This would actually cover a larger class of journal replay attacks
than this particular one...

Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR