Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: cem@kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/6] xfs: check di_forkoff correctly in scrub
Date: Fri, 11 Sep 2026 08:59:19 -0700	[thread overview]
Message-ID: <20260911155919.GG6265@frogsfrogsfrogs> (raw)
In-Reply-To: <20260911150745.GA26822@lst.de>

On Fri, Sep 11, 2026 at 05:07:45PM +0200, Christoph Hellwig wrote:
> On Thu, Sep 10, 2026 at 10:54:58PM -0700, Darrick J. Wong wrote:
> > The di_forkoff check in xchk_dinode is incorrect, according to LOLLM.
> > XFS_DFORK_BOFF returns a byte count relative to the start of the literal
> > area, not the start of the inode.  Therefore, this check won't flag
> > di_forkoff values that are larger than the literal area but not the
> > inode size itself.  Fix this check; sadly the old APTR code was correct.
> 
> The fi looks good, but I really which we could encapsulate this
> magic >> 3 a bit better (here and elsewhere).

I /did/ think about adding a cleanup to do:

#define XFS_B_TO_FORKOFF(b)	((b) >> 3)
#define XFS_FORKOFF_TO_B(f)	((f) << 3)

and then code like this:

fs/xfs/libxfs/xfs_attr_leaf.c:782:      minforkoff = max_t(int64_t, dsize, xfs_bmdr_space_calc(MINDBTPTRS));
fs/xfs/libxfs/xfs_attr_leaf.c:783:      minforkoff = roundup(minforkoff, 8) >> 3;
fs/xfs/libxfs/xfs_attr_leaf.c:786:      maxforkoff = XFS_LITINO(mp) - xfs_bmdr_space_calc(MINABTPTRS);
fs/xfs/libxfs/xfs_attr_leaf.c:787:      maxforkoff = maxforkoff >> 3;   /* rounded down */

becomes:

	minforkoff = XFS_B_TO_FORKOFF(max_t(int64_t, dsize,
				xfs_bmdr_space_calc(MINDBTPTRS)));
	maxforkoff = XFS_B_TO_FORKOFF(XFS_LITINO(mp) -
				xfs_bmdr_space_calc(MINABTPTRS));

There aren't as many users of FORKOFF_TO_B though:

static inline unsigned int xfs_inode_fork_boff(struct xfs_inode *ip)
{
	return XFS_FORKOFF_TO_B(ip->i_forkoff);
}

> Reviewed-by: Christoph Hellwig <hch@lst.de>

Thanks!

--D

  reply	other threads:[~2026-09-11 15:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11  5:53 [PATCHSET] xfs: LLM-inspired bug fixes, part 14 Darrick J. Wong
2026-09-11  5:53 ` [PATCH 1/6] xfs: check padding field in xfs_ioc_commit_range Darrick J. Wong
2026-09-11  7:14   ` Christoph Hellwig
2026-09-11  5:53 ` [PATCH 2/6] xfs: don't call xfs_exchange_range_finish for a dry run Darrick J. Wong
2026-09-11  7:14   ` Christoph Hellwig
2026-09-11  5:54 ` [PATCH 3/6] xfs: use the correct reservations for rtrmap/refcount recovery Darrick J. Wong
2026-09-11  7:15   ` Christoph Hellwig
2026-09-11  5:54 ` [PATCH 5/6] xfs: only flag zero padding for dir3 data blocks, not dir3 block blocks Darrick J. Wong
2026-09-11  7:16   ` Christoph Hellwig
2026-09-11  5:54 ` [PATCH 6/6] xfs: check di_forkoff correctly in scrub Darrick J. Wong
2026-09-11 15:07   ` Christoph Hellwig
2026-09-11 15:59     ` Darrick J. Wong [this message]
2026-09-15  6:39       ` Christoph Hellwig
2026-09-16 12:06 ` [PATCHSET] xfs: LLM-inspired bug fixes, part 14 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=20260911155919.GG6265@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=hch@lst.de \
    --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