From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: stable@vger.kernel.org, Hagen Paul Pfeifer <hagen@jauu.net>,
lkml <linux-kernel@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Michael Petlan <mpetlan@redhat.com>
Subject: Re: [PATCH] perf tools: Fix printable strings in python3 scripts
Date: Thu, 1 Oct 2020 12:12:47 -0300 [thread overview]
Message-ID: <20201001151247.GC18693@kernel.org> (raw)
In-Reply-To: <20200928201135.3633850-1-jolsa@kernel.org>
Em Mon, Sep 28, 2020 at 10:11:35PM +0200, Jiri Olsa escreveu:
> Hagen reported broken strings in python3 tracepoint scripts:
>
> make PYTHON=python3
> ./perf record -e sched:sched_switch -a -- sleep 5
> ./perf script --gen-script py
> ./perf script -s ./perf-script.py
>
> [..]
> sched__sched_switch 7 563231.759525792 0 swapper \
> prev_comm=bytearray(b'swapper/7\x00\x00\x00\x00\x00\x00\x00'), \
> prev_pid=0, prev_prio=120, prev_state=, next_comm=bytearray(b'mutex-thread-co\x00'),
>
> The problem is in is_printable_array function that does not take
> zero byte into account and claim such string as not printable,
> so the code will create byte array instead of string.
Thanks, tested and applied.
- Arnaldo
> Cc: stable@vger.kernel.org
> Fixes: 249de6e07458 ("perf script python: Fix string vs byte array resolving")
> Tested-by: Hagen Paul Pfeifer <hagen@jauu.net>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> tools/perf/util/print_binary.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/print_binary.c b/tools/perf/util/print_binary.c
> index 599a1543871d..13fdc51c61d9 100644
> --- a/tools/perf/util/print_binary.c
> +++ b/tools/perf/util/print_binary.c
> @@ -50,7 +50,7 @@ int is_printable_array(char *p, unsigned int len)
>
> len--;
>
> - for (i = 0; i < len; i++) {
> + for (i = 0; i < len && p[i]; i++) {
> if (!isprint(p[i]) && !isspace(p[i]))
> return 0;
> }
> --
> 2.26.2
>
--
- Arnaldo
prev parent reply other threads:[~2020-10-01 15:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-28 20:11 [PATCH] perf tools: Fix printable strings in python3 scripts Jiri Olsa
2020-10-01 15:12 ` Arnaldo Carvalho de Melo [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201001151247.GC18693@kernel.org \
--to=acme@kernel.org \
--cc=a.p.zijlstra@chello.nl \
--cc=alexander.shishkin@linux.intel.com \
--cc=hagen@jauu.net \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=mpetlan@redhat.com \
--cc=namhyung@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.