[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFcvxdMozCv1mJFKemQKhOnZPLpfkWs3d97bHUijRdw7MdFO1w@mail.gmail.com>
Date: Sun, 29 Jun 2025 01:12:51 +0300
From: Elazar Leibovich <elazarl@...ro.ai>
To: "Rafael J. Wysocki" <rafael@...nel.org>
Cc: Sivan Zohar-Kotzer <sivany32@...il.com>, Daniel Lezcano <daniel.lezcano@...nel.org>, elazarl@...il.com,
linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] powercap: dtpm_cpu: Fix NULL pointer dereference race
during CPU offlining
On Fri, Jun 27, 2025 at 11:07 PM Rafael J. Wysocki <rafael@...nel.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.
Powered by blists - more mailing lists