lib/crypto: Annotate crypto strings with nonstring
authorKees Cook <kees@kernel.org>
Thu, 29 May 2025 17:31:17 +0000 (10:31 -0700)
committerEric Biggers <ebiggers@google.com>
Mon, 16 Jun 2025 01:14:49 +0000 (18:14 -0700)
commite202196b8aa249d78ab87eae56bbe0e71e3dc39c
tree78197503f6b3ad63cdfb91692a3cf4e425ca29a4
parent19272b37aa4f83ca52bdf9c16d5d81bdd1354494
lib/crypto: Annotate crypto strings with nonstring

Annotate various keys, ivs, and other byte arrays with __nonstring so
that static initializers will not complain about truncating the trailing
NUL byte under GCC 15 with -Wunterminated-string-initialization enabled.
Silences many warnings like:

../lib/crypto/aesgcm.c:642:27: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (13 chars into 12 available) [-Wunterminated-string-initialization]
  642 |                 .iv     = "\xca\xfe\xba\xbe\xfa\xce\xdb\xad"
      |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Kees Cook <kees@kernel.org>
Link: https://lore.kernel.org/r/20250529173113.work.760-kees@kernel.org
Signed-off-by: Eric Biggers <ebiggers@google.com>
lib/crypto/aescfb.c
lib/crypto/aesgcm.c