提交 2561c45b 编写于 作者: D Dmitry Osipenko 提交者: Greg Kroah-Hartman

thermal: core: Fix use-after-free in thermal_cooling_device_destroy_sysfs

commit 3c587768271e9c20276522025729e4ebca51583b upstream.

This patch fixes use-after-free that was detected by KASAN. The bug is
triggered on a CPUFreq driver module unload by freeing 'cdev' on device
unregister and then using the freed structure during of the cdev's sysfs
data destruction. The solution is to unregister the sysfs at first, then
destroy sysfs data and finally release the cooling device.

Cc: <stable@vger.kernel.org> # v4.17+
Fixes: 8ea22951 ("thermal: Add cooling device's statistics in sysfs")
Signed-off-by: NDmitry Osipenko <digetx@gmail.com>
Acked-by: NViresh Kumar <viresh.kumar@linaro.org>
Acked-by: NEduardo Valentin <edubezval@gmail.com>
Signed-off-by: NZhang Rui <rui.zhang@intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 e2496105
...@@ -1102,8 +1102,9 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev) ...@@ -1102,8 +1102,9 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
ida_simple_remove(&thermal_cdev_ida, cdev->id); ida_simple_remove(&thermal_cdev_ida, cdev->id);
device_unregister(&cdev->device); device_del(&cdev->device);
thermal_cooling_device_destroy_sysfs(cdev); thermal_cooling_device_destroy_sysfs(cdev);
put_device(&cdev->device);
} }
EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister); EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册