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] [day] [month] [year] [list]
Message-ID: <20250507195646.GA3495761@ax162>
Date: Wed, 7 May 2025 20:56:46 +0100
From: Nathan Chancellor <nathan@...nel.org>
To: WangYuli <wangyuli@...ontech.com>
Cc: masahiroy@...nel.org, nicolas.schier@...ux.dev,
	linux-kbuild@...r.kernel.org, linux-kernel@...r.kernel.org,
	m.seyfarth@...il.com, zhanjun@...ontech.com,
	niecheng1@...ontech.com, guanwentao@...ontech.com
Subject: Re: [PATCH] kbuild: Disable -Wdefault-const-init-var-unsafe

On Wed, May 07, 2025 at 05:13:40PM +0800, WangYuli wrote:
> Similar to ("kbuild: Disable -Wdefault-const-init-field-unsafe")
> from list, -Wdefault-const-init-var-unsafe need to be disabled too.

Thanks for the change but I already sent a v2 of that change to cover
this warning too:

https://lore.kernel.org/20250506-default-const-init-clang-v2-1-fcfb69703264@kernel.org/

> While I haven't found this warning triggered in the kernel code
> itself (my testing covers just a tiny fraction), it's clearly
> something that should be disabled for the same reason.
> 
> Additionally, because dkms uses kernel compile parameters, some
> out-of-tree modules might also hit this warning, like the Mucse
> network driver.
> 
> Fix follow error with -Werror:
>   drivers/net/ethernet/mucse/rnpgbe/rnpgbe_main.c:6126:11: error: default initialization of an object of type 'const u8[6]' (aka 'const unsigned char[6]') leaves the object uninitialized and is incompatible with C++ [-Werror,-Wdefault-const-init-var-unsafe]
>    6126 |         const u8 target_addr[ETH_ALEN];
>         |                  ^
>   1 error generated.

For the record, we do not care if warnings trigger in out of tree code,
that is not justification enough to disable the warning. If this warning
is coming from rnpgbe_set_mac() like I have seen in some downstream
trees, I don't even understand why this is marked const when there is

  memcpy((void *)target_addr, addr->sa_data, netdev->addr_len);

right after it :/

> Link: https://lore.kernel.org/all/20250501-default-const-init-clang-v1-0-3d2c6c185dbb@kernel.org/
> Signed-off-by: WangYuli <wangyuli@...ontech.com>
> ---
>  scripts/Makefile.extrawarn | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn
> index a7b680df5b24..14e22310fbbf 100644
> --- a/scripts/Makefile.extrawarn
> +++ b/scripts/Makefile.extrawarn
> @@ -44,6 +44,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation-non-kprintf)
>  # the field is within a union with other non-const members, or the containing
>  # object is not const so the field can be modified via memcpy() / memset().
>  KBUILD_CFLAGS += $(call cc-disable-warning, default-const-init-field-unsafe)
> +KBUILD_CFLAGS += $(call cc-disable-warning, default-const-init-var-unsafe)
>  else
>  
>  # gcc inanely warns about local variables called 'main'
> -- 
> 2.49.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ