From: "Darrick J. Wong" <djwong@kernel.org>
To: NeilBrown <neil@brown.name>
Cc: Ethan Tidmore <ethantidmore06@gmail.com>,
Carlos Maiolino <cem@kernel.org>,
Christian Brauner <brauner@kernel.org>,
linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] xfs: Fix error pointer dereference
Date: Wed, 18 Feb 2026 16:31:54 -0800 [thread overview]
Message-ID: <20260219003154.GB6490@frogsfrogsfrogs> (raw)
In-Reply-To: <177146073877.8396.8928465677585359848@noble.neil.brown.name>
On Thu, Feb 19, 2026 at 11:25:38AM +1100, NeilBrown wrote:
> On Thu, 19 Feb 2026, Darrick J. Wong wrote:
> > On Wed, Feb 18, 2026 at 01:51:15PM -0600, Ethan Tidmore wrote:
> > > The function try_lookup_noperm() can return an error pointer and is not
> > > checked for one. Add checks for error pointer.
> > >
> > > Detected by Smatch:
> > > fs/xfs/scrub/orphanage.c:449 xrep_adoption_check_dcache() error:
> > > 'd_child' dereferencing possible ERR_PTR()
> > >
> > > fs/xfs/scrub/orphanage.c:485 xrep_adoption_zap_dcache() error:
> > > 'd_child' dereferencing possible ERR_PTR()
> > >
> > > Fixes: 06c567403ae5a ("Use try_lookup_noperm() instead of d_hash_and_lookup() outside of VFS")
> >
> > Cc: <stable@vger.kernel.org> # v6.16
>
> I don't think this is justified. In this use case try_lookup_noperm()
> will never actually return an error.
Sure, but a future update to try_lookup_noperm that *does* introduce the
possibility of an ERR_PTR return could get backported to 6.18, at which
point this code is now broken. I think I'd rather just clean all this
up all at once.
> >
> > > Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
> > > ---
> > > fs/xfs/scrub/orphanage.c | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/fs/xfs/scrub/orphanage.c b/fs/xfs/scrub/orphanage.c
> > > index 52a108f6d5f4..cdb0f486f50c 100644
> > > --- a/fs/xfs/scrub/orphanage.c
> > > +++ b/fs/xfs/scrub/orphanage.c
> > > @@ -442,7 +442,7 @@ xrep_adoption_check_dcache(
> > > return 0;
> > >
> > > d_child = try_lookup_noperm(&qname, d_orphanage);
> >
> > "Look up a dentry by name in the dcache, returning NULL if it does not
> > currently exist."
> >
> > Could you please fix the documentation since try_lookup_noperm can
> > return ERR_PTR values?
>
> Fair - I'll include a patch with my next batch.
>
> >
> > > - if (d_child) {
> > > + if (!IS_ERR_OR_NULL(d_child)) {
> >
> > If d_child is an ERR_PTR, shouldn't we extract that error value and
> > return it instead of zero?
>
> This is a purely cosmetic question as no error is actually returned in
> practice. So whatever you feel most comfortable with is best.
If we're going to check for an ERR_PTR value (even if one cannot
currently be returned) then we should pass it upwards. We might as well
get rid of all the lurking broken logic all at once.
--D
> NeilBrown
>
>
> >
> > --D
> >
> > > trace_xrep_adoption_check_child(sc->mp, d_child);
> > >
> > > if (d_is_positive(d_child)) {
> > > @@ -479,7 +479,7 @@ xrep_adoption_zap_dcache(
> > > return;
> > >
> > > d_child = try_lookup_noperm(&qname, d_orphanage);
> > > - while (d_child != NULL) {
> > > + while (!IS_ERR_OR_NULL(d_child)) {
> > > trace_xrep_adoption_invalidate_child(sc->mp, d_child);
> > >
> > > ASSERT(d_is_negative(d_child));
> > > --
> > > 2.53.0
> > >
> > >
> >
>
>
next prev parent reply other threads:[~2026-02-19 0:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 19:51 Ethan Tidmore
2026-02-18 23:49 ` Darrick J. Wong
2026-02-19 0:25 ` NeilBrown
2026-02-19 0:31 ` Darrick J. Wong [this message]
2026-02-19 0:21 ` NeilBrown
2026-02-19 11:26 ` Nirjhar Roy (IBM)
2026-02-19 16:46 ` Ethan Tidmore
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=20260219003154.GB6490@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=ethantidmore06@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=neil@brown.name \
/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
all inboxes | Powered by JetHome®