Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Haoli Zhang" <26031212468@stu.xidian.edu.cn>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf/core: Protect ctx after dropping its reference
Date: Mon, 16 Nov 2026 12:11:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-216989@kernel.org> (raw)
In-Reply-To: <20261116120452.22269-1-26031212468@stu.xidian.edu.cn>

> Take an RCU read lock before decrementing the reference and retain it
> through the non-final branch's tombstone check and wakeup. This keeps ctx
> alive until that branch has finished. When the decrement is final,
> release the read lock immediately; that caller continues the final
> cleanup and queues the RCU callback.
> 
> Read ctx->task with READ_ONCE(), matching the WRITE_ONCE() used when the
> task context is marked as a tombstone. Keep smp_mb__after_atomic(): it
> preserves the existing wait_var_event() ordering, while RCU protects the
> context's lifetime.
> 
> A similar fix was posted by Weiming Shi in October:
> https://lkml.iu.edu/2610.0/09721.html. This version releases the RCU
> read lock immediately on the final-put path and uses READ_ONCE() for the
> lockless ctx->task check.
> 
> The report shows the access in put_ctx() reached through event release,
> and the free callback was queued from task-exit context cleanup. These
> stacks are consistent with the post-decrement lifetime race described
> above.
> 
> Fixes: 59f3aa4a3ee2 ("perf: Simplify perf_event_free_task() wait")
> Reported-by: syzbot+56ad4cdaff8716472033@syzkaller.appspotmail.com
> Closes: https://syzbot.org/bug?extid=56ad4cdaff8716472033
> Link: https://lkml.iu.edu/2610.0/09721.html
> Co-developed-by: Jinning Zhang <25031212117@stu.xidian.edu.cn>
> Signed-off-by: Jinning Zhang <25031212117@stu.xidian.edu.cn>
> Co-developed-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Bin Yu <byu@xidian.edu.cn>
> Signed-off-by: Haoli Zhang <26031212468@stu.xidian.edu.cn>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116120452.22269-1-26031212468@stu.xidian.edu.cn?part=1


      reply	other threads:[~2026-11-16 12:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 12:04 [PATCH] perf/core: Protect ctx after dropping its reference Haoli Zhang
2026-11-16 12:11 ` sashiko-bot [this message]

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=sashiko-outbox-216989@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=26031212468@stu.xidian.edu.cn \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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