Linux Perf Users
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jayapal Ashwin Nair" <jayapalashwin.nair@amd.com>,
	linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf/x86/rapl: Fix use-after-free on rapl_pmus_core on AMD/Hygon
Date: Tue, 13 Oct 2026 09:59:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-169411@kernel.org> (raw)
In-Reply-To: <20261013095051.24777-1-jayapalashwin.nair@amd.com>

> The global rapl_pmus_core pointer can be used after it has been freed in
> two ways:
> 
> 1) init_rapl_pmus() stores the newly allocated rapl_pmus in
>    *rapl_pmus_ptr before calling init_rapl_pmu(). If init_rapl_pmu()
>    fails, rapl_pmus is freed but *rapl_pmus_ptr is not cleared, leaving
>    rapl_pmus_core pointing to freed memory. rapl_pmu_init() then jumps
>    to core_init_failed, where rapl_advertise() dereferences it.
> 
> 2) If perf_pmu_register() fails for the power_core PMU,
>    cleanup_rapl_pmus() frees rapl_pmus_core, but the pointer is not
>    cleared. rapl_advertise() then dereferences the stale pointer in the
>    same way as in 1).
> 
> In both cases, rmmod can result in use-after-free and a double free.
> 
> Fix this by setting rapl_pmus_core to NULL on both failure paths.
> 
> Fixes: b4943b8bfc41 ("perf/x86/rapl: Add core energy counter support for AMD CPUs")
> Signed-off-by: Jayapal Ashwin Nair <jayapalashwin.nair@amd.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013095051.24777-1-jayapalashwin.nair@amd.com?part=1


      reply	other threads:[~2026-10-13  9:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  9:50 [PATCH] perf/x86/rapl: Fix use-after-free on rapl_pmus_core on AMD/Hygon Jayapal Ashwin Nair
2026-10-13  9:59 ` 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-169411@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jayapalashwin.nair@amd.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