* [PATCH] scsi: qla2xxx: Format SFP EEPROM vendor strings with %.*s
@ 2026-11-19 17:05 Ian Rogers
0 siblings, 0 replies; only message in thread
From: Ian Rogers @ 2026-11-19 17:05 UTC (permalink / raw)
To: Nilesh Javali, GR-QLogic-Storage-Upstream, James E.J. Bottomley,
Martin K. Petersen
Cc: linux-scsi, linux-kernel, llvm, Elkin Cruz, Ian Rogers
In qla2xxx_print_sfp_info(), the verbose logging path passes the 16-byte
SFF-8472 transceiver EEPROM fields a0->vendor_name and a0->vendor_pn
directly as the format string argument to snprintf(). Per SFF-8472, these
ASCII fields are space-padded rather than NUL-terminated, and their bytes
originate from pluggable SFP optics over I2C; any '%' byte in EEPROM data
or a corrupted I2C read is interpreted as a printf format specifier with
no variadic arguments supplied.
Format a0->vendor_name and a0->vendor_pn directly in ql_dbg() using "%.*s"
bounded by sizeof(), matching the non-verbose ql_dbg() call immediately
above in the same function.
Found via an x86_64 LLVM=1 (Clang 21.1.8) allyesconfig audit with
-Wformat-security enabled; fix and changelog drafted with an AI coding
assistant. Build-tested under LLVM=1 W=1 and -Wformat-security; not tested
on QLogic Fibre Channel hardware.
Fixes: e4e3a2ce9556 ("scsi: qla2xxx: Add ability to autodetect SFP type")
Signed-off-by: Ian Rogers <irogers@google.com>
---
drivers/scsi/qla2xxx/qla_init.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index ccb039d97353..77504cfc0741 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -4126,15 +4126,13 @@ static void qla2xxx_print_sfp_info(struct scsi_qla_host *vha)
if (!(ql2xextended_error_logging & ql_dbg_verbose))
return;
- memset(str, 0, STR_LEN);
- snprintf(str, SFF_VEN_NAME_LEN+1, a0->vendor_name);
ql_dbg(ql_dbg_init, vha, 0x015a,
- "SFP MFG Name: %s\n", str);
+ "SFP MFG Name: %.*s\n",
+ (int)sizeof(a0->vendor_name), a0->vendor_name);
- memset(str, 0, STR_LEN);
- snprintf(str, SFF_PART_NAME_LEN+1, a0->vendor_pn);
ql_dbg(ql_dbg_init, vha, 0x015c,
- "SFP Part Name: %s\n", str);
+ "SFP Part Name: %.*s\n",
+ (int)sizeof(a0->vendor_pn), a0->vendor_pn);
/* media */
memset(str, 0, STR_LEN);
--
2.56.1.708.g77570a6a1d-goog
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-19 17:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 17:05 [PATCH] scsi: qla2xxx: Format SFP EEPROM vendor strings with %.*s Ian Rogers
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®