From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Ian Rogers <irogers@google.com>,
Kan Liang <kan.liang@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Adrian Hunter <adrian.hunter@intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linux-perf-users@vger.kernel.org,
Athira Rajeev <atrajeev@linux.vnet.ibm.com>,
Masami Hiramatsu <mhiramat@kernel.org>
Subject: Re: [PATCH 1/9] perf dwarf-aux: Check allowed location expressions when collecting variables
Date: Sun, 18 Aug 2024 01:24:11 +0900 [thread overview]
Message-ID: <20240818012411.a00eb93e5b8f9cf45e2f513b@kernel.org> (raw)
In-Reply-To: <20240816235840.2754937-2-namhyung@kernel.org>
On Fri, 16 Aug 2024 16:58:31 -0700
Namhyung Kim <namhyung@kernel.org> wrote:
> It missed to call check_allowed_ops() in __die_collect_vars_cb() so it
> can take variables with complex location expression incorrectly.
>
> For example, I found some variable has this expression.
>
> 015d8df8 ffffffff81aacfb3 (base address)
> 015d8e01 v000000000000004 v000000000000000 views at 015d8df2 for:
> ffffffff81aacfb3 ffffffff81aacfd2 (DW_OP_fbreg: -176; DW_OP_deref;
> DW_OP_plus_uconst: 332; DW_OP_deref_size: 4;
> DW_OP_lit1; DW_OP_shra; DW_OP_const1u: 64;
> DW_OP_minus; DW_OP_stack_value)
> 015d8e14 v000000000000000 v000000000000000 views at 015d8df4 for:
> ffffffff81aacfd2 ffffffff81aacfd7 (DW_OP_reg3 (rbx))
> 015d8e19 v000000000000000 v000000000000000 views at 015d8df6 for:
> ffffffff81aacfd7 ffffffff81aad020 (DW_OP_fbreg: -176; DW_OP_deref;
> DW_OP_plus_uconst: 332; DW_OP_deref_size: 4;
> DW_OP_lit1; DW_OP_shra; DW_OP_const1u: 64;
> DW_OP_minus; DW_OP_stack_value)
> 015d8e2c <End of list>
>
> It looks like '((int *)(-176(%rbp) + 332) >> 1) - 64' but the current
> code thought it's just -176(%rbp) and processed the variable incorrectly.
> It should reject such a complex expression if check_allowed_ops()
> doesn't like it. :)
Looks good to me. Hmm, I should reconsider to support this complex variable
on ftrace probe events...
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thanks,
>
> Fixes: 932dcc2c39ae ("perf dwarf-aux: Add die_collect_vars()")
> Cc: Masami Hiramatsu <mhiramat@kernel.org>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
> ---
> tools/perf/util/dwarf-aux.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/perf/util/dwarf-aux.c b/tools/perf/util/dwarf-aux.c
> index 5e080d7e22c2..beb632153a74 100644
> --- a/tools/perf/util/dwarf-aux.c
> +++ b/tools/perf/util/dwarf-aux.c
> @@ -1598,6 +1598,9 @@ static int __die_collect_vars_cb(Dwarf_Die *die_mem, void *arg)
> if (dwarf_getlocations(&attr, 0, &base, &start, &end, &ops, &nops) <= 0)
> return DIE_FIND_CB_SIBLING;
>
> + if (!check_allowed_ops(ops, nops))
> + return DIE_FIND_CB_SIBLING;
> +
> if (die_get_real_type(die_mem, &type_die) == NULL)
> return DIE_FIND_CB_SIBLING;
>
> --
> 2.46.0.184.g6999bdac58-goog
>
>
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2024-08-17 16:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-16 23:58 [PATCHSET 0/9] perf annotate-data: Update data-type profiling quality (v1) Namhyung Kim
2024-08-16 23:58 ` [PATCH 1/9] perf dwarf-aux: Check allowed location expressions when collecting variables Namhyung Kim
2024-08-17 16:24 ` Masami Hiramatsu [this message]
2024-08-16 23:58 ` [PATCH 2/9] perf annotate-data: Fix off-by-one in location range check Namhyung Kim
2024-08-18 13:22 ` Masami Hiramatsu
2024-08-16 23:58 ` [PATCH 3/9] perf annotate-data: Add enum type_match_result Namhyung Kim
2024-08-16 23:58 ` [PATCH 4/9] perf annotate-data: Add variable_state_str() Namhyung Kim
2024-08-16 23:58 ` [PATCH 5/9] perf annotate-data: Change return type of find_data_type_block() Namhyung Kim
2024-08-16 23:58 ` [PATCH 6/9] perf annotate-data: Add is_pointer_type() helper Namhyung Kim
2024-08-16 23:58 ` [PATCH 7/9] perf annotate-data: Add is_better_type() helper Namhyung Kim
2024-08-16 23:58 ` [PATCH 8/9] perf annotate-data: Check variables in every scope Namhyung Kim
2024-08-16 23:58 ` [PATCH 9/9] perf annotate-data: Update type stat at the end of find_data_type_die() Namhyung Kim
2024-08-19 19:35 ` [PATCHSET 0/9] perf annotate-data: Update data-type profiling quality (v1) 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=20240818012411.a00eb93e5b8f9cf45e2f513b@kernel.org \
--to=mhiramat@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=atrajeev@linux.vnet.ibm.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.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