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] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP-5=fV3Er=Ek8=iE=bSGbEBmM56_PJffMWot1g_5Bh8B5hO7A@mail.gmail.com>
Date:   Wed, 19 Jul 2023 15:31:41 -0700
From:   Ian Rogers <irogers@...gle.com>
To:     Arnaldo Carvalho de Melo <acme@...nel.org>
Cc:     Namhyung Kim <namhyung@...nel.org>, Ingo Molnar <mingo@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Jiri Olsa <jolsa@...nel.org>,
        Adrian Hunter <adrian.hunter@...el.com>,
        Clark Williams <williams@...hat.com>,
        Kate Carcia <kcarcia@...hat.com>, linux-kernel@...r.kernel.org,
        linux-perf-users@...r.kernel.org,
        Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: Re: [PATCH 2/6] perf thread: Allow tools to register a thread->priv destructor

On Wed, Jul 19, 2023 at 1:30 PM Arnaldo Carvalho de Melo
<acme@...nel.org> wrote:
>
> From: Arnaldo Carvalho de Melo <acme@...hat.com>
>
> So that when thread__delete() runs it can be called and free stuff tools
> stashed into thread->priv, like 'perf trace' does and will use this
> new facility to plug some leaks.
>
> Cc: Adrian Hunter <adrian.hunter@...el.com>
> Cc: Ian Rogers <irogers@...gle.com>
> Cc: Jiri Olsa <jolsa@...nel.org>
> Cc: Namhyung Kim <namhyung@...nel.org>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
> ---
>  tools/perf/util/thread.c | 11 +++++++++++
>  tools/perf/util/thread.h |  2 ++
>  2 files changed, 13 insertions(+)
>
> diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
> index 0b166404c5c365cf..35dd4e716e411da9 100644
> --- a/tools/perf/util/thread.c
> +++ b/tools/perf/util/thread.c
> @@ -80,6 +80,13 @@ struct thread *thread__new(pid_t pid, pid_t tid)
>         return NULL;
>  }
>
> +static void (*thread__priv_destructor)(void *priv);
> +
> +void thread__set_priv_destructor(void (*destructor)(void *priv))
> +{

Perhaps:
assert(thread__priv_destructor == NULL);

To make it clear that there should never be >1 currently.

> +       thread__priv_destructor = destructor;
> +}
> +
>  void thread__delete(struct thread *thread)
>  {
>         struct namespaces *namespaces, *tmp_namespaces;
> @@ -112,6 +119,10 @@ void thread__delete(struct thread *thread)
>         exit_rwsem(thread__namespaces_lock(thread));
>         exit_rwsem(thread__comm_lock(thread));
>         thread__free_stitch_list(thread);
> +
> +       if (thread__priv_destructor)
> +               thread__priv_destructor(thread__priv(thread));
> +
>         RC_CHK_FREE(thread);
>  }
>
> diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
> index 9068a21ce0fa1b0f..e79225a0ea46b789 100644
> --- a/tools/perf/util/thread.h
> +++ b/tools/perf/util/thread.h
> @@ -71,6 +71,8 @@ struct thread *thread__new(pid_t pid, pid_t tid);
>  int thread__init_maps(struct thread *thread, struct machine *machine);
>  void thread__delete(struct thread *thread);
>
> +void thread__set_priv_destructor(void (*destructor)(void *priv));
> +
>  struct thread *thread__get(struct thread *thread);
>  void thread__put(struct thread *thread);
>
> --
> 2.41.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ