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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <06233fa3-0663-4861-8fd0-ca30806d38a3@linaro.org>
Date: Thu, 20 Mar 2025 11:46:03 +0000
From: James Clark <james.clark@...aro.org>
To: Leo Yan <leo.yan@....com>
Cc: 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>,
 "Liang, Kan" <kan.liang@...ux.intel.com>, linux-perf-users@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] perf build: Use -fzero-init-padding-bits=all



On 20/03/2025 10:52 am, Leo Yan wrote:
> GCC-15 release claims [1]:
> 
>   {0} initializer in C or C++ for unions no longer guarantees clearing
>   of the whole union (except for static storage duration initialization),
>   it just initializes the first union member to zero. If initialization
>   of the whole union including padding bits is desirable, use {} (valid
>   in C23 or C++) or use -fzero-init-padding-bits=unions option to
>   restore old GCC behavior.
> 
> This new behaviour might cause unexpected data when we define a union
> with using the '{ 0 }' initializer.  Currently, the perf tool has ruled
> out these cases with the sanitizer "-fsanitize=undefined".
> 
> But the sanitizer is not enabled by default, we need to manually enable
> it with EXTRA_CFLAGS='-fsanitize=undefined'.  This means developers
> might encounter issues caused by the initializer with new compilers.
> 
> Enable -fzero-init-padding-bits=all to zero padding bits in unions and
> structures that might otherwise be left uninitialized.
> 
> [1] https://gcc.gnu.org/gcc-15/changes.html
> 
> Signed-off-by: Leo Yan <leo.yan@....com>
> ---
> 
> Changes from v1:
> - Changed to use '-fzero-init-padding-bits=all' to replace
>    '-fzero-init-padding-bits=unions'. (Namhyung)
> - Updated commit log for a bit background info. (Ian)
> 
>   tools/perf/Makefile.config | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index a148ca9efca9..b4f6d656c729 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -323,6 +323,8 @@ FEATURE_CHECK_LDFLAGS-libaio = -lrt
>   FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
>   FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl
>   
> +# Explicitly clear padding bits with the initializer '{ 0 }'
> +CORE_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
>   CORE_CFLAGS += -fno-omit-frame-pointer
>   CORE_CFLAGS += -Wall
>   CORE_CFLAGS += -Wextra

I don't think this makes its way to libperf. I don't have a compiler 
that supports it, but "-std=gnu11" is in CORE_CFLAGS and that's not 
there on any libperf compile commands so I'm assuming CORE_CFLAGS is 
only local to Perf.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ