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-next>] [day] [month] [year] [list]
Message-ID: <20250825195412.223077-1-zecheng@google.com>
Date: Mon, 25 Aug 2025 19:54:02 +0000
From: Zecheng Li <zecheng@...gle.com>
To: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>, 
	Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...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>, 
	"Liang, Kan" <kan.liang@...ux.intel.com>, Masami Hiramatsu <mhiramat@...nel.org>
Cc: Xu Liu <xliuprof@...gle.com>, linux-perf-users@...r.kernel.org, 
	linux-kernel@...r.kernel.org, Zecheng Li <zecheng@...gle.com>
Subject: [PATCH v2 00/10] perf tools: Some improvements on data type profiler

Hi all,

I've identified several missing data type annotations within the perf
tools when annotating the Linux kernel. This patch series improves the
coverage and correctness of data type annotations.

Here's a breakdown of the changes:

Patches 1-3 fix type matching from DWARF. They address cases with
negative offsets (e.g., from intrusive linked lists) and distinguish
DWARF expressions for variable value or address.

Patch 4 skips annotations for LEA instructions in x86, as these do not
involve memory access.

Patches 5-7 implement a basic approach for register offset tracking
based on add, sub, and lea operations. The register is invalidated when
an unsupported arithmetic instruction on that register is encountered.
While this feature has known limitations and may regress in rare cases
compared to the original, it generally improves offset tracking in most
scenarios.

Patch 8 skips check_variable when the type is found directly by
register, since sufficient checking is already performed in
match_var_offset. check_variable lacks some DWARF information to
correctly determine if a variable is valid.

Patch 9 fixes __die_find_scope_cb for namespaces. I found this issue
when trying to annotate a Rust program. The Die for a namespace doesn't
have a PC range, so it would be skipped. Therefore, we should check a
namespace's siblings and children.

Patch 10 implements support for DW_OP_piece. Currently, it is allowed in
check_allowed_ops but is handled like other single location expressions.
We should split any expression containing DW_OP_piece into multiple
parts and handle them separately.

I have tested each patch on a vmlinux and manually checked the results.
After applying all patches, there are less missing or incorrect
annotations. No obvious regressions were observed.

v2:
1. update the match_var_offset function signature to s64
2. correct the comment for is_breg_access_indirect. Use simpler logic to
match the expressions we support.
3. add is_reg_var_addr to indicate whether a register holds an address
of the variable. This defers the type dereference logic to
update_var_state.
4. invalidate register state for unsupported instructions.
5. include two new patches related to improving data type profiler.

v1: https://lore.kernel.org/linux-perf-users/20250725202809.1230085-1-zecheng@google.com/

Zecheng Li (10):
  perf dwarf-aux: Use signed variable types in match_var_offset
  perf dwarf-aux: More accurate variable type match for breg
  perf dwarf-aux: Better variable collection for insn tracking
  perf annotate: Skip annotating data types to lea instructions
  perf dwarf-aux: Find pointer type to a type
  perf annotate: Track arithmetic instructions on pointers
  perf annotate: Invalidate register states for unsupported instructions
  perf dwarf-aux: Skip check_variable for die_find_variable_by_reg
  perf dwarf-aux: fix __die_find_scope_cb for namespaces
  perf dwarf-aux: support DW_OP_piece expressions

 tools/perf/arch/x86/annotate/instructions.c | 155 +++++++-
 tools/perf/util/annotate-data.c             |  35 +-
 tools/perf/util/annotate-data.h             |   6 +
 tools/perf/util/annotate.c                  |  18 +
 tools/perf/util/dwarf-aux.c                 | 372 ++++++++++++++++----
 tools/perf/util/dwarf-aux.h                 |   8 +-
 6 files changed, 519 insertions(+), 75 deletions(-)

-- 
2.51.0.261.g7ce5a0a67e-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ