Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp852822pxk; Thu, 17 Sep 2020 19:07:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4iO/YRjoPK9kmb6oIhsF55WIVGkqbXOy3l7VIxyv5aBYK86sufPIPoUtn39SoxqtzkHJ+ X-Received: by 2002:a50:cf0b:: with SMTP id c11mr35154310edk.87.1600394824222; Thu, 17 Sep 2020 19:07:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600394824; cv=none; d=google.com; s=arc-20160816; b=k67dt5KcOPXmVA6LII5td+XhiqnenHZsQCqRLzR3TSDlP+mYn2nMf9w6GB9g8HIgZa qLiGNVCQE45hjjr3gBheXNNL8ouvJVSGSouJ1og7vU3O2TTsEMUdH8yqRBN2Cal11Os7 WpLRHWiNXlCGJvN4TJvpVxTVF2ipEH4A2MOs1Us+CxTDKgEKCkrLauxAEhOj3InORpxh 6SR6H+b4oxHRuBDMX3G2K2Ziup3raMFTGMSNUOMHf4xt4aVUlduaYKM2QQAUEbPK7uAX 8BdJDR5ApGD0qRs6Oclrd+uFDZ84T4PGe4ke5410uILroa4Jvg/Wfz9oWd54hyZSn2K/ VgdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UAXBCb+0Mfontkwlhrbm2KVq4Lco4B4pEPbHFMHR3Hs=; b=MgVsNWcIZa9wf0Qb+L3hY6OQDHfcejFXWg7JprECxRFyaWMDj+/K5DQnQO8JR7/+fH ewWaLYzB/RaBZlQYV4yxzTfNLGjl4SW+vexjQtekClKMgBXcbksNUfnZk3tBCQn11f0z LpIjBk/e22pHzfHffW3B/yoYcpCRbKwd7QnKiYGN77fS1xw3rSWmIvysVq9BP0Z4S3wP ROeFKm44vu3AoI9AmaVRjNLk7jXVemf6+wwNUVmu7ZTxGAm+bk6OlFKZ9mDc0SUvaEqg jlkWIkY5eXsog2aoPx7EqsEeZ8AIBI8PBzXORuEXEpuEdeoYYYvhbaCRDWBBXyX7Ks6W Pqew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FwdSL9Cg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q24si1144526eja.493.2020.09.17.19.06.40; Thu, 17 Sep 2020 19:07:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FwdSL9Cg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727339AbgIRCEf (ORCPT + 99 others); Thu, 17 Sep 2020 22:04:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:51946 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727317AbgIRCEa (ORCPT ); Thu, 17 Sep 2020 22:04:30 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C8C4823119; Fri, 18 Sep 2020 02:04:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600394669; bh=9IqLsNCTVBVXseTgonF0WbfTdJQzI6mPYtBikZU3Pv0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FwdSL9CgP4iiTt6dtSkQ3I+EVhoDMWoRbGGFtYzNvn2k3uRxLs/ORhKJlMyOC6mFL EeXt/q0ir2/6XDiSAZyoPu5+fzrFnTaDsCFvdYFGST0xTymTtzekiM4/C4M07pfSz7 zjBYD5vyETznGEXkuKnXO/nmn3iCEjHDqMhRNMp4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zeng Tao , Sudeep Holla , Greg Kroah-Hartman , Sasha Levin Subject: [PATCH AUTOSEL 5.4 162/330] cpu-topology: Fix the potential data corruption Date: Thu, 17 Sep 2020 21:58:22 -0400 Message-Id: <20200918020110.2063155-162-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200918020110.2063155-1-sashal@kernel.org> References: <20200918020110.2063155-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zeng Tao [ Upstream commit 4a33691c4cea9eb0a7c66e87248be4637e14b180 ] Currently there are only 10 bytes to store the cpu-topology 'name' information. Only 10 bytes copied into cluster/thread/core names. If the cluster ID exceeds 2-digit number, it will result in the data corruption, and ending up in a dead loop in the parsing routines. The same applies to the thread names with more that 3-digit number. This issue was found using the boundary tests under virtualised environment like QEMU. Let us increase the buffer to fix such potential issues. Reviewed-by: Sudeep Holla Signed-off-by: Zeng Tao Link: https://lore.kernel.org/r/1583294092-5929-1-git-send-email-prime.zeng@hisilicon.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/base/arch_topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c index 1eb81f113786f..83e26fd188cc9 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -270,7 +270,7 @@ static int __init get_cpu_for_node(struct device_node *node) static int __init parse_core(struct device_node *core, int package_id, int core_id) { - char name[10]; + char name[20]; bool leaf = true; int i = 0; int cpu; @@ -317,7 +317,7 @@ static int __init parse_core(struct device_node *core, int package_id, static int __init parse_cluster(struct device_node *cluster, int depth) { - char name[10]; + char name[20]; bool leaf = true; bool has_cores = false; struct device_node *c; -- 2.25.1