mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-14 14:34:28 +08:00
hwmon: (coretemp) Fix out-of-bounds memory access
Fix a bug that pdata->cpu_map[] is set before out-of-bounds check.
The problem might be triggered on systems with more than 128 cores per
package.
Fixes: 7108b80a54
("hwmon/coretemp: Handle large core ID value")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20240202092144.71180-2-rui.zhang@intel.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
1168491e7f
commit
4e440abc89
@ -509,18 +509,14 @@ static int create_core_data(struct platform_device *pdev, unsigned int cpu,
|
||||
if (pkg_flag) {
|
||||
attr_no = PKG_SYSFS_ATTR_NO;
|
||||
} else {
|
||||
index = ida_alloc(&pdata->ida, GFP_KERNEL);
|
||||
index = ida_alloc_max(&pdata->ida, NUM_REAL_CORES - 1, GFP_KERNEL);
|
||||
if (index < 0)
|
||||
return index;
|
||||
|
||||
pdata->cpu_map[index] = topology_core_id(cpu);
|
||||
attr_no = index + BASE_SYSFS_ATTR_NO;
|
||||
}
|
||||
|
||||
if (attr_no > MAX_CORE_DATA - 1) {
|
||||
err = -ERANGE;
|
||||
goto ida_free;
|
||||
}
|
||||
|
||||
tdata = init_temp_data(cpu, pkg_flag);
|
||||
if (!tdata) {
|
||||
err = -ENOMEM;
|
||||
|
Loading…
Reference in New Issue
Block a user