Skip to content

Commit

Permalink
cpufreq: powernv: Fix use-after-free
Browse files Browse the repository at this point in the history
commit d0a72ef upstream.

The cpufreq driver has a use-after-free that we can hit if:

a) There's an OCC message pending when the notifier is registered, and
b) The cpufreq driver fails to register with the core.

When a) occurs the notifier schedules a workqueue item to handle the
message. The backing work_struct is located on chips[].throttle and
when b) happens we clean up by freeing the array. Once we get to
the (now free) queued item and the kernel crashes.

Fixes: c5e29ea ("cpufreq: powernv: Fix bugs in powernv_cpufreq_{init/exit}")
Cc: [email protected] # v4.6+
Signed-off-by: Oliver O'Halloran <[email protected]>
Reviewed-by: Gautham R. Shenoy <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
oohal authored and gregkh committed Apr 17, 2020
1 parent 2a87b49 commit 35e68ae
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/cpufreq/powernv-cpufreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,12 @@ static int init_chip_info(void)

static inline void clean_chip_info(void)
{
int i;

/* flush any pending work items */
if (chips)
for (i = 0; i < nr_chips; i++)
cancel_work_sync(&chips[i].throttle);
kfree(chips);
}

Expand Down

0 comments on commit 35e68ae

Please sign in to comment.