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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAM9d7cj_TAQb5phBmo1R5OSS-DGQimszqb8PhQqoFYjw6sRgaA@mail.gmail.com>
Date:   Thu, 22 Jun 2023 22:01:59 -0700
From:   Namhyung Kim <namhyung@...nel.org>
To:     Ian Rogers <irogers@...gle.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Ivan Babrou <ivan@...udflare.com>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] perf unwind: Fix map reference counts

On Thu, Jun 22, 2023 at 9:31 PM Ian Rogers <irogers@...gle.com> wrote:
>
> The result of thread__find_map is the map in the passed in
> addr_location. Calling addr_location__exit puts that map and so copies
> need to do a map__get. Add in the corresponding map__puts.
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>

Acked-by: Namhyung Kim <namhyung@...nel.org>

Thanks,
Namhyung


>
> v2. Add missing map__put when dso is missing.
> ---
>  tools/perf/util/unwind-libunwind-local.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
> index 36bf5100bad2..ebfde537b99b 100644
> --- a/tools/perf/util/unwind-libunwind-local.c
> +++ b/tools/perf/util/unwind-libunwind-local.c
> @@ -419,7 +419,8 @@ static struct map *find_map(unw_word_t ip, struct unwind_info *ui)
>         struct map *ret;
>
>         addr_location__init(&al);
> -       ret = thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al);
> +       thread__find_map(ui->thread, PERF_RECORD_MISC_USER, ip, &al);
> +       ret = map__get(al.map);
>         addr_location__exit(&al);
>         return ret;
>  }
> @@ -440,8 +441,10 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
>                 return -EINVAL;
>
>         dso = map__dso(map);
> -       if (!dso)
> +       if (!dso) {
> +               map__put(map);
>                 return -EINVAL;
> +       }
>
>         pr_debug("unwind: find_proc_info dso %s\n", dso->name);
>
> @@ -476,11 +479,11 @@ find_proc_info(unw_addr_space_t as, unw_word_t ip, unw_proc_info_t *pi,
>
>                 memset(&di, 0, sizeof(di));
>                 if (dwarf_find_debug_frame(0, &di, ip, base, symfile, start, map__end(map)))
> -                       return dwarf_search_unwind_table(as, ip, &di, pi,
> -                                                        need_unwind_info, arg);
> +                       ret = dwarf_search_unwind_table(as, ip, &di, pi,
> +                                                       need_unwind_info, arg);
>         }
>  #endif
> -
> +       map__put(map);
>         return ret;
>  }
>
> @@ -534,12 +537,14 @@ static int access_dso_mem(struct unwind_info *ui, unw_word_t addr,
>
>         dso = map__dso(map);
>
> -       if (!dso)
> +       if (!dso) {
> +               map__put(map);
>                 return -1;
> +       }
>
>         size = dso__data_read_addr(dso, map, ui->machine,
>                                    addr, (u8 *) data, sizeof(*data));
> -
> +       map__put(map);
>         return !(size == sizeof(*data));
>  }
>
> --
> 2.41.0.162.gfafddb0af9-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ