Linux filesystem development
 help / color / mirror / Atom feed
From: Matthias Goergens <matthias.goergens@gmail.com>
To: jack@suse.cz
Cc: benquike@gmail.com, brauner@kernel.org, viro@zeniv.linux.org.uk,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] isofs: reject short directory records in isofs_read_level3_size()
Date: Fri, 25 Sep 2026 12:38:04 +0800	[thread overview]
Message-ID: <20260925043804.2091174-1-matthias.goergens@gmail.com> (raw)
In-Reply-To: <20260924151356.3287733-1-matthias.goergens@gmail.com>

Hi Honza,

On Thu, Sep 24, 2026 at 11:13:56PM +0800, Matthias Goergens wrote:
> Either way, I'll first check a set of real images for empty directory
> blocks, so we know the check doesn't reject discs that mount today.

Empty directory blocks do occur: about 1% of the disc images I checked
on archive.org have them, mostly from Easy CD Creator 4.0 to 4.2 and
Nero, and always at the end of a directory.  One of them hangs on
for_next, see [1].  Two more examples, with the bytes used in each
block of the directory:

  https://archive.org/details/Anime_Transformer  DM_BXL2.iso
    /XTRAS    2022 1526 empty   (Easy CD Creator 4.2)
  https://archive.org/details/comdex-edu  Comdex_05.iso
    /IMAGES   2012 2048 empty   (Nero)

So a general check in readdir or lookup would stop those discs from
mounting.

In isofs_read_level3_size() it would reject none of them: no empty block
on those discs follows a record with the multi-extent flag, so the walk
always ends first.  What refusing buys is limited to crafted images,
where a flagged record followed by empty blocks makes the walk skip
block after block until a read fails, because the 100-section limit
counts records, not blocks.

No other reader I looked at rejects them: Microsoft's published CDFS
sample, GRUB, libarchive, libcdio, 7-Zip and libisofs all skip empty
blocks inside a multi-extent chain and stop at the end of the directory,
and GRUB fixed an unbounded walk that way in 4e0bab34ece7 ("fs/iso9660:
Add check to prevent infinite loop").  Windows Server 2022 and 2025 also
join the sections across an empty block and return the whole file.

So I'd suggest following their lead: skip empty blocks in the walk as
readdir and lookup do, and stop at the end of the directory.
isofs_read_level3_size() doesn't know where the directory ends today,
though.  isofs_lookup() does and could pass it down through
__isofs_iget(), but inodes reached from an NFS file handle can't, so
those would still need a bound such as counting skipped blocks towards
the 100-section limit.  If that is more plumbing than you'd like, the
counting alone would do.  What would you prefer?

Whatever the bound, only a zero length at the start of a block should
count as an empty block.  A multi-extent record can end one block with
padding and its next section start the following one; that has to keep
working.

Thanks,
Matthias

[1] https://lore.kernel.org/all/20260925042835.1974673-1-matthias.goergens@gmail.com/

  reply	other threads:[~2026-09-25  4:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 22:25 [PATCH] isofs: reject short directory records in isofs_read_level3_size() Hui Peng
2026-09-23 17:52 ` Matthias Goergens
2026-09-24 15:03   ` Jan Kara
2026-09-24 15:13     ` Matthias Goergens
2026-09-25  4:38       ` Matthias Goergens [this message]
2026-09-25  9:28         ` Jan Kara
2026-09-25 11:22           ` Matthias Goergens
2026-09-26  8:35           ` [PATCH] isofs: bound empty directory blocks " Matthias Goergens
2026-09-29 10:57             ` Jan Kara
2026-09-30  3:39               ` Matthias Goergens
2026-09-30 10:33                 ` Jan Kara
2026-10-01 10:30                   ` Matthias Goergens
2026-10-02 10:55                     ` Jan Kara

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=20260925043804.2091174-1-matthias.goergens@gmail.com \
    --to=matthias.goergens@gmail.com \
    --cc=benquike@gmail.com \
    --cc=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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