[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Ziqkb9lF30W0XX5d@x1>
Date: Thu, 25 Apr 2024 15:43:59 -0300
From: Arnaldo Carvalho de Melo <acme@...nel.org>
To: Adrian Hunter <adrian.hunter@...el.com>
Cc: Ian Rogers <irogers@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Namhyung Kim <namhyung@...nel.org>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org
Subject: Re: [PATCH] perf intel-pt: Fix unassigned instruction op
On Tue, Mar 26, 2024 at 06:52:12PM +0200, Adrian Hunter wrote:
> On 26/03/24 18:13, Ian Rogers wrote:
> > On Tue, Mar 26, 2024 at 1:32 AM Adrian Hunter <adrian.hunter@...el.com> wrote:
> >>
> >> MemorySanitizer discovered instances where the instruction op value was
> >> not assigned.:
> >>
> >> WARNING: MemorySanitizer: use-of-uninitialized-value
> >> #0 0x5581c00a76b3 in intel_pt_sample_flags tools/perf/util/intel-pt.c:1527:17
> >> Uninitialized value was stored to memory at
> >> #0 0x5581c005ddf8 in intel_pt_walk_insn tools/perf/util/intel-pt-decoder/intel-pt-decoder.c:1256:25
> >>
> >> The op value is used to set branch flags for branch instructions
> >> encountered when walking the code, so fix by setting op to
> >> INTEL_PT_OP_OTHER in other cases.
> >>
> >> Reported-by: Ian Rogers <irogers@...gle.com>
> >> Closes: https://lore.kernel.org/linux-perf-users/20240320162619.1272015-1-irogers@google.com/
> >> Signed-off-by: Adrian Hunter <adrian.hunter@...el.com>
> >
> > Great, thanks! Should it have a Fixes tag like:
> >
> > Fixes: 4c761d805bb2 ("perf intel-pt: Fix intel_pt_fup_event()
> > assumptions about setting state type")
>
> Yes, I should have put a fixes tag, cc stable. I think the issue
> has always been there, so:
>
> Fixes: 90e457f7be087 ("perf tools: Add Intel PT support")
> Cc: stable@...r.kernel.org
Thanks, applied, had fell thru the cracks :-\
- Arnaldo
> >
> > Tested-by: Ian Rogers <irogers@...gle.com>
> >
> > Ian
> >
> >> ---
> >> tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 ++
> >> tools/perf/util/intel-pt.c | 2 ++
> >> 2 files changed, 4 insertions(+)
> >>
> >> diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
> >> index b450178e3420..e733f6b1f7ac 100644
> >> --- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
> >> +++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
> >> @@ -1319,6 +1319,8 @@ static bool intel_pt_fup_event(struct intel_pt_decoder *decoder, bool no_tip)
> >> bool ret = false;
> >>
> >> decoder->state.type &= ~INTEL_PT_BRANCH;
> >> + decoder->state.insn_op = INTEL_PT_OP_OTHER;
> >> + decoder->state.insn_len = 0;
> >>
> >> if (decoder->set_fup_cfe_ip || decoder->set_fup_cfe) {
> >> bool ip = decoder->set_fup_cfe_ip;
> >> diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
> >> index f38893e0b036..4db9a098f592 100644
> >> --- a/tools/perf/util/intel-pt.c
> >> +++ b/tools/perf/util/intel-pt.c
> >> @@ -764,6 +764,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
> >>
> >> addr_location__init(&al);
> >> intel_pt_insn->length = 0;
> >> + intel_pt_insn->op = INTEL_PT_OP_OTHER;
> >>
> >> if (to_ip && *ip == to_ip)
> >> goto out_no_cache;
> >> @@ -898,6 +899,7 @@ static int intel_pt_walk_next_insn(struct intel_pt_insn *intel_pt_insn,
> >>
> >> if (to_ip && *ip == to_ip) {
> >> intel_pt_insn->length = 0;
> >> + intel_pt_insn->op = INTEL_PT_OP_OTHER;
> >> goto out_no_cache;
> >> }
> >>
> >> --
> >> 2.34.1
> >>
>
Powered by blists - more mailing lists