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: <kjxkqexdkyesepwtyjsp2uuo73r65msvhl7ccxt77wv722gw3j@7ekim6v5clrh>
Date: Mon, 14 Apr 2025 21:54:52 +0530
From: Brahmajit <brahmajit.xyz@...il.com>
To: Robert Moore <robert.moore@...el.com>, 
	"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>, Len Brown <lenb@...nel.org>, linux-acpi@...r.kernel.org, 
	acpica-devel@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] ACPI: Fix building with GCC 15

On 14.04.2025 21:46, Brahmajit Das wrote:
> Since the Linux kernel initializes many non-C-string char arrays with
> literals. While it would be possible to convert initializers from:
>    { "BOOP", ... }
> to something like:
>    { { 'B', 'O', 'O', 'P' }, ... }
> that is annoying.
> Making -Wunterminated-string-initialization stay silent about char
> arrays marked with nonstring would be much better.
> 
> Without the __attribute__((nonstring)) we would get the following build
> error:
> 
> ...
> drivers/acpi/acpica/acpredef.h:903:11: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
>   903 |         {{"_S3D", METHOD_0ARGS,
>       |           ^~~~~~
> drivers/acpi/acpica/acpredef.h:906:11: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
>   906 |         {{"_S4D", METHOD_0ARGS,
>       |           ^~~~~~
> 
> and,
> 
> ...
> drivers/acpi/acpica/nsrepair2.c:115:10: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
>   115 |         {"_ALR", acpi_ns_repair_ALR},
>       |          ^~~~~~
> drivers/acpi/acpica/nsrepair2.c:116:10: error: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (5 chars into 4 available) [-Werror=unterminated-string-initialization]
>   116 |         {"_CID", acpi_ns_repair_CID},
> ...
> 
> Upstream GCC has added this commit
> 622968990beee7499e951590258363545b4a3b57[0][1] which silences warning
> about truncating NUL char when initializing nonstring arrays.
> 
> [0]: https://gcc.gnu.org/cgit/gcc/commit/?id=622968990beee7499e951590258363545b4a3b57
> [1]: https://gcc.gnu.org/cgit/gcc/commit/?id=afb46540d3921e96c4cd7ba8fa2c8b0901759455
> 
> Thanks to Jakub Jelinek <jakub@....gnu.org> for the gcc patch.
> 
> Signed-off-by: Brahmajit Das <listout@...tout.xyz>
> ---
>  drivers/acpi/acpica/aclocal.h   |  4 ++--
>  drivers/acpi/acpica/nsrepair2.c |  2 +-
>  drivers/acpi/tables.c           | 28 +++++++++++++++-------------
>  include/acpi/actbl.h            |  3 ++-
>  4 files changed, 20 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/acpi/acpica/aclocal.h b/drivers/acpi/acpica/aclocal.h
> index 6f4fe47c955b..d2cda1b35e59 100644
> --- a/drivers/acpi/acpica/aclocal.h
> +++ b/drivers/acpi/acpica/aclocal.h
> @@ -293,7 +293,7 @@ acpi_status (*acpi_internal_method) (struct acpi_walk_state * walk_state);
>   * expected_return_btypes - Allowed type(s) for the return value
>   */
>  struct acpi_name_info {
> -	char name[ACPI_NAMESEG_SIZE];
> +	char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
>  	u16 argument_list;
>  	u8 expected_btypes;
>  };
> @@ -370,7 +370,7 @@ typedef acpi_status (*acpi_object_converter) (struct acpi_namespace_node *
>  					      converted_object);
>  
>  struct acpi_simple_repair_info {
> -	char name[ACPI_NAMESEG_SIZE];
> +	char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
>  	u32 unexpected_btypes;
>  	u32 package_index;
>  	acpi_object_converter object_converter;
> diff --git a/drivers/acpi/acpica/nsrepair2.c b/drivers/acpi/acpica/nsrepair2.c
> index 1bb7b71f07f1..a28b1fa2b1ea 100644
> --- a/drivers/acpi/acpica/nsrepair2.c
> +++ b/drivers/acpi/acpica/nsrepair2.c
> @@ -25,7 +25,7 @@ acpi_status (*acpi_repair_function) (struct acpi_evaluate_info * info,
>  				     return_object_ptr);
>  
>  typedef struct acpi_repair_info {
> -	char name[ACPI_NAMESEG_SIZE];
> +	char name[ACPI_NAMESEG_SIZE] __attribute__((nonstring));
>  	acpi_repair_function repair_function;
>  
>  } acpi_repair_info;
> diff --git a/drivers/acpi/tables.c b/drivers/acpi/tables.c
> index 2295abbecd14..27104cbb48b5 100644
> --- a/drivers/acpi/tables.c
> +++ b/drivers/acpi/tables.c
> @@ -396,19 +396,21 @@ static u8 __init acpi_table_checksum(u8 *buffer, u32 length)
>  }
>  
>  /* All but ACPI_SIG_RSDP and ACPI_SIG_FACS: */
> -static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst = {
> -	ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT,
> -	ACPI_SIG_EINJ, ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT,
> -	ACPI_SIG_MSCT, ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT,
> -	ACPI_SIG_ASF,  ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR,
> -	ACPI_SIG_HPET, ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG,
> -	ACPI_SIG_MCHI, ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI,
> -	ACPI_SIG_TCPA, ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT,
> -	ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
> -	ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
> -	ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
> -	ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI,
> -	ACPI_SIG_NBFT };
> +static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst
> +	__attribute__((nonstring)) = {
> +		ACPI_SIG_BERT, ACPI_SIG_BGRT, ACPI_SIG_CPEP, ACPI_SIG_ECDT,
> +		ACPI_SIG_EINJ, ACPI_SIG_ERST, ACPI_SIG_HEST, ACPI_SIG_MADT,
> +		ACPI_SIG_MSCT, ACPI_SIG_SBST, ACPI_SIG_SLIT, ACPI_SIG_SRAT,
> +		ACPI_SIG_ASF,  ACPI_SIG_BOOT, ACPI_SIG_DBGP, ACPI_SIG_DMAR,
> +		ACPI_SIG_HPET, ACPI_SIG_IBFT, ACPI_SIG_IVRS, ACPI_SIG_MCFG,
> +		ACPI_SIG_MCHI, ACPI_SIG_SLIC, ACPI_SIG_SPCR, ACPI_SIG_SPMI,
> +		ACPI_SIG_TCPA, ACPI_SIG_UEFI, ACPI_SIG_WAET, ACPI_SIG_WDAT,
> +		ACPI_SIG_WDDT, ACPI_SIG_WDRT, ACPI_SIG_DSDT, ACPI_SIG_FADT,
> +		ACPI_SIG_PSDT, ACPI_SIG_RSDT, ACPI_SIG_XSDT, ACPI_SIG_SSDT,
> +		ACPI_SIG_IORT, ACPI_SIG_NFIT, ACPI_SIG_HMAT, ACPI_SIG_PPTT,
> +		ACPI_SIG_NHLT, ACPI_SIG_AEST, ACPI_SIG_CEDT, ACPI_SIG_AGDI,
> +		ACPI_SIG_NBFT
> +	};
>  
>  #define ACPI_HEADER_SIZE sizeof(struct acpi_table_header)
>  
> diff --git a/include/acpi/actbl.h b/include/acpi/actbl.h
> index 451f6276da49..88ba1b978053 100644
> --- a/include/acpi/actbl.h
> +++ b/include/acpi/actbl.h
> @@ -66,7 +66,8 @@
>   ******************************************************************************/
>  
>  struct acpi_table_header {
> -	char signature[ACPI_NAMESEG_SIZE];	/* ASCII table signature */
> +	char signature[ACPI_NAMESEG_SIZE]
> +		__attribute__((nonstring)); /* ASCII table signature */
>  	u32 length;		/* Length of table in bytes, including this header */
>  	u8 revision;		/* ACPI Specification minor version number */
>  	u8 checksum;		/* To make sum of entire table == 0 */
> -- 
> 2.49.0
> 

Do I need to send the acpica part to GitHub first?

-- 
Regards,
listout

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ