[CPUFREQ] Fix use after free on governor restore
authorDmitry Monakhov <dmonakhov@openvz.org>
Sun, 4 Oct 2009 20:38:55 +0000 (00:38 +0400)
committerDave Jones <davej@redhat.com>
Wed, 18 Nov 2009 04:15:04 +0000 (23:15 -0500)
commite77b89f13a0d48aea70b69976e854f2a2444a519
treed78288fc4386e1613713fff8c13d28f7ec480d32
parent293afe44d75abce4252db76cbb303a7de4297ce1
[CPUFREQ] Fix use after free on governor restore

Currently on governer backup/restore path we storing governor's pointer.
This is wrong because one may unload governor's module after cpu goes
offline. As result use-after-free will take place on restored cpu.
It is not easy to exploit this bug, but still we have to close this
issue ASAP. Issue was introduced by following commit
084f34939424161669467c19280dbcf637730314

##TESTCASE##
#!/bin/sh -x
modprobe acpi_cpufreq
# Any non default governor, in may case it is "ondemand"
modprobe cpufreq_ondemand
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
rmmod acpi_cpufreq
rmmod cpufreq_ondemand
modprobe acpi_cpufreq  # << use-after-free here.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Dave Jones <davej@redhat.com>
drivers/cpufreq/cpufreq.c