From: Ian Rogers <irogers@google.com>
To: Nilesh Javali <njavali@marvell.com>,
GR-QLogic-Storage-Upstream@marvell.com,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, Elkin Cruz <elkin@google.com>,
Ian Rogers <irogers@google.com>
Subject: [PATCH] scsi: qla2xxx: Format SFP EEPROM vendor strings with %.*s
Date: Thu, 19 Nov 2026 09:05:11 -0800 [thread overview]
Message-ID: <20261119170511.1515433-1-irogers@google.com> (raw)
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
reply other threads:[~2026-11-19 17:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261119170511.1515433-1-irogers@google.com \
--to=irogers@google.com \
--cc=GR-QLogic-Storage-Upstream@marvell.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=elkin@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mkp@kernel.org \
--cc=njavali@marvell.com \
/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®