mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Coly Li <colyli@kernel.org>,
	Kent Overstreet <kent.overstreet@linux.dev>,
	linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH] md/bcache: Mark __nonstring look-up table
Date: Thu, 17 Apr 2025 00:10:53 -0700	[thread overview]
Message-ID: <994E520B-64B1-4387-8DFF-88755346FE55@kernel.org> (raw)
In-Reply-To: <CAMj1kXHfearSZG6TFTxxX87qmRkUmAefQm-TfPNS8j09kWxujQ@mail.gmail.com>



On April 16, 2025 11:16:45 PM PDT, Ard Biesheuvel <ardb@kernel.org> wrote:
>On Thu, 17 Apr 2025 at 00:01, Kees Cook <kees@kernel.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@kernel.org>
>> ---
>> Cc: Coly Li <colyli@kernel.org>
>> Cc: Kent Overstreet <kent.overstreet@linux.dev>
>> Cc: linux-bcache@vger.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...

-Kees


-- 
Kees Cook

  reply	other threads:[~2025-04-17  7:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 22:01 Kees Cook
2025-04-17  4:13 ` Coly Li
2025-04-17  6:16 ` Ard Biesheuvel
2025-04-17  7:10   ` Kees Cook [this message]
2025-04-17 13:11     ` Coly Li
2025-04-17 14:08       ` Ard Biesheuvel
2025-04-17 14:17         ` Coly Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=994E520B-64B1-4387-8DFF-88755346FE55@kernel.org \
    --to=kees@kernel.org \
    --cc=ardb@kernel.org \
    --cc=colyli@kernel.org \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-bcache@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®