[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <389A9925-0990-422C-A1B3-0195FAA73288@coly.li>
Date: Sat, 19 Apr 2025 11:55:10 +0800
From: Coly Li <i@...y.li>
To: Kees Cook <kees@...nel.org>
Cc: Coly Li <colyli@...nel.org>,
Kent Overstreet <kent.overstreet@...ux.dev>,
Ard Biesheuvel <ardb@...nel.org>,
linux-bcache@...r.kernel.org,
linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org
Subject: Re: [PATCH v2] md/bcache: Mark __nonstring look-up table
> 2025年4月19日 04:21,Kees Cook <kees@...nel.org> 写道:
>
> GCC 15's new -Wunterminated-string-initialization notices that the 16
> character lookup table "zero_uuid" (which is not used as a C-String)
> needs to be marked as "nonstring":
>
> drivers/md/bcache/super.c: In function 'uuid_find_empty':
> drivers/md/bcache/super.c:549:43: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16 available) [-Wunterminated-string-initialization]
> 549 | static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Add the annotation (since it is not used as a C-String), and switch the
> initializer to an array of bytes.
>
> Signed-off-by: Kees Cook <kees@...nel.org>
> ---
> v2: use byte array initializer (colyli)
> v1: https://lore.kernel.org/all/20250416220135.work.394-kees@kernel.org/
> Cc: Coly Li <colyli@...nel.org>
> Cc: Kent Overstreet <kent.overstreet@...ux.dev>
> Cc: Ard Biesheuvel <ardb@...nel.org>
> Cc: linux-bcache@...r.kernel.org
> ---
> drivers/md/bcache/super.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index e42f1400cea9..a76ce92502ed 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -546,7 +546,8 @@ static struct uuid_entry *uuid_find(struct cache_set *c, const char *uuid)
>
> static struct uuid_entry *uuid_find_empty(struct cache_set *c)
> {
> - static const char zero_uuid[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
> + static const char zero_uuid[] __nonstring =
I notice zero_uuid[16] changes to zero_uuid[], then the element number information is removed.
Is it OK for GCC 15 to only add __nonstring and keep zero_uuid[16]?
Thanks.
Coly Li
> + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
>
> return uuid_find(c, zero_uuid);
> }
> --
> 2.34.1
>
>
Powered by blists - more mailing lists