From: Zhang Rui <rui.zhang@intel.com>
To: linux@roeck-us.net, jdelvare@suse.com
Cc: fenghua.yu@intel.com, linux-hwmon@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH V2 01/11] hwmon: (coretemp) Fix out-of-bounds memory access
Date: Fri, 2 Feb 2024 17:21:34 +0800 [thread overview]
Message-ID: <20240202092144.71180-2-rui.zhang@intel.com> (raw)
In-Reply-To: <20240202092144.71180-1-rui.zhang@intel.com>
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: 7108b80a542b ("hwmon/coretemp: Handle large core ID value")
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Cc: <stable@vger.kernel.org>
---
drivers/hwmon/coretemp.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
index ba82d1e79c13..e78c76919111 100644
--- a/drivers/hwmon/coretemp.c
+++ b/drivers/hwmon/coretemp.c
@@ -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;
--
2.34.1
next prev parent reply other threads:[~2024-02-02 9:21 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-02 9:21 [PATCH V2 00/11] hwmon: (coretemp) Fixes, improvements and support for large core count Zhang Rui
2024-02-02 9:21 ` Zhang Rui [this message]
2024-02-03 15:16 ` [PATCH V2 01/11] hwmon: (coretemp) Fix out-of-bounds memory access Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 02/11] hwmon: (coretemp) Fix bogus core_id to attr name mapping Zhang Rui
2024-02-03 15:16 ` Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 03/11] hwmon: (coretemp) Enlarge per package core count limit Zhang Rui
2024-02-03 15:17 ` Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 04/11] hwmon: (coretemp) Introduce enum for attr index Zhang Rui
2024-02-04 14:45 ` Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 05/11] hwmon: (coretemp) Remove unnecessary dependency of array index Zhang Rui
2024-02-04 14:46 ` Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 06/11] hwmon: (coretemp) Replace sensor_device_attribute with device_attribute Zhang Rui
2024-02-04 14:46 ` Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 07/11] hwmon: (coretemp) Remove redundant pdata->cpu_map[] Zhang Rui
2024-02-04 14:47 ` Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 08/11] hwmon: (coretemp) Abstract core_temp helpers Zhang Rui
2024-02-04 14:47 ` Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 09/11] hwmon: (coretemp) Split package temp_data and core temp_data Zhang Rui
2024-02-04 14:48 ` Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 10/11] hwmon: (coretemp) Remove redundant temp_data->is_pkg_data Zhang Rui
2024-02-04 14:49 ` Guenter Roeck
2024-02-02 9:21 ` [PATCH V2 11/11] hwmon: (coretemp) Use dynamic allocated memory for core temp_data Zhang Rui
2024-02-04 14:50 ` Guenter Roeck
2024-02-02 18:15 ` [PATCH V2 00/11] hwmon: (coretemp) Fixes, improvements and support for large core count Guenter Roeck
2024-02-03 5:40 ` Zhang, Rui
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240202092144.71180-2-rui.zhang@intel.com \
--to=rui.zhang@intel.com \
--cc=fenghua.yu@intel.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox