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
| ||
|
Message-ID: <20250318130811.GQ688833@kernel.org> Date: Tue, 18 Mar 2025 13:08:11 +0000 From: Simon Horman <horms@...nel.org> To: Kees Cook <kees@...nel.org> Cc: "Jason A . Donenfeld" <Jason@...c4.com>, Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, wireguard@...ts.zx2c4.com, netdev@...r.kernel.org, linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org Subject: Re: [PATCH v2] wireguard: Add __nonstring annotations for unterminated strings On Wed, Mar 12, 2025 at 01:14:51PM -0700, Kees Cook wrote: > When a character array without a terminating NUL character has a static > initializer, GCC 15's -Wunterminated-string-initialization will only > warn if the array lacks the "nonstring" attribute[1]. Mark the arrays > with __nonstring to correctly identify the char array as "not a C string" > and thereby eliminate the warning: > > ../drivers/net/wireguard/cookie.c:29:56: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 chars into 8 available) [-Wunterminated-string-initialization] > 29 | static const u8 mac1_key_label[COOKIE_KEY_LABEL_LEN] = "mac1----"; > | ^~~~~~~~~~ > ../drivers/net/wireguard/cookie.c:30:58: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (9 chars into 8 available) [-Wunterminated-string-initialization] > 30 | static const u8 cookie_key_label[COOKIE_KEY_LABEL_LEN] = "cookie--"; > | ^~~~~~~~~~ > ../drivers/net/wireguard/noise.c:28:38: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (38 chars into 37 available) [-Wunterminated-string-initialization] > 28 | static const u8 handshake_name[37] = "Noise_IKpsk2_25519_ChaChaPoly_BLAKE2s"; > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../drivers/net/wireguard/noise.c:29:39: warning: initializer-string for array of 'unsigned char' truncates NUL terminator but destination lacks 'nonstring' attribute (35 chars into 34 available) [-Wunterminated-string-initialization] > 29 | static const u8 identifier_name[34] = "WireGuard v1 zx2c4 Jason@...c4.com"; > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The arrays are always used with their fixed size, so use __nonstring. > > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117178 [1] > Signed-off-by: Kees Cook <kees@...nel.org> > --- > v2: Improve commit log, add cookie nonstrings too > v1: https://lore.kernel.org/lkml/20250310222249.work.154-kees@kernel.org/ Reviewed-by: Simon Horman <horms@...nel.org>
Powered by blists - more mailing lists