From: Elazar Leibovich <elazarl@atero.ai>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Sivan Zohar-Kotzer <sivany32@gmail.com>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
elazarl@gmail.com, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] powercap: dtpm_cpu: Fix NULL pointer dereference race during CPU offlining
Date: Sun, 29 Jun 2025 01:12:51 +0300 [thread overview]
Message-ID: <CAFcvxdMozCv1mJFKemQKhOnZPLpfkWs3d97bHUijRdw7MdFO1w@mail.gmail.com> (raw)
In-Reply-To: <CAJZ5v0jXPten8QwruK_Dqzvc0izLCfecMPBWMMoP8cnG4mDY0Q@mail.gmail.com>
On Fri, Jun 27, 2025 at 11:07 PM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > * DTPM power calculations are triggered (e.g., via sysfs reads) while CPU is online
> > * The CPU goes offline during the calculation, before em_cpu_get() is called
> > * em_cpu_get() now returns NULL since the energy model was unregistered
>
> But energy models for CPUs are never unregistered.
>
Can't the following happen (extremely rare, but still):
CPU gets set to impossible during shutdown sequence, e.g.
// arch/alpha/kernel/process.c
common_shutdown_1(void *generic_ptr)
...
set_cpu_possible(boot_cpuid, false);
Just before `get_cpu_device` is called by `em_cpu_get`.
Then `get_cpu_device` returns NULL for impossible CPU, causing
`em_cpu_get` to return NULL.
It's not a common scenario, but it seems NULL checking doesn't cost much,
and can assure us no rare case is crashing the system.
next prev parent reply other threads:[~2025-06-28 22:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-18 23:16 [PATCH] powercap: dtpm_cpu: Fix NULL pointer dereference race during CPU offlining Sivan Zohar-Kotzer
2025-06-27 20:06 ` Rafael J. Wysocki
2025-06-28 22:12 ` Elazar Leibovich [this message]
2025-06-30 20:16 ` Rafael J. Wysocki
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=CAFcvxdMozCv1mJFKemQKhOnZPLpfkWs3d97bHUijRdw7MdFO1w@mail.gmail.com \
--to=elazarl@atero.ai \
--cc=daniel.lezcano@kernel.org \
--cc=elazarl@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=sivany32@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).