diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2023-03-16 22:41:54 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2023-04-04 15:39:56 +0300 |
commit | c8bb2d76a40ac0ccf6303d369e536fddcde847fb (patch) | |
tree | 3f71d1f2f130cdfd35eaa4a4063159cb7cc25620 /tools/perf/util/symbol-elf.c | |
parent | 5d9df8731c0941f3add30f96745a62586a0c9d52 (diff) | |
download | linux-c8bb2d76a40ac0ccf6303d369e536fddcde847fb.tar.xz |
perf symbols: Fix use-after-free in get_plt_got_name()
Fix use-after-free in get_plt_got_name().
Discovered using EXTRA_CFLAGS="-fsanitize=undefined -fsanitize=address".
Fixes: ce4c8e7966f317ef ("perf symbols: Get symbols for .plt.got for x86-64")
Reported-by: kernel test robot <yujie.liu@intel.com>
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/oe-lkp/202303061424.6ad43294-yujie.liu@intel.com
Link: https://lore.kernel.org/r/20230316194156.8320-2-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/symbol-elf.c')
-rw-r--r-- | tools/perf/util/symbol-elf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c index c0a2de42c51b..7ef5f6d7d415 100644 --- a/tools/perf/util/symbol-elf.c +++ b/tools/perf/util/symbol-elf.c @@ -557,6 +557,7 @@ static bool get_plt_got_name(GElf_Shdr *shdr, size_t i, const char *sym_name; char *demangled; GElf_Sym sym; + bool result; u32 disp; if (!di->sorted) @@ -583,9 +584,11 @@ static bool get_plt_got_name(GElf_Shdr *shdr, size_t i, snprintf(buf, buf_sz, "%s@plt", sym_name); + result = *sym_name; + free(demangled); - return *sym_name; + return result; } static int dso__synthesize_plt_got_symbols(struct dso *dso, Elf *elf, |