linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Ian Rogers <irogers@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org
Subject: Re: [PATCH] perf intel-pt: Fix unassigned instruction op
Date: Tue, 26 Mar 2024 18:52:12 +0200	[thread overview]
Message-ID: <d7b31967-0820-4eef-8746-db0299af154f@intel.com> (raw)
In-Reply-To: <CAP-5=fVbR8xvFvG_cnzq6==QbZ1wX9mPT-RWHEMgaTp6ic0jNA@mail.gmail.com>

On 26/03/24 18:13, Ian Rogers wrote:
> On Tue, Mar 26, 2024 at 1:32 AM Adrian Hunter <adrian.hunter@intel.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@google.com>
>> Closes: https://lore.kernel.org/linux-perf-users/20240320162619.1272015-1-irogers@google.com/
>> Signed-off-by: Adrian Hunter <adrian.hunter@intel.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@vger.kernel.org

> 
> Tested-by: Ian Rogers <irogers@google.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
>>


  reply	other threads:[~2024-03-26 16:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-20 16:26 [PATCH v1] perf intel-pt: Fix memory sanitizer use-of-uninitialized-value Ian Rogers
2024-03-25 15:44 ` Ian Rogers
2024-03-25 16:06   ` Adrian Hunter
2024-03-26  8:32 ` [PATCH] perf intel-pt: Fix unassigned instruction op Adrian Hunter
2024-03-26 16:13   ` Ian Rogers
2024-03-26 16:52     ` Adrian Hunter [this message]
2024-04-25 18:43       ` Arnaldo Carvalho de Melo

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=d7b31967-0820-4eef-8746-db0299af154f@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=acme@kernel.org \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).