Skip to content

Commit f53a6a2

Browse files
committed
emulex/benet: Annotate flash_cookie as nonstring
JIRA: https://issues.redhat.com/browse/RHEL-72657 commit f0f149d Author: Kees Cook <kees@kernel.org> Date: Wed Apr 16 15:10:29 2025 -0700 emulex/benet: Annotate flash_cookie as nonstring GCC 15's new -Wunterminated-string-initialization notices that the 32 character "flash_cookie" (which is not used as a C-String) needs to be marked as "nonstring": drivers/net/ethernet/emulex/benet/be_cmds.c:2618:51: warning: initializer-string for array of 'char' truncates NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16 available) [-Wunterminated-string-initialization] 2618 | static char flash_cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "}; | ^~~~~~~~~~~~~~~~~~ Add this annotation, avoid using a multidimensional array, but keep the string split (with a comment about why). Additionally mark it const and annotate the "cookie" member that is being memcmp()ed against as nonstring too. Signed-off-by: Kees Cook <kees@kernel.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250416221028.work.967-kees@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Dennis Chen <dechen@redhat.com>
1 parent 6c17800 commit f53a6a2

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

drivers/net/ethernet/emulex/benet/be_cmds.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2615,7 +2615,11 @@ static int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
26152615
return status;
26162616
}
26172617

2618-
static char flash_cookie[2][16] = {"*** SE FLAS", "H DIRECTORY *** "};
2618+
/*
2619+
* Since the cookie is text, add a parsing-skipped space to keep it from
2620+
* ever being matched on storage holding this source file.
2621+
*/
2622+
static const char flash_cookie[32] __nonstring = "*** SE FLAS" "H DIRECTORY *** ";
26192623

26202624
static bool phy_flashing_required(struct be_adapter *adapter)
26212625
{

drivers/net/ethernet/emulex/benet/be_cmds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ struct flash_section_entry {
14151415
} __packed;
14161416

14171417
struct flash_section_info {
1418-
u8 cookie[32];
1418+
u8 cookie[32] __nonstring;
14191419
struct flash_section_hdr fsec_hdr;
14201420
struct flash_section_entry fsec_entry[32];
14211421
} __packed;

0 commit comments

Comments
 (0)