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: <CAM9d7ch5b9XHzQ-Hb=kPu-6jLyESWqgizz6MRNWb0d-NnK9aqg@mail.gmail.com>
Date: Tue, 16 Jan 2024 13:53:49 -0800
From: Namhyung Kim <namhyung@...nel.org>
To: Ilkka Koskinen <ilkka@...amperecomputing.com>
Cc: James Clark <james.clark@....com>, linux-perf-users@...r.kernel.org, 
	linux-kernel@...r.kernel.org, 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>
Subject: Re: [PATCH] perf data convert: Fix segfault when converting to json
 on arm64

Hello,

On Fri, Jan 12, 2024 at 3:35 AM James Clark <james.clark@....com> wrote:
>
>
>
> On 11/01/2024 23:29, 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>
> > ---
> >  tools/perf/util/data-convert-json.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/tools/perf/util/data-convert-json.c b/tools/perf/util/data-convert-json.c
> > index 5bb3c2ba95ca..5d6de1cef546 100644
> > --- a/tools/perf/util/data-convert-json.c
> > +++ b/tools/perf/util/data-convert-json.c
> > @@ -97,6 +97,11 @@ static void output_json_format(FILE *out, bool comma, int depth, const char *for
> >  static void output_json_key_string(FILE *out, bool comma, int depth,
> >               const char *key, const char *value)
> >  {
> > +     if (!value) {
> > +             pr_info("No value set for key %s\n", key);
> > +             return;
> > +     }
> > +
> >       output_json_delimiters(out, comma, depth);
> >       output_json_string(out, key);
> >       fputs(": ", out);
>
>
> It looks like this would hide new errors on any of the other fields that
> output_json_key_string() is called on. Maybe it would be better to only
> wrap the call to output cpu_desc with the if? If that's the only one
> that we think is optional, and even better only do it for arm64.
>
> I mention this because the test for 'perf data convert' only checks for
> valid json syntax, but not any fields. So we might want to avoid others
> going missing.

Makes sense.  Ilkka, can you send v2 with this?

Thanks,
Namhyung

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ