From: kernel test robot <yi1.lai@intel.com>
To: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: "Paul E . McKenney" <paulmck@kernel.org>,
linux-kernel@vger.kernel.org,
Bradley Morgan <brads@mainlining.org>,
Boqun Feng <boqun@kernel.org>,
rcu@vger.kernel.org, lkmm@lists.linux.dev, yi1.lai@intel.com
Subject: Re: [PATCH] hazptr: handle NULL address in hazptr_detach
Date: Thu, 10 Sep 2026 10:16:39 +0800 [thread overview]
Message-ID: <aqITB4oCfaR7vD+G@ly-workstation> (raw)
In-Reply-To: <20260908152228.4154-1-mathieu.desnoyers@efficios.com>
On Tue, Sep 08, 2026 at 11:22:14AM -0400, Mathieu Desnoyers wrote:
> When hazptr_acquire loads a NULL pointer, it sets:
>
> - slot_item->slot.addr = NULL,
> - slot_item->ctx.ctx = ctx
> - ctx->slot = slot
>
> And it returns NULL.
>
> Then hazptr_detach is called on this ctx, it will act on the ctx as if
> needed to be promoted to backup slot, even though it has a NULL addr.
>
> Looking at what hazptr_note_context_switch() does before promoting
> to backup slot, it checks for a NULL slot->addr, which is exactly
> what is missing from hazptr_detach.
>
> With this in place there would be no need to explicitly check the
> hazptr_acquire() return value before calling hazptr_detach().
>
> hazptr_release() has a early return check for NULL addr as well, so it
> makes sense that detach does an early return (no-op) similarly.
>
> Fixes: 6357ec235c59 ("hazptrtorture: Fix hazptr ownership issue")
> Reported-by: kernel test robot <yi1.lai@intel.com>
> Closes: https://lore.kernel.org/oe-lkp/202608130915.62b53936-lkp@intel.com
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
> Reviewed-by: Bradley Morgan <brads@mainlining.org>
> Cc: Paul E. McKenney <paulmck@kernel.org>
> Cc: Boqun Feng <boqun@kernel.org>
> Cc: Bradley Morgan <brads@mainlining.org>
> Cc: <rcu@vger.kernel.org>
> Cc: <lkmm@lists.linux.dev>
> ---
> include/linux/hazptr.h | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/hazptr.h b/include/linux/hazptr.h
> index 43122c5673bd..d1670121947a 100644
> --- a/include/linux/hazptr.h
> +++ b/include/linux/hazptr.h
> @@ -160,10 +160,12 @@ void hazptr_detach(struct hazptr_ctx *ctx)
> struct hazptr_slot *slot;
>
> guard(preempt)();
> + slot = ctx->slot;
> + if (!slot->addr)
> + return;
> #ifdef CONFIG_HAZPTR_DEBUG
> ctx->detach_task = ctx->detach_cpu = true;
> #endif
> - slot = ctx->slot;
> if (unlikely(hazptr_slot_is_backup(ctx, slot)))
> return;
> hazptr_promote_to_backup_slot(ctx, slot);
> --
> 2.43.0
>
Applied this fix patch on top of Pual's v2 RFC patch series. The issue
cannot be reproduce.
Tested-by: kernel test robot <yi1.lai@intel.com>
next prev parent reply other threads:[~2026-09-10 2:16 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 15:22 Mathieu Desnoyers
2026-09-08 15:24 ` Bradley Morgan
2026-09-08 15:29 ` Mathieu Desnoyers
2026-09-08 15:52 ` Bradley Morgan
2026-09-08 16:22 ` Paul E. McKenney
2026-09-08 16:31 ` Bradley Morgan
2026-09-08 16:53 ` Mathieu Desnoyers
2026-09-10 3:14 ` Paul E. McKenney
2026-09-10 2:16 ` kernel test robot [this message]
2026-09-10 3:11 ` Paul E. McKenney
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=aqITB4oCfaR7vD+G@ly-workstation \
--to=yi1.lai@intel.com \
--cc=boqun@kernel.org \
--cc=brads@mainlining.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkmm@lists.linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=paulmck@kernel.org \
--cc=rcu@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
all inboxes | Powered by JetHome®