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: <CAP-5=fV59uES4ZkNHDUypeO0XSnjkUTDWLydvaymEsegyeSb-w@mail.gmail.com>
Date: Tue, 30 Sep 2025 13:05:33 -0700
From: Ian Rogers <irogers@...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>, 
	Kan Liang <kan.liang@...ux.intel.com>, linux-perf-users@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] perf sched: Avoid union type punning undefined behavior

On Sun, Sep 14, 2025 at 11:33 AM Ian Rogers <irogers@...gle.com> wrote:
>
> A union is used to set the priv value in thread (a void*) to a boolean
> value through type punning. Undefined behavior sanitizer fails on this.
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>

Ping.

Thanks,
Ian

> ---
>  tools/perf/builtin-sched.c | 19 ++++---------------
>  1 file changed, 4 insertions(+), 15 deletions(-)
>
> diff --git a/tools/perf/builtin-sched.c b/tools/perf/builtin-sched.c
> index f166d6cbc083..eca3b1c58c4b 100644
> --- a/tools/perf/builtin-sched.c
> +++ b/tools/perf/builtin-sched.c
> @@ -1532,35 +1532,24 @@ static int process_sched_wakeup_ignore(const struct perf_tool *tool __maybe_unus
>         return 0;
>  }
>
> -union map_priv {
> -       void    *ptr;
> -       bool     color;
> -};
> -
>  static bool thread__has_color(struct thread *thread)
>  {
> -       union map_priv priv = {
> -               .ptr = thread__priv(thread),
> -       };
> -
> -       return priv.color;
> +       return thread__priv(thread) != NULL;
>  }
>
>  static struct thread*
>  map__findnew_thread(struct perf_sched *sched, struct machine *machine, pid_t pid, pid_t tid)
>  {
>         struct thread *thread = machine__findnew_thread(machine, pid, tid);
> -       union map_priv priv = {
> -               .color = false,
> -       };
> +       bool color = false;
>
>         if (!sched->map.color_pids || !thread || thread__priv(thread))
>                 return thread;
>
>         if (thread_map__has(sched->map.color_pids, tid))
> -               priv.color = true;
> +               color = true;
>
> -       thread__set_priv(thread, priv.ptr);
> +       thread__set_priv(thread, color ? ((void*)1) : NULL);
>         return thread;
>  }
>
> --
> 2.51.0.384.g4c02a37b29-goog
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ