Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Carlos Maiolino <cem@kernel.org>
Cc: samsun1006219@gmail.com, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 6/6] xfs: don't report half-built inodes to fserror
Date: Tue, 24 Feb 2026 11:40:39 -0800	[thread overview]
Message-ID: <20260224194039.GA13843@frogsfrogsfrogs> (raw)
In-Reply-To: <aZ2NU4-LCIGOgjI9@nidhogg.toxiclabs.cc>

On Tue, Feb 24, 2026 at 12:39:08PM +0100, Carlos Maiolino wrote:
> On Thu, Feb 19, 2026 at 02:02:23PM -0800, Darrick J. Wong wrote:
> > On Thu, Feb 19, 2026 at 02:21:36PM +0100, Carlos Maiolino wrote:
> > > On Wed, Feb 18, 2026 at 10:02:17PM -0800, Darrick J. Wong wrote:
> > > > From: Darrick J. Wong <djwong@kernel.org>
> > > > 
> > > > Sam Sun apparently found a syzbot way to fuzz a filesystem such that
> > > > xfs_iget_cache_miss would free the inode before the fserror code could
> > > > catch up.  Frustratingly he doesn't use the syzbot dashboard so there's
> > > > no C reproducer and not even a full error report, so I'm guessing that:
> > > > 
> > > > Inodes that are being constructed or torn down inside XFS are not
> > > > visible to the VFS.  They should never be reported to fserror.
> > > > Also, any inode that has been freshly allocated in _cache_miss should be
> > > > marked INEW immediately because, well, it's an incompletely constructed
> > > > inode that isn't yet visible to the VFS.
> > > > 
> > > > Reported-by: Sam Sun <samsun1006219@gmail.com>
> > > > Fixes: 5eb4cb18e445d0 ("xfs: convey metadata health events to the health monitor")
> > > > Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> > > 
> > > The change looks ok to me. Would be nice though if we can be sure this
> > > fix the reporter's issue. Any idea if the reporter could reproduce it?
> > 
> > It sounds like syzbot found a reproducer for the reporter, but they will
> > not integrate with Google's syzbot dashboard or stand up their own
> > instance so I can't download it on my own; and they only posted a very
> > large strace so someone would have to turn that into a C program.
> > 
> > This is rude behavior, and egregiously so when the reporter **has an
> > automated fuzzer** that spat out a C program somewhere, but they won't
> > share.
> 
> Agreed.
> 
> > 
> > > Otherwise pointing this as a fix to a problem we can't be sure has
> > > actually been fixed, sounds misleading at best.
> > 
> > I don't know what to do unless the reporter builds a patched kernel and
> > tests it for us.
> 
> Chances are.... we never hear anything else again, but hopefully I'm
> wrong :)
> 
> My suggestion would be to leave the Fixes tag off, to avoid stable
> backports that "might not really fix" the problem, but this is a
> suggestion only, I'm ok to have it anyway.

I didn't cc stable, so this isn't going to get autobackported.  TBH, if
someone /does/ decide to backport all this manually, we ought to leave
them some breadcrumbs of what else needs to be pulled in.

FWIW the patch actually /does/ fix a real problem -- we shouldn't be
exposing XFS_INEW inodes to the VFS, but we do want the failure to be
recorded (with inumber) by the health monitoring system so that
xfs_healer can actually try to repair the inode, so we have to keep the
xfs_inode_mark_sick call in the iget miss code.

I don't know if that's the root cause of the problem that syzbot
reported, but I guess we'll never know.

--D

> > > For the fix itself though:
> > > 
> > > Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> > 
> > Thanks for reviewing.
> > 
> > --D
> > 
> > > 
> > > > ---
> > > >  fs/xfs/xfs_health.c |    8 ++++++--
> > > >  fs/xfs/xfs_icache.c |    9 ++++++++-
> > > >  2 files changed, 14 insertions(+), 3 deletions(-)
> > > > 
> > > > 
> > > > diff --git a/fs/xfs/xfs_health.c b/fs/xfs/xfs_health.c
> > > > index 6475159eb9302c..239b843e83d42a 100644
> > > > --- a/fs/xfs/xfs_health.c
> > > > +++ b/fs/xfs/xfs_health.c
> > > > @@ -316,8 +316,12 @@ xfs_rgno_mark_sick(
> > > >  
> > > >  static inline void xfs_inode_report_fserror(struct xfs_inode *ip)
> > > >  {
> > > > -	/* Report metadata inodes as general filesystem corruption */
> > > > -	if (xfs_is_internal_inode(ip)) {
> > > > +	/*
> > > > +	 * Do not report inodes being constructed or freed, or metadata inodes,
> > > > +	 * to fsnotify.
> > > > +	 */
> > > > +	if (xfs_iflags_test(ip, XFS_INEW | XFS_IRECLAIM) ||
> > > > +	    xfs_is_internal_inode(ip)) {
> > > >  		fserror_report_metadata(ip->i_mount->m_super, -EFSCORRUPTED,
> > > >  				GFP_NOFS);
> > > >  		return;
> > > > diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> > > > index dbaab4ae709f9c..f13e55b75d66c4 100644
> > > > --- a/fs/xfs/xfs_icache.c
> > > > +++ b/fs/xfs/xfs_icache.c
> > > > @@ -636,6 +636,14 @@ xfs_iget_cache_miss(
> > > >  	if (!ip)
> > > >  		return -ENOMEM;
> > > >  
> > > > +	/*
> > > > +	 * Set XFS_INEW as early as possible so that the health code won't pass
> > > > +	 * the inode to the fserror code if the ondisk inode cannot be loaded.
> > > > +	 * We're going to free the xfs_inode immediately if that happens, which
> > > > +	 * would lead to UAF problems.
> > > > +	 */
> > > > +	xfs_iflags_set(ip, XFS_INEW);
> > > > +
> > > >  	error = xfs_imap(pag, tp, ip->i_ino, &ip->i_imap, flags);
> > > >  	if (error)
> > > >  		goto out_destroy;
> > > > @@ -713,7 +721,6 @@ xfs_iget_cache_miss(
> > > >  	ip->i_udquot = NULL;
> > > >  	ip->i_gdquot = NULL;
> > > >  	ip->i_pdquot = NULL;
> > > > -	xfs_iflags_set(ip, XFS_INEW);
> > > >  
> > > >  	/* insert the new inode */
> > > >  	spin_lock(&pag->pag_ici_lock);
> > > > 
> > > > 
> > > 
> > 
> 

  reply	other threads:[~2026-02-24 19:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-19  6:00 [PATCHSET 1/2] xfs: bug fixes for 7.0 Darrick J. Wong
2026-02-19  6:00 ` [PATCH 1/6] xfs: fix copy-paste error in previous fix Darrick J. Wong
2026-02-19  6:41   ` Christoph Hellwig
2026-02-19 12:56   ` Carlos Maiolino
2026-02-19  6:01 ` [PATCH 2/6] xfs: fix xfs_group release bug in xfs_verify_report_losses Darrick J. Wong
2026-02-19  6:41   ` Christoph Hellwig
2026-02-19 12:57   ` Carlos Maiolino
2026-02-19  6:01 ` [PATCH 3/6] " Darrick J. Wong
2026-02-19  6:42   ` Christoph Hellwig
2026-02-19 13:02   ` Carlos Maiolino
2026-02-19 21:48     ` Darrick J. Wong
2026-02-19  6:01 ` [PATCH 4/6] xfs: fix potential pointer access race in xfs_healthmon_get Darrick J. Wong
2026-02-19  6:43   ` Christoph Hellwig
2026-02-19 13:09     ` Carlos Maiolino
2026-02-19 21:52     ` Darrick J. Wong
2026-02-19 13:15   ` Pankaj Raghav
2026-02-19  6:02 ` [PATCH 5/6] xfs: don't report metadata inodes to fserror Darrick J. Wong
2026-02-19  6:44   ` Christoph Hellwig
2026-02-19 13:11   ` Carlos Maiolino
2026-02-19  6:02 ` [PATCH 6/6] xfs: don't report half-built " Darrick J. Wong
2026-02-19  6:44   ` Christoph Hellwig
2026-02-19 13:21   ` Carlos Maiolino
2026-02-19 22:02     ` Darrick J. Wong
2026-02-24 11:39       ` Carlos Maiolino
2026-02-24 19:40         ` Darrick J. Wong [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-02-20  1:00 [PATCHSET v2 1/2] xfs: bug fixes for 7.0 Darrick J. Wong
2026-02-20  1:01 ` [PATCH 6/6] xfs: don't report half-built inodes to fserror 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=20260224194039.GA13843@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=samsun1006219@gmail.com \
    /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