Re: [PATCH RESEND] romfs: reject directory entry chains that do not move forward
From: Jan Kara
Date: Thu Oct 01 2026 - 05:43:28 EST
On Wed 30-09-26 18:33:28, Palla Raghunath wrote:
> On Tue, Sep 22, 2026 at 11:58:35AM +0200, Jan Kara wrote:
> > I doubt these bugs have any practical relevance so I wouldn't CC stable.
> > But I guess that's for Christian.
>
> Fair enough. I'll drop the stable tag if there is a v2.
>
> > The patch looks good, I'm just not sure we are guaranteed ROMFS directories
> > are indeed following monotonically increasing disk offset (although that's
> > the most logical thing to do) - added Dave to CC for that.
>
> Thanks for the review, Jan.
>
> Documentation/filesystems/romfs.rst doesn't state it, but genromfs
> always lays directories out that way. processdir() hands each entry the
> current offset, which only ever grows, and it places a subdirectory's
> contents straight after the subdirectory's own header, before the next
> sibling. Entries are added to the directory list in that same order,
> and dumpnode() writes each next pointer from that list, so within one
> directory every next pointer points forward. I don't know of any other
> tool that builds romfs images.
>
> If you'd rather not rely on that, I can bound the walk by the number of
> 16-byte header slots in the image instead. That stops a cycle without
> assuming any particular order. Happy to send a v2 either way.
After checking Documentation/filesystems/romfs.rst I agree that monotonely
increasing offsets were likely the intention despite it isn't stated there
explicitely. So I think your current version is fine. Thanks!
Honza
--
Jan Kara <jack@xxxxxxxx>
SUSE Labs, CR