Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp4092856ybf; Tue, 3 Mar 2020 19:59:05 -0800 (PST) X-Google-Smtp-Source: ADFU+vsemSHN5XufN2ctw+F8NIbeGQrbB7Yz3b9/TrnSOiZOJtuReLt9UsYKFALQkOPdWRI/Ecpa X-Received: by 2002:a05:6830:118c:: with SMTP id u12mr847528otq.124.1583294345448; Tue, 03 Mar 2020 19:59:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583294345; cv=none; d=google.com; s=arc-20160816; b=s/9kuHj+Oqc/yBtIGeoUnlL9bKXff6JnKve1t92rxwmlqfn0or2W+9PqMhlWXh4udG zovBu63fiLDG+yQHEqbOSPSlsg3eUyRPT7Ary/NmtNNHxmhK9v0yXBMxmie1EszQQjp5 AcMC+PYuPNE1ZYmjvqHZUJdrv8oVbAQrXgaCtQXI1eSfoblrw3IXh5buGNi0ep7zZ0QY NS0NE9zTGAyyNT0+xy4J/2XOG5AyYfMNoMPSUSRg8b08/YYr/vVvlJbsbbXiO+kykkW+ c9svARpYjBDjvN8+YD6NZE7ArPBlEm+ox2g32zvuaVGHLsWzT+GklhOOTBDdkUS31Wh4 kaFg== 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=ldLMjDTiafkt0zfaSfIWkJkdUDrNSwTmWwGOnWWUSV4=; b=hD7EuiYgAlxecpi5JM3WC5hXBnj96CHoHWJR8htTPUfI8lq4kyAjHO1/8Hmfp0uIU1 kjWP7tBf1vqBfE9I0EQ55UWbD8Txo5893/xp5Kp17AQt64+qOV+a0WdoStIoNJwZZLwW r8EXXkkxpeI3DQOyeRtKeb5f3tvIugMIoKJhc92oTbX9Rpg84ml48DwcINV5DS4OOdHM x8KlT2s0vb8/Cll70jb10kQbeGAQreE+rjFvCD9LgFD5Qq1xNFU9+EeWZ/qbYlJg8oIp qjprQmeGW25BEW4m6cBUfopd2Y43QiHNvmwfQ58Pgu8wuYKg8W7o5fXu4eZRU8ADXsHj qSrA== 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 e26si389597otk.251.2020.03.03.19.58.52; Tue, 03 Mar 2020 19:59:05 -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 S1726094AbgCDD6l (ORCPT + 99 others); Tue, 3 Mar 2020 22:58:41 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:11141 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725796AbgCDD6l (ORCPT ); Tue, 3 Mar 2020 22:58:41 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 43BDCC901401D4F4FFA7; Wed, 4 Mar 2020 11:58:39 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Wed, 4 Mar 2020 11:58:32 +0800 From: Zeng Tao To: CC: , Zeng Tao , "Greg Kroah-Hartman" , "Rafael J. Wysocki" , Subject: [PATCH v2] cpu-topology: Fix the potential data corruption Date: Wed, 4 Mar 2020 11:54:52 +0800 Message-ID: <1583294092-5929-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 '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 --- Changelog: v1->v2: update the commit message suggested by sudeep. --- 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