From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@infradead.org>
Cc: cem@kernel.org, stable@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 10/12] xfs: check for buffer overruns when examining local/remote xattr entries
Date: Thu, 8 Oct 2026 09:17:46 -0700 [thread overview]
Message-ID: <20261008161746.GS2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <aseGmj8np-ovaiuh@infradead.org>
On Thu, Oct 08, 2026 at 05:03:38AM -0700, Christoph Hellwig wrote:
> On Wed, Oct 07, 2026 at 10:57:26PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <djwong@kernel.org>
> >
> > LOLLM noticed that the xattr scrub and repair code can walk off the end
> > of the buffer if the xattr entry record starts so close to the end of
> > the buffer that there's not even space for the entry structure itself.
> > Strengthen the bounds checking here.
> >
> > Cc: <stable@vger.kernel.org> # v4.15
> > Fixes: 13791d3b833428 ("xfs: scrub extended attribute leaf space")
> > Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> > Assisted-by: LOLLM # finding obvious bugs
> > ---
> > fs/xfs/scrub/attr.c | 12 ++++++++++++
> > fs/xfs/scrub/attr_repair.c | 16 ++++++++++++++--
> > 2 files changed, 26 insertions(+), 2 deletions(-)
> >
> >
> > diff --git a/fs/xfs/scrub/attr.c b/fs/xfs/scrub/attr.c
> > index 842d65834afbc9..4ce7299060fbba 100644
> > --- a/fs/xfs/scrub/attr.c
> > +++ b/fs/xfs/scrub/attr.c
> > @@ -335,6 +335,12 @@ xchk_xattr_entry(
> > /* Check the name information. */
> > if (ent->flags & XFS_ATTR_LOCAL) {
> > lentry = xfs_attr3_leaf_name_local(leaf, idx);
> > + name_end = (char *)lentry +
> > + offsetof(struct xfs_attr_leaf_name_local, nameval[0]);
>
> Overly long line.
>
> > + if (name_end > buf_end) {
> > + xchk_da_set_corrupt(ds, level);
> > + return;
> > + }
> > namesize = xfs_attr_leaf_entsize_local(lentry->namelen,
> > be16_to_cpu(lentry->valuelen));
> > name_end = (char *)lentry + namesize;
> > @@ -342,6 +348,12 @@ xchk_xattr_entry(
> > xchk_da_set_corrupt(ds, level);
> > } else {
> > rentry = xfs_attr3_leaf_name_remote(leaf, idx);
> > + name_end = (char *)rentry +
> > + offsetof(struct xfs_attr_leaf_name_remote, name[0]);
>
> Same here.
>
> Can you split the local vs remote code into separate helpers as
> that would really help with readability here?
Will do, as a prep patch that comes before this one.
> Also for this long type names just using typeof might be nicer than
> spelling out the type.
Ooh, that works. I'll fix that too.
--D
next prev parent reply other threads:[~2026-10-08 16:17 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-08 5:55 [PATCHSET] xfs: LLM-inspired bug fixes, part 21 Darrick J. Wong
2026-10-08 5:55 ` [PATCH 01/12] xfs: check for termination during rmap btree walk Darrick J. Wong
2026-10-08 11:52 ` Christoph Hellwig
2026-10-08 5:55 ` [PATCH 02/12] xfs: don't subtract excess usage twice when computing agf_btreeblks Darrick J. Wong
2026-10-08 11:54 ` Christoph Hellwig
2026-10-08 15:44 ` Darrick J. Wong
2026-10-08 5:55 ` [PATCH 03/12] xfs: abort directory tree repair whenever dl->aborted is set Darrick J. Wong
2026-10-08 11:54 ` Christoph Hellwig
2026-10-08 5:55 ` [PATCH 04/12] xfs: reattach dquots after changing inode ids Darrick J. Wong
2026-10-08 11:57 ` Christoph Hellwig
2026-10-08 17:20 ` Darrick J. Wong
2026-10-08 5:56 ` [PATCH 05/12] xfs: never reset the default quota timer Darrick J. Wong
2026-10-08 11:57 ` Christoph Hellwig
2026-10-08 5:56 ` [PATCH 06/12] xfs: fix correction of unwritten extents in quota file data fork Darrick J. Wong
2026-10-08 12:00 ` Christoph Hellwig
2026-10-08 15:59 ` Darrick J. Wong
2026-10-08 5:56 ` [PATCH 07/12] xfs: always report inode repair setup failures Darrick J. Wong
2026-10-08 12:00 ` Christoph Hellwig
2026-10-08 5:56 ` [PATCH 08/12] xfs: range-check bc_levels array access in scrub tracepoints Darrick J. Wong
2026-10-08 12:01 ` Christoph Hellwig
2026-10-08 5:57 ` [PATCH 09/12] xfs: reject absurdly large xattr value lengths in xchk_xattr_actor Darrick J. Wong
2026-10-08 12:01 ` Christoph Hellwig
2026-10-08 5:57 ` [PATCH 10/12] xfs: check for buffer overruns when examining local/remote xattr entries Darrick J. Wong
2026-10-08 12:03 ` Christoph Hellwig
2026-10-08 16:17 ` Darrick J. Wong [this message]
2026-10-08 5:57 ` [PATCH 11/12] xfs: clarify various parts of the bitmap API Darrick J. Wong
2026-10-08 12:04 ` Christoph Hellwig
2026-10-08 5:57 ` [PATCH 12/12] xfs: complain loudly when dirtree checker finds broken links Darrick J. Wong
2026-10-08 12:04 ` Christoph Hellwig
2026-10-08 17:36 ` Darrick J. Wong
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=20261008161746.GS2705364@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hch@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.