Skip to content

Commit

Permalink
perf probe: Add protection to avoid endless loop
Browse files Browse the repository at this point in the history
if dwarf_offdie() returns NULL, the continue statement forces the next
iteration of the loop without updating the 'off' variable. It will cause
an endless loop in the process of traversing the compile unit.  So add
exception protection for looping CUs.

Signed-off-by: Jianlin Lv <Jianlin.Lv@arm.com>
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: jianlin.lv@arm.com
Link: http://lore.kernel.org/lkml/20210203145702.1219509-1-Jianlin.Lv@arm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Jianlin Lv authored and Arnaldo Carvalho de Melo committed Feb 8, 2021
1 parent d2e31d7 commit 900547d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/perf/util/probe-finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,10 @@ static int debuginfo__find_probe_location(struct debuginfo *dbg,
while (!dwarf_nextcu(dbg->dbg, off, &noff, &cuhl, NULL, NULL, NULL)) {
/* Get the DIE(Debugging Information Entry) of this CU */
diep = dwarf_offdie(dbg->dbg, off + cuhl, &pf->cu_die);
if (!diep)
if (!diep) {
off = noff;
continue;
}

/* Check if target file is included. */
if (pp->file)
Expand Down Expand Up @@ -1949,8 +1951,10 @@ int debuginfo__find_line_range(struct debuginfo *dbg, struct line_range *lr)

/* Get the DIE(Debugging Information Entry) of this CU */
diep = dwarf_offdie(dbg->dbg, off + cuhl, &lf.cu_die);
if (!diep)
if (!diep) {
off = noff;
continue;
}

/* Check if target file is included. */
if (lr->file)
Expand Down

0 comments on commit 900547d

Please sign in to comment.