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: <208BFA1D-F3E9-4D9F-A4A1-4E4C3F4CA309@coly.li>
Date: Thu, 17 Apr 2025 21:11:39 +0800
From: Coly Li <i@...y.li>
To: Kees Cook <kees@...nel.org>
Cc: Ard Biesheuvel <ardb@...nel.org>,
 Coly Li <colyli@...nel.org>,
 Kent Overstreet <kent.overstreet@...ux.dev>,
 linux-bcache@...r.kernel.org,
 linux-kernel@...r.kernel.org,
 linux-hardening@...r.kernel.org
Subject: Re: [PATCH] md/bcache: Mark __nonstring look-up table



> 2025年4月17日 15:10,Kees Cook <kees@...nel.org> 写道:
> 
> 
> 
> On April 16, 2025 11:16:45 PM PDT, Ard Biesheuvel <ardb@...nel.org> wrote:
>> On Thu, 17 Apr 2025 at 00:01, Kees Cook <kees@...nel.org> wrote:
>>> 
>>> 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 to silence the GCC warning.
>>> 
>>> Signed-off-by: Kees Cook <kees@...nel.org>
>>> ---
>>> Cc: Coly Li <colyli@...nel.org>
>>> Cc: Kent Overstreet <kent.overstreet@...ux.dev>
>>> Cc: linux-bcache@...r.kernel.org
>>> ---
>>> drivers/md/bcache/super.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>> 
>>> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
>>> index e42f1400cea9..577d048170fe 100644
>>> --- a/drivers/md/bcache/super.c
>>> +++ b/drivers/md/bcache/super.c
>>> @@ -546,7 +546,7 @@ 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 = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
>>> 
>> 
>> Just
>> 
>> static const char zero_uuid[16] = {};
>> 
>> should work fine here too. No need for the initializer.
> 
> 🤦 Yes. This is what I get for fixing dozens of these. I'll send a v2...


Can we do this,

static const char zero_uuid[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};

I like the explicit array element number 16, and the explicit uuid content by obvious zero (‘0’) symbols. They provide redundant information.
Not sure whether GCC 15 complains or not.

Thanks.

Coly Li

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ