Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp434371ybf; Fri, 28 Feb 2020 00:40:53 -0800 (PST) X-Google-Smtp-Source: APXvYqz7DOmjqLf/MfJJbq3SfQGO0d7StMdQlO1XibDphs3POZST9LOFZrwk5WEV+1XodHscXhVT X-Received: by 2002:a54:458d:: with SMTP id z13mr2416516oib.32.1582879253193; Fri, 28 Feb 2020 00:40:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582879253; cv=none; d=google.com; s=arc-20160816; b=THZk3r1lhliZEk5UAyCBTZe16Dwg0M/sfqBYW86PS6koUvHblJyYxIFa20ZHNRzGEr fV5d6D2fsPbZMcaeqnRQx307a/Hx7A9uGaHMZDYzKY76evM9HwVnkRFgYh+ge3GFMsIg YrQKiRp5rLq0fJjbawYSQyglHlyGtpp+usMYJIy+KSl4MHzwAlxu/olJNtOoY+5T5oAH RHky8slVgm5YIyu98WotBO9SUdr4ABVOP+0Kt/lzWE/FQpgUfM1HJD/89mRQBYnjOgAW WNfHV6toxx1/cPqkyQhlHi5eVj8L5DKWMn63ZG/nKiBjSEqrXNnTtPPjMnAIZ3OqX31U DdiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=sf2HRBeMBVgajixEyYMBtCE2t2VuOkAiWz3rjF2TDrc=; b=mFkFBrdOfZttoEXRFRJMLeHGX80NPKCtpujS8/tN70absPrBBB6UREu4LHTvTopZVw fdVIFHvKTwEVvbRW1X6+UQjW1k9Y5v6TmaWF8FxIntWJNxxYfgvkyH3Jex0Ba4oy6fdA icaIhhAT2b6J7w7T9E9Pxdwuo3auWIZ+pmze2a4QomX9Iq4rvZ2E0SCCIO6cnWAGUFI8 TBWg/Q5UfvWkax0soWJV7uDg8cTUgz/oqc/dTnwPSbUrATdhjoqSXlbvHpMrrkMF3iEp HlaqnHwdbs+M8QmHF9+WplT2/oeoeiyC+OqvBMAt798Fkii40fMVEbRnEJP0+mj3+CIX 1hcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si1065358ota.230.2020.02.28.00.40.40; Fri, 28 Feb 2020 00:40:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726207AbgB1Ik2 (ORCPT + 99 others); Fri, 28 Feb 2020 03:40:28 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11121 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725877AbgB1Ik1 (ORCPT ); Fri, 28 Feb 2020 03:40:27 -0500 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 69D972B2DC7E9AB1EB50; Fri, 28 Feb 2020 16:40:19 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.439.0; Fri, 28 Feb 2020 16:40:11 +0800 From: Zeng Tao To: CC: , Zeng Tao , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , Subject: [PATCH] cpu-topology: Fix the potential data corruption Date: Fri, 28 Feb 2020 16:35:45 +0800 Message-ID: <1582878945-50415-1-git-send-email-prime.zeng@hisilicon.com> X-Mailer: git-send-email 2.8.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently there are only 10 bytes to store the cpu-topology info. That is: snprintf(buffer, 10, "cluster%d",i); snprintf(buffer, 10, "thread%d",i); snprintf(buffer, 10, "core%d",i); In the boundary test, if the cluster number exceeds 100, there will be a data corrution, and the kernel will fall into dead loop. in the cluster parse function. So in this patch, enlarge the buffer to fix such potential issues. Signed-off-by: Zeng Tao --- 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 6119e11..f489883 100644 --- a/drivers/base/arch_topology.c +++ b/drivers/base/arch_topology.c @@ -281,7 +281,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; @@ -327,7 +327,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.8.1