[PATCH 0/5] scsi: lpfc: Remove all strlcat() uses

From: Ian Bridges

Date: Wed Jul 29 2026 - 11:23:13 EST


In preparation for removing the strlcat() API[1], this series replaces
its 81 remaining call sites in the lpfc driver. The sites live in nine
string building functions across five files, and each patch converts
one source file.

Functions that accumulate a variable number of fragments move to
seq_buf. The three sysfs show functions move to sysfs_emit_at(), the
designated helper for sysfs output. lpfc_vport_symbolic_node_name()
builds five fixed fragments and becomes a single scnprintf() call.
The intermediate tmp buffers and the per fragment overflow checks
become unnecessary in every scheme. Each loop that appends keeps one
overflow exit, so a full buffer stops the iteration.

One cross-cutting behavior change applies to several patches. The old
code formatted each fragment into a fixed size tmp buffer before
appending it, so a fragment longer than that buffer was silently
truncated even when the destination had room for it. The replacements
format each fragment directly into the destination. Truncation is
still bounded by the destination size. The per patch changelogs call
out the affected functions.

The patch series was tested as follows. No hardware testing was
done. Testing on real adapters is welcome.

- W=1 builds of the whole driver directory, zero warnings.
- A userspace differential harness. The old and new function bodies
are extracted verbatim from the two trees and compiled side by side
against the real lib/seq_buf.c. 472000 randomized cases across all
nine functions, including oversized inputs, undersized buffers and
prefilled destinations, compared byte for byte under ASan and
UBSan. All outputs are identical except two behavior changes.
Those are the format string interpretation removed in patch 1 and
the fragment cap removal in patch 2. The harness classifies every
observed difference as exactly one of those two.
- A KUnit corpus. The nine functions run as compiled kernel code in a
QEMU guest with KASAN, UBSAN and FORTIFY_SOURCE enabled, against
fabricated adapter state covering both branches of every converted
conditional that is compiled in. The LPFC_MXP_STAT debug block is
disabled at compile time and was build tested with the macro
defined. The same 40 test cases run on the unpatched base and
on this series. The base run matches the old expected outputs, and
the patched run is byte identical everywhere except the two
documented changes.

[1] https://github.com/KSPP/linux/issues/370

Ian Bridges (5):
scsi: lpfc: Replace strlcat() with seq_buf in lpfc_info()
scsi: lpfc: Replace strlcat() with scnprintf() in
lpfc_vport_symbolic_node_name()
scsi: lpfc: Replace strlcat() with seq_buf in lpfc_rx_monitor_report()
scsi: lpfc: Replace strlcat() with seq_buf in the debugfs dump helpers
scsi: lpfc: Replace strlcat() with sysfs_emit_at() in the sysfs show
functions

drivers/scsi/lpfc/lpfc_attr.c | 555 +++++++++++++------------------
drivers/scsi/lpfc/lpfc_ct.c | 29 +-
drivers/scsi/lpfc/lpfc_debugfs.c | 202 +++++------
drivers/scsi/lpfc/lpfc_scsi.c | 49 +--
drivers/scsi/lpfc/lpfc_scsi.h | 3 -
drivers/scsi/lpfc/lpfc_sli.c | 43 +--
6 files changed, 361 insertions(+), 520 deletions(-)

--
2.47.3