FAILED: patch "[PATCH] hwmon: (coretemp) Fix out-of-bounds memory access" failed to apply to 6.7-stable tree
[email protected]
maintainerThe patch below does not apply to the 6.7-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.7.y
git checkout FETCH_HEAD
git cherry-pick -x 4e440abc894585a34c2904a32cd54af1742311b3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2024021936-mulch-prone-c0a6@gregkh' --subject-prefix 'PATCH 6.7.y' HEAD^..
Possible dependencies:
4e440abc8945 ("hwmon: (coretemp) Fix out-of-bounds memory access")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 4e440abc894585a34c2904a32cd54af1742311b3 Mon Sep 17 00:00:00 2001
From: Zhang Rui <[email protected]>
Date: Fri, 2 Feb 2024 17:21:34 +0800
Subject: [PATCH] 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.
drivers/hwmon/coretemp.c +2 -6
@@ -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 ;