lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d77856e0-50e8-b7b4-734-93be3447ed73@os.amperecomputing.com>
Date: Thu, 22 Feb 2024 13:42:23 -0800 (PST)
From: Ilkka Koskinen <ilkka@...amperecomputing.com>
To: Namhyung Kim <namhyung@...nel.org>, James Clark <james.clark@....com>
cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
    Arnaldo Carvalho de Melo <acme@...nel.org>, 
    Mark Rutland <mark.rutland@....com>, 
    Alexander Shishkin <alexander.shishkin@...ux.intel.com>, 
    Jiri Olsa <jolsa@...nel.org>, Ian Rogers <irogers@...gle.com>, 
    Adrian Hunter <adrian.hunter@...el.com>, 
    Evgeny Pistun <kotborealis@...oo.ru>, 
    Ilkka Koskinen <ilkka@...amperecomputing.com>, 
    linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] perf data convert: Fix segfault when converting to
 json on arm64


cc: Evgeny Pistun since he submitted a patch pretty similar to my first 
version
(https://lore.kernel.org/all/20240125184411.30757-1-kotborealis@awooo.ru/)



Namhyung and James,

What's your thought on this? Is one of the patches (Evgeny's or mine) 
good enough or should we try some other approach?

Cheers, Ilkka


On Wed, 17 Jan 2024, Ilkka Koskinen wrote:
> Arm64 doesn't have Model in /proc/cpuinfo and, thus, cpu_desc doesn't get
> assigned.
>
> Running
> 	$ perf data convert --to-json perf.data.json
>
> ends up calling output_json_string() with NULL pointer, which causes a
> segmentation fault.
>
> Signed-off-by: Ilkka Koskinen <ilkka@...amperecomputing.com>
> ---
> v1:
>    - https://lore.kernel.org/all/20240111232923.8138-1-ilkka@os.amperecomputing.com/
> v2:
>    - Changed the patch based on James's comments.
> v3:
>    - The architecture is checked from the actual data file to allow one to do
>      conversion on another system. (thanks to James for the feedback)
> ---
> tools/perf/util/data-convert-json.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c
> index 5bb3c2ba95ca..405c38371870 100644
> --- a/tools/perf/util/data-convert-json.c
> +++ b/tools/perf/util/data-convert-json.c
> @@ -284,7 +284,13 @@ static void output_headers(struct perf_session *session, struct convert_json *c)
> 	output_json_key_string(out, true, 2, "os-release", header->env.os_release);
> 	output_json_key_string(out, true, 2, "arch", header->env.arch);
>
> -	output_json_key_string(out, true, 2, "cpu-desc", header->env.cpu_desc);
> +	/*
> +	 * Arm64 doesn't have Model section in /proc/cpuinfo and, thus, cpu-desc
> +	 * is not set.
> +	 */
> +	if (strncmp(header->env.arch, "aarch64", 7))
> +		output_json_key_string(out, true, 2, "cpu-desc", header->env.cpu_desc);
> +
> 	output_json_key_string(out, true, 2, "cpuid", header->env.cpuid);
> 	output_json_key_format(out, true, 2, "nrcpus-online", "%u", header->env.nr_cpus_online);
> 	output_json_key_format(out, true, 2, "nrcpus-avail", "%u", header->env.nr_cpus_avail);
> -- 
> 2.43.0
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ