From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 962044A3B for ; Mon, 19 Feb 2024 18:53:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708368830; cv=none; b=U70wg1ueP1L5BgK5y94gfDF/GB/Rm9A0PI2cCaGX35OdGVVmxYW3A7jimWLaoiWUAI+U/4d92toF5aRPBHj+sUL2+2wGmHCkMBV1cE+qyx3ewn6W3CjNoLRxeiItR96a2fSdc0b7twsKkYXuspCDq3AZ8kpF+HSib45Xrn6IJZI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708368830; c=relaxed/simple; bh=+cufyo4sI2Nr7LwwLKGND+Y36cvahIvciyIjm5Nktg4=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=Jxdxj6ohqtuEpc2Tn4px6NOW6roiDGRmC3p7B4r7XWeQcmcB7vxVKf+dSUm/e3Q2Rb2K7B8czRjLe4MnaVjxOwI9gniIkm6/J7L4APKXVcSmoM/f7Pq3OLC1T5Q2E8n7zJSHSZxcTZD0hcrUi0sCV+tuFSg/crzF1Og7yfcF9+E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XNgqkX36; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="XNgqkX36" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06DB6C433F1; Mon, 19 Feb 2024 18:53:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708368830; bh=+cufyo4sI2Nr7LwwLKGND+Y36cvahIvciyIjm5Nktg4=; h=Subject:To:Cc:From:Date:From; b=XNgqkX368ZOw6PiZp4g5t4OcH9BbO9sRL1+CU5vAizSb+I6auOo3eXTnB1CqGtNwK 6pPHXsZitDrTtZiWhk6w1hGywoYXnnrmmY2IUd62TxjMG83PFi5SXER358WM1N3EmQ vFaybUksaEsdxVuvmTt2YrBRhOQuEqxppql7r0iM= Subject: FAILED: patch "[PATCH] hwmon: (coretemp) Fix out-of-bounds memory access" failed to apply to 5.15-stable tree To: rui.zhang@intel.com,linux@roeck-us.net,stable@vger.kernel.org Cc: From: Date: Mon, 19 Feb 2024 19:53:39 +0100 Message-ID: <2024021939-blunt-uncouple-5a31@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-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 . 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-5.15.y git checkout FETCH_HEAD git cherry-pick -x 4e440abc894585a34c2904a32cd54af1742311b3 # git commit -s git send-email --to '' --in-reply-to '2024021939-blunt-uncouple-5a31@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^.. Possible dependencies: 4e440abc8945 ("hwmon: (coretemp) Fix out-of-bounds memory access") 7108b80a542b ("hwmon/coretemp: Handle large core ID value") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 4e440abc894585a34c2904a32cd54af1742311b3 Mon Sep 17 00:00:00 2001 From: Zhang Rui 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. Fixes: 7108b80a542b ("hwmon/coretemp: Handle large core ID value") Signed-off-by: Zhang Rui Cc: Link: https://lore.kernel.org/r/20240202092144.71180-2-rui.zhang@intel.com Signed-off-by: Guenter Roeck 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;