All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuto Ohnuki <ytohnuki@amazon.com>
To: <djwong@kernel.org>
Cc: <bfoster@redhat.com>, <cem@kernel.org>, <darrick.wong@oracle.com>,
	<dchinner@redhat.com>, <linux-kernel@vger.kernel.org>,
	<linux-xfs@vger.kernel.org>,
	<syzbot+652af2b3c5569c4ab63c@syzkaller.appspotmail.com>,
	<ytohnuki@amazon.com>
Subject: Re: [PATCH] xfs: fix use-after-free in xfs_inode_item_push()
Date: Wed, 4 Mar 2026 17:41:18 +0000	[thread overview]
Message-ID: <20260304174117.88648-2-ytohnuki@amazon.com> (raw)
In-Reply-To: <20260304164451.GW57948@frogsfrogsfrogs>

> > ---
> >  fs/xfs/xfs_inode_item.c | 5 +++--
> >  fs/xfs/xfs_trans_ail.c  | 8 +++++++-
> >  2 files changed, 10 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
> > index 8913036b8024..0a8957f9c72f 100644
> > --- a/fs/xfs/xfs_inode_item.c
> > +++ b/fs/xfs/xfs_inode_item.c
> > @@ -746,6 +746,7 @@ xfs_inode_item_push(
> >     struct xfs_inode_log_item *iip = INODE_ITEM(lip);
> >     struct xfs_inode        *ip = iip->ili_inode;
> >     struct xfs_buf          *bp = lip->li_buf;
> > +   struct xfs_ail          *ailp = lip->li_ailp;
> >     uint                    rval = XFS_ITEM_SUCCESS;
> >     int                     error;
> >  
> > @@ -771,7 +772,7 @@ xfs_inode_item_push(
> >     if (!xfs_buf_trylock(bp))
> >             return XFS_ITEM_LOCKED;
> >  
> > -   spin_unlock(&lip->li_ailp->ail_lock);
> > +   spin_unlock(&ailp->ail_lock);
> >  
> >     /*
> >      * We need to hold a reference for flushing the cluster buffer as it may
> > @@ -795,7 +796,7 @@ xfs_inode_item_push(
> >             rval = XFS_ITEM_LOCKED;
> >     }
> >  
> > -   spin_lock(&lip->li_ailp->ail_lock);
> > +   spin_lock(&ailp->ail_lock);
> 
> Hmm, so the @lip UAF is here, where we try to re-acquire the AIL lock?

Yes. The syzbot report shows a Read of size 8 at offset 48 (li_ailp)
when spin_lock() dereferences the freed log item to get the
AIL pointer.

> >     return rval;
> >  }
> >  
> > diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c
> > index 923729af4206..e34d8a7e341d 100644
> > --- a/fs/xfs/xfs_trans_ail.c
> > +++ b/fs/xfs/xfs_trans_ail.c
> > @@ -510,6 +510,13 @@ xfsaild_push(
> >             if (test_bit(XFS_LI_FLUSHING, &lip->li_flags))
> >                     goto next_item;
> >  
> > +           /*
> > +            * The log item may be freed after the push if the AIL lock is
> > +            * temporarily dropped and the RCU grace period expires,
> > +            * so trace it before pushing.
> > +            */
> > +           trace_xfs_ail_push(lip);
> > +
> >             /*
> >              * Note that iop_push may unlock and reacquire the AIL lock.  We
> >              * rely on the AIL cursor implementation to be able to deal with
> > @@ -519,7 +526,6 @@ xfsaild_push(
> >             switch (lock_result) {
> >             case XFS_ITEM_SUCCESS:
> >                     XFS_STATS_INC(mp, xs_push_ail_success);
> > -                   trace_xfs_ail_push(lip);
> 
> Do the tracepoints in the other legs of the switch statement have a
> similar UAF problem because they dereference @lip?
> 
> --D

Thank you very much for pointing out the other switch statement.

XFS_ITEM_PINNED is always returned before the AIL lock
is dropped, so trace_xfs_ail_pinned() is safe.

However, looking into it further, XFS_ITEM_FLUSHING and 
XFS_ITEM_LOCKED can also be returned via the rval path after the AIL 
lock is dropped and reacquired. So trace_xfs_ail_flushing() and
trace_xfs_ail_locked() could also hit a UAF in those cases.

I'll send a v2 that addresses those as well.



Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg, R.C.S. Luxembourg B186284

Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlington Road, Dublin 4, Ireland, branch registration number 908705




  reply	other threads:[~2026-03-04 17:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-04 16:24 [PATCH] xfs: fix use-after-free in xfs_inode_item_push() Yuto Ohnuki
2026-03-04 16:44 ` Darrick J. Wong
2026-03-04 17:41   ` Yuto Ohnuki [this message]
2026-03-04 23:06 ` Dave Chinner
2026-03-05 18:28   ` Yuto Ohnuki

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=20260304174117.88648-2-ytohnuki@amazon.com \
    --to=ytohnuki@amazon.com \
    --cc=bfoster@redhat.com \
    --cc=cem@kernel.org \
    --cc=darrick.wong@oracle.com \
    --cc=dchinner@redhat.com \
    --cc=djwong@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=syzbot+652af2b3c5569c4ab63c@syzkaller.appspotmail.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 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.