cpufreq: powernow-k8: avoid use after free issue in cpufreq_notify_transition()
PATCH 1/1 cpufreq: powernow-k8: avoid use after free issue in cpufreq_notify_transition()
From: chenqiwu <[email protected]>
There is a potential UAF issue in cpufreq_notify_transition() that the cpufreq of current cpu has been released before using it. So we should make a judgement and avoid it.
--- drivers/cpufreq/powernow-k8.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/cpufreq/powernow-k8.c +5 -0
@@ -913,6 +913,11 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, freqs.new =find_khz_freq_from_fid (fid); policy =cpufreq_cpu_get (smp_processor_id ()); +if (!policy) { +pr_debug ("cpu %d: CPUFreq policy not found\n" , +smp_processor_id ()); +return 1 ; + }cpufreq_cpu_put (policy);cpufreq_freq_transition_begin (policy, &freqs);
Signature · 1 line
1.9.1
Viresh Kumar
maintainerQuoted 16 lines · On 28-12-19, 10:57, [email protected] wrote:
From: chenqiwu <[email protected]>
There is a potential UAF issue in
cpufreq_notify_transition()that the cpufreq of current cpu has been released before using it. So we should make a judgement and avoid it.Signed-off-by chenqiwu <[email protected]>--- drivers/cpufreq/powernow-k8.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/cpufreq/powernow-k8.c +0
-0
drivers/cpufreq/powernow-k8.c static int transition_frequency_fidvid(struct powernow_k8_data *data, · line 920
Quoted 8 lines
drivers/cpufreq/powernow-k8.c +5
-0@@ -913,6 +913,11 @@ static int transition_frequency_fidvid(struct powernow_k8_data *data, freqs.new =find_khz_freq_from_fid (fid); policy =cpufreq_cpu_get (smp_processor_id ()); +if (!policy) { +pr_debug ("cpu %d: CPUFreq policy not found\n" , +smp_processor_id ()); +return 1 ; + }
You $subject and this change doesn't look related to me. The cpufreq policy shall never be NULL here as we are in the middle of changing frequency, initiated by cpufreq core itself.
Quoted 5 lines
drivers/cpufreq/powernow-k8.c +0
-0cpufreq_cpu_put (policy);cpufreq_freq_transition_begin (policy, &freqs);Signature · 1 line
1.9.1
Signature · 1 line
viresh