Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp1412590imm; Thu, 5 Jul 2018 22:55:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcn0/GgmSewDznC+1L8iDmuQPmD9V/NnIiTkMLk0pjJzuN+U2bp/2Fiq4Y1DQ17pMQfpXoV X-Received: by 2002:a62:6698:: with SMTP id s24-v6mr9302855pfj.243.1530856505425; Thu, 05 Jul 2018 22:55:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530856505; cv=none; d=google.com; s=arc-20160816; b=cXZy40MIi/ABd6/ptE51PA+RPWpOWnsg82KsyNbqHWWNxv6EL+dstxSFIMIKxfbYk+ HpCerxjcT1BNITYITT0sfKGJF8XZ1Vq6KMMfDl9225zhOu2XXew/S0Y8LtdbEWsTWeM2 I+L9DSn6zAwrzX7B2+VGtuKjvMEmpVhiEAggoapX38/JgKeYrTjO/EC8vpT2Nx9X3WZF q2irwB7tnpCBCthSJnJqdwm0BuaK+X7nrRbFwbf3ZFgSZ4y9qIbpF+ZwNrX+SLCLiE8/ m2oDQPN+Tdm+sfHg0/hEzC7aVZ5B+Wx8LFIKWEaZeuMDAouCY+X8HMfjwny0oAQfwItq DKMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=beVRz2Ht1K4WNcr/oHMR5Io0hObLQSWad3YoTtS+TJU=; b=fw1AFV9BmQq19YUqUnYRoI9K7V0Vz+3s5b3A9ixGsevyfY35YP0FM06H1nqmSwZBo0 ws3vVq2kuY1u8MVhcp0OVwNrIlLuqNe3XjtrDAizaOhdhm323hLxCouy6WOSlvYIdWyx h+0/uGS3GVIUL3JrIOOGqSNopqWuMTCSbbWjuyGYxW/aJpe11ABfSsaiwt5pmtbHXI7V lmPoNTmShxrn7fY+QCiq0HBQaM3R7CbCf24hc0bUFrfmwfSKNt9Kfh64xmYqPrWYGGcg QGuw+X1rIzmBwbpo6nNd4NaRjpGjCScBdIJWsSCP3trbdAomDNRrXUsvwGpz5HowrX/F G84w== 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 y3-v6si7280699pge.41.2018.07.05.22.54.51; Thu, 05 Jul 2018 22:55:05 -0700 (PDT) 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 S934742AbeGFFxB (ORCPT + 99 others); Fri, 6 Jul 2018 01:53:01 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34038 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934657AbeGFFwz (ORCPT ); Fri, 6 Jul 2018 01:52:55 -0400 Received: from localhost (D57D388D.static.ziggozakelijk.nl [213.125.56.141]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 016E9BA2; Fri, 6 Jul 2018 05:52:54 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Richter , Heiko Carstens , Hendrik Brueckner , Martin Schwidefsky , Arnaldo Carvalho de Melo , Sasha Levin Subject: [PATCH 4.14 54/61] perf test: "Session topology" dumps core on s390 Date: Fri, 6 Jul 2018 07:47:18 +0200 Message-Id: <20180706054714.404844466@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180706054712.332416244@linuxfoundation.org> References: <20180706054712.332416244@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Richter [ Upstream commit d121109100bda84bbbb199dab97f9d56432ab235 ] The "perf test Session topology" entry fails with core dump on s390. The root cause is a NULL pointer dereference in function check_cpu_topology() line 76 (or line 82 without -v). The session->header.env.cpu variable is NULL because on s390 function process_cpu_topology() returns with error: socket_id number is too big. You may need to upgrade the perf tool. and releases the env.cpu variable via zfree() and sets it to NULL. Here is the gdb output: (gdb) n 76 pr_debug("CPU %d, core %d, socket %d\n", i, (gdb) n Program received signal SIGSEGV, Segmentation fault. 0x00000000010f4d9e in check_cpu_topology (path=0x3ffffffd6c8 "/tmp/perf-test-J6CHMa", map=0x14a1740) at tests/topology.c:76 76 pr_debug("CPU %d, core %d, socket %d\n", i, (gdb) Make sure the env.cpu variable is not used when its NULL. Test for NULL pointer and return TEST_SKIP if so. Output before: [root@p23lp27 perf]# ./perf test -F 39 39: Session topology :Segmentation fault (core dumped) [root@p23lp27 perf]# Output after: [root@p23lp27 perf]# ./perf test -vF 39 39: Session topology : --- start --- templ file: /tmp/perf-test-Ajx59D socket_id number is too big.You may need to upgrade the perf tool. ---- end ---- Session topology: Skip [root@p23lp27 perf]# Signed-off-by: Thomas Richter Cc: Heiko Carstens Cc: Hendrik Brueckner Cc: Martin Schwidefsky Link: http://lkml.kernel.org/r/20180528073657.11743-1-tmricht@linux.ibm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/tests/topology.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) --- a/tools/perf/tests/topology.c +++ b/tools/perf/tests/topology.c @@ -66,6 +66,27 @@ static int check_cpu_topology(char *path session = perf_session__new(&file, false, NULL); TEST_ASSERT_VAL("can't get session", session); + /* On platforms with large numbers of CPUs process_cpu_topology() + * might issue an error while reading the perf.data file section + * HEADER_CPU_TOPOLOGY and the cpu_topology_map pointed to by member + * cpu is a NULL pointer. + * Example: On s390 + * CPU 0 is on core_id 0 and physical_package_id 6 + * CPU 1 is on core_id 1 and physical_package_id 3 + * + * Core_id and physical_package_id are platform and architecture + * dependend and might have higher numbers than the CPU id. + * This actually depends on the configuration. + * + * In this case process_cpu_topology() prints error message: + * "socket_id number is too big. You may need to upgrade the + * perf tool." + * + * This is the reason why this test might be skipped. + */ + if (!session->header.env.cpu) + return TEST_SKIP; + for (i = 0; i < session->header.env.nr_cpus_avail; i++) { if (!cpu_map__has(map, i)) continue; @@ -91,7 +112,7 @@ int test__session_topology(struct test * { char path[PATH_MAX]; struct cpu_map *map; - int ret = -1; + int ret = TEST_FAIL; TEST_ASSERT_VAL("can't get templ file", !get_temp(path)); @@ -106,12 +127,9 @@ int test__session_topology(struct test * goto free_path; } - if (check_cpu_topology(path, map)) - goto free_map; - ret = 0; - -free_map: + ret = check_cpu_topology(path, map); cpu_map__put(map); + free_path: unlink(path); return ret;