Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hang Zhengyang" <hang.zhengyang1010@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf/core: Check for a NULL cpc before cancelling its hrtimer
Date: Thu, 03 Dec 2026 07:43:45 +0000	[thread overview]
Message-ID: <sashiko-outbox-247316@kernel.org> (raw)
In-Reply-To: <20261203073728.2470032-1-hang.zhengyang1010@gmail.com>

> perf_pmu_register() allocates the per-CPU contexts one CPU at a time.
> When one of these allocations fails, it returns -ENOMEM and
> perf_pmu_free() runs with NULL entries for the CPUs that are not
> allocated yet. The loop in perf_pmu_free() skips those entries, but
> commit 35fbc5a85891 ("perf/core: Cancel hrtimer on
> perf_pmu_unregister()") put the hrtimer_cancel() before the NULL check.
> Such a failure then oopses instead of returning -ENOMEM:
> 
>   KASAN: null-ptr-deref in range [0x0000000000000108-0x000000000000010f]
>   RIP: 0010:hrtimer_active+0xc1/0x350
>   Call Trace:
>    hrtimer_cancel+0x15/0x40
>    perf_pmu_free+0x1cd/0x320
>    perf_pmu_register+0x4e1/0xb40
> 
> The allocations are small GFP_KERNEL ones, so this needs fault injection
> or a registering task that the OOM killer has picked. Found with failslab
> fault injection on the allocations in perf_pmu_register().
> 
> Cancel the hrtimer after the NULL check.
> 
> Fixes: 35fbc5a85891 ("perf/core: Cancel hrtimer on perf_pmu_unregister()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Hang Zhengyang <hang.zhengyang1010@gmail.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203073728.2470032-1-hang.zhengyang1010@gmail.com?part=1

      reply	other threads:[~2026-12-03  7:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  7:37 [PATCH] perf/core: Check for a NULL cpc before cancelling its hrtimer Hang Zhengyang
2026-12-03  7:43 ` 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-247316@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=hang.zhengyang1010@gmail.com \
    --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