From: Christoph Hellwig <hch@infradead.org>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: cem@kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 02/12] xfs: improve dirent bounds checking in scrub and repair
Date: Sun, 27 Sep 2026 23:37:37 -0700 [thread overview]
Message-ID: <aroLMeT0OiY37AnN@infradead.org> (raw)
In-Reply-To: <179057612639.479634.13348969749056583205.stgit@frogsfrogsfrogs>
On Sun, Sep 27, 2026 at 11:16:20PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
>
> LOLLM complains that we don't do enough bounds checking of the directory
> entries in directory blocks when we're looking for errors or trying to
> salvage entries. Let's improve that with more detailed checks.
>
> Cc: <stable@vger.kernel.org> # v4.16
> Fixes: ce92d29ddf9908 ("xfs: directory scrubber must walk through data block to offset")
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> Assisted-by: LOLLM # finding obvious bugs
> ---
> fs/xfs/scrub/dir.c | 56 +++++++++++++++++++++++++++++++++++++++++----
> fs/xfs/scrub/dir_repair.c | 30 +++++++++++++++++++++++-
> 2 files changed, 79 insertions(+), 7 deletions(-)
>
>
> diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
> index a63eebf39fd496..dd21570378b281 100644
> --- a/fs/xfs/scrub/dir.c
> +++ b/fs/xfs/scrub/dir.c
> @@ -340,6 +340,7 @@ xchk_dir_rec(
> xfs_dahash_t hash;
> struct xfs_dir3_icleaf_hdr hdr;
> unsigned int tag;
> + bool foundit = false;
> int error;
>
> ASSERT(blk->magic == XFS_DIR2_LEAF1_MAGIC ||
> @@ -390,22 +391,60 @@ xchk_dir_rec(
> xchk_fblock_set_corrupt(ds->sc, XFS_DATA_FORK, rec_bno);
> goto out_relse;
> }
> - for (;;) {
> + while (iter_off < end) {
Nit: maybe move the iter_off initialization just above this for
clarify?
> struct xfs_dir2_data_entry *dep = bp->b_addr + iter_off;
> struct xfs_dir2_data_unused *dup = bp->b_addr + iter_off;
> + unsigned int advance;
>
> - if (iter_off >= end) {
> + /* must have freetag */
> + if (iter_off + offsetof(struct xfs_dir2_data_unused, length) >= end) {
Overly long line.
In general it feels like the inner body would benefit from being
split into a helper for readability given how big it becomes. That
would also ease deduplicating the xchk_fblock_set_corrupt calls.
next prev parent reply other threads:[~2026-09-28 6:37 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 6:15 [PATCHSET] xfs: LLM-inspired bug fixes, part 19 Darrick J. Wong
2026-09-28 6:16 ` [PATCH 01/12] xfs: be extra careful about replacement directory construction Darrick J. Wong
2026-09-28 6:34 ` Christoph Hellwig
2026-09-29 3:59 ` Darrick J. Wong
2026-09-28 6:16 ` [PATCH 02/12] xfs: improve dirent bounds checking in scrub and repair Darrick J. Wong
2026-09-28 6:37 ` Christoph Hellwig [this message]
2026-09-29 4:12 ` Darrick J. Wong
2026-09-28 6:16 ` [PATCH 03/12] xfs: abort dirtree repair if the live update hook dies Darrick J. Wong
2026-09-28 6:38 ` Christoph Hellwig
2026-09-28 6:16 ` [PATCH 04/12] xfs: bail out of directory tree repairs on error Darrick J. Wong
2026-09-28 8:07 ` Christoph Hellwig
2026-09-28 6:17 ` [PATCH 05/12] xfs: fix revalidation of xchk_dquot_iter cached mappings Darrick J. Wong
2026-09-28 8:08 ` Christoph Hellwig
2026-09-28 6:17 ` [PATCH 06/12] xfs: don't repair fs summary counters with garbage Darrick J. Wong
2026-09-28 8:08 ` Christoph Hellwig
2026-09-28 6:17 ` [PATCH 07/12] xfs: allow softlimit with no hardlimit in quota scrub Darrick J. Wong
2026-09-28 8:08 ` Christoph Hellwig
2026-09-28 6:17 ` [PATCH 08/12] xfs: assign an owner to scrub_stats_fops Darrick J. Wong
2026-09-28 8:09 ` Christoph Hellwig
2026-09-28 6:18 ` [PATCH 09/12] xfs: fix lost errno returned from xfarray_foliosort Darrick J. Wong
2026-09-28 8:09 ` Christoph Hellwig
2026-09-28 6:18 ` [PATCH 10/12] xfs: fix skipped inode mask handling in iscan Darrick J. Wong
2026-09-28 8:10 ` Christoph Hellwig
2026-09-28 6:18 ` [PATCH 11/12] xfs: don't proceed with xattr repair if the live update fails Darrick J. Wong
2026-09-28 8:10 ` Christoph Hellwig
2026-09-28 6:18 ` [PATCH 12/12] xfs: don't fix the directory tree if " Darrick J. Wong
2026-09-28 8:10 ` Christoph Hellwig
2026-10-08 13:32 ` [PATCHSET] xfs: LLM-inspired bug fixes, part 19 Carlos Maiolino
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=aroLMeT0OiY37AnN@infradead.org \
--to=hch@infradead.org \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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