mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/2] scsi: bfa: Replace strlcat() in symbolic name construction
@ 2026-09-28  9:00 Mariia Nikitash
  2026-09-28  9:00 ` [PATCH v2 1/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init() Mariia Nikitash
  2026-09-28  9:00 ` [PATCH v2 2/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init() Mariia Nikitash
  0 siblings, 2 replies; 5+ messages in thread
From: Mariia Nikitash @ 2026-09-28  9:00 UTC (permalink / raw)
  To: anil.gurumurthy, sudarsana.kalluru, James.Bottomley, mkp
  Cc: linux-scsi, linux-kernel, linux-hardening, morbo, kees,
	justinstitt, codemender-patching+linux, Mariia Nikitash

This series replaces the strlcat() uses in BFA symbolic name
construction with snprintf().

Patch 1 converts bfa_fcs_fabric_nsymb_init().
Patch 2 converts bfa_fcs_fabric_psymb_init().

---

Changes since v1:
- Split the BFA changes out of the original cross-subsystem series.
- Patch 1: no code changes.
- Patch 2: use a single snprintf() call for both host_os_patch cases
  and drop the explicit final NUL assignment.

Original series:
https://lore.kernel.org/all/20260915081910.4142719-1-morbo@google.com/

Original bfa_fcs_fabric_psymb_init() patch:
https://lore.kernel.org/all/20260915081910.4142719-8-morbo@google.com/

Bill Wendling (2):
  scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init()
  scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init()

 drivers/scsi/bfa/bfa_fcs.c | 88 ++++++++------------------------------
 1 file changed, 17 insertions(+), 71 deletions(-)

-- 
2.43.0

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init()
  2026-09-28  9:00 [PATCH v2 0/2] scsi: bfa: Replace strlcat() in symbolic name construction Mariia Nikitash
@ 2026-09-28  9:00 ` Mariia Nikitash
  2026-09-28 17:36   ` Bart Van Assche
  2026-09-28  9:00 ` [PATCH v2 2/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init() Mariia Nikitash
  1 sibling, 1 reply; 5+ messages in thread
From: Mariia Nikitash @ 2026-09-28  9:00 UTC (permalink / raw)
  To: anil.gurumurthy, sudarsana.kalluru, James.Bottomley, mkp
  Cc: linux-scsi, linux-kernel, linux-hardening, morbo, kees,
	justinstitt, codemender-patching+linux, Mariia Nikitash

From: Bill Wendling <morbo@google.com>

bfa_fcs_fabric_nsymb_init() constructs the node symbolic name using
strscpy() followed by five strlcat() calls and explicit NUL-termination.

In preparation for removing the deprecated strlcat() API[1], replace the
chained string copies with a single snprintf() call.

Link: https://github.com/KSPP/linux/issues/370 [1]
Cc: codemender-patching+linux@google.com
Assisted-by: LLM
Signed-off-by: Bill Wendling <morbo@google.com>
Signed-off-by: Mariia Nikitash <nikitash.mariiaw@gmail.com>
---
 drivers/scsi/bfa/bfa_fcs.c | 31 +++++++------------------------
 1 file changed, 7 insertions(+), 24 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
index 9b57312f43f5..7a4e0e8c7182 100644
--- a/drivers/scsi/bfa/bfa_fcs.c
+++ b/drivers/scsi/bfa/bfa_fcs.c
@@ -821,30 +821,13 @@ bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric)
 
 	bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
 
-	/* Model name/number */
-	strscpy(port_cfg->node_sym_name.symname, model,
-		BFA_SYMNAME_MAXLEN);
-	strlcat(port_cfg->node_sym_name.symname,
-			BFA_FCS_PORT_SYMBNAME_SEPARATOR,
-			BFA_SYMNAME_MAXLEN);
-
-	/* Driver Version */
-	strlcat(port_cfg->node_sym_name.symname, (char *)driver_info->version,
-		BFA_SYMNAME_MAXLEN);
-	strlcat(port_cfg->node_sym_name.symname,
-			BFA_FCS_PORT_SYMBNAME_SEPARATOR,
-			BFA_SYMNAME_MAXLEN);
-
-	/* Host machine name */
-	strlcat(port_cfg->node_sym_name.symname,
-		driver_info->host_machine_name,
-		BFA_SYMNAME_MAXLEN);
-	strlcat(port_cfg->node_sym_name.symname,
-			BFA_FCS_PORT_SYMBNAME_SEPARATOR,
-			BFA_SYMNAME_MAXLEN);
-
-	/* null terminate */
-	port_cfg->node_sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
+	/* Model name/number, Driver Version, Host machine name */
+	snprintf(port_cfg->node_sym_name.symname, BFA_SYMNAME_MAXLEN,
+		 "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR
+		 "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR
+		 "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR,
+		 model, (char *)driver_info->version,
+		 driver_info->host_machine_name);
 }
 
 /*
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 2/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init()
  2026-09-28  9:00 [PATCH v2 0/2] scsi: bfa: Replace strlcat() in symbolic name construction Mariia Nikitash
  2026-09-28  9:00 ` [PATCH v2 1/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init() Mariia Nikitash
@ 2026-09-28  9:00 ` Mariia Nikitash
  2026-09-28 17:38   ` Bart Van Assche
  1 sibling, 1 reply; 5+ messages in thread
From: Mariia Nikitash @ 2026-09-28  9:00 UTC (permalink / raw)
  To: anil.gurumurthy, sudarsana.kalluru, James.Bottomley, mkp
  Cc: linux-scsi, linux-kernel, linux-hardening, morbo, kees,
	justinstitt, codemender-patching+linux, Mariia Nikitash

From: Bill Wendling <morbo@google.com>

Similar to bfa_fcs_fabric_nsymb_init(), bfa_fcs_fabric_psymb_init()
builds the port symbolic name using strscpy() and a chain of seven or
eight strlcat() calls.

In preparation for removing the deprecated strlcat() API[1], replace the
chained strscpy() and strlcat() calls with a single snprintf() call.

An empty host_os_patch naturally contributes no characters through %s,
allowing both cases to be handled by the same snprintf() call. Since
snprintf() also NUL-terminates the destination, the explicit final NUL
assignment can be dropped.

Link: https://github.com/KSPP/linux/issues/370 [1]
Cc: codemender-patching+linux@google.com
Assisted-by: LLM
Signed-off-by: Bill Wendling <morbo@google.com>
Signed-off-by: Mariia Nikitash <nikitash.mariiaw@gmail.com>
---
 drivers/scsi/bfa/bfa_fcs.c | 57 +++++++-------------------------------
 1 file changed, 10 insertions(+), 47 deletions(-)

diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
index 7a4e0e8c7182..3e5d3a141f32 100644
--- a/drivers/scsi/bfa/bfa_fcs.c
+++ b/drivers/scsi/bfa/bfa_fcs.c
@@ -760,53 +760,16 @@ bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric)
 
 	bfa_ioc_get_adapter_model(&fabric->fcs->bfa->ioc, model);
 
-	/* Model name/number */
-	strscpy(port_cfg->sym_name.symname, model,
-		BFA_SYMNAME_MAXLEN);
-	strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
-		BFA_SYMNAME_MAXLEN);
-
-	/* Driver Version */
-	strlcat(port_cfg->sym_name.symname, driver_info->version,
-		BFA_SYMNAME_MAXLEN);
-	strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
-		BFA_SYMNAME_MAXLEN);
-
-	/* Host machine name */
-	strlcat(port_cfg->sym_name.symname,
-		driver_info->host_machine_name,
-		BFA_SYMNAME_MAXLEN);
-	strlcat(port_cfg->sym_name.symname, BFA_FCS_PORT_SYMBNAME_SEPARATOR,
-		BFA_SYMNAME_MAXLEN);
-
-	/*
-	 * Host OS Info :
-	 * If OS Patch Info is not there, do not truncate any bytes from the
-	 * OS name string and instead copy the entire OS info string (64 bytes).
-	 */
-	if (driver_info->host_os_patch[0] == '\0') {
-		strlcat(port_cfg->sym_name.symname,
-			driver_info->host_os_name,
-			BFA_SYMNAME_MAXLEN);
-		strlcat(port_cfg->sym_name.symname,
-			BFA_FCS_PORT_SYMBNAME_SEPARATOR,
-			BFA_SYMNAME_MAXLEN);
-	} else {
-		strlcat(port_cfg->sym_name.symname,
-			driver_info->host_os_name,
-			BFA_SYMNAME_MAXLEN);
-		strlcat(port_cfg->sym_name.symname,
-			BFA_FCS_PORT_SYMBNAME_SEPARATOR,
-			BFA_SYMNAME_MAXLEN);
-
-		/* Append host OS Patch Info */
-		strlcat(port_cfg->sym_name.symname,
-			driver_info->host_os_patch,
-			BFA_SYMNAME_MAXLEN);
-	}
-
-	/* null terminate */
-	port_cfg->sym_name.symname[BFA_SYMNAME_MAXLEN - 1] = 0;
+	snprintf(port_cfg->sym_name.symname, BFA_SYMNAME_MAXLEN,
+		 "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR
+		 "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR
+		 "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR
+		 "%s" BFA_FCS_PORT_SYMBNAME_SEPARATOR
+		 "%s",
+		 model, driver_info->version,
+		 driver_info->host_machine_name,
+		 driver_info->host_os_name,
+		 driver_info->host_os_patch);
 }
 
 /*
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 1/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init()
  2026-09-28  9:00 ` [PATCH v2 1/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init() Mariia Nikitash
@ 2026-09-28 17:36   ` Bart Van Assche
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2026-09-28 17:36 UTC (permalink / raw)
  To: Mariia Nikitash, anil.gurumurthy, sudarsana.kalluru,
	James.Bottomley, mkp
  Cc: linux-scsi, linux-kernel, linux-hardening, morbo, kees,
	justinstitt, codemender-patching+linux

On 9/28/26 2:00 AM, Mariia Nikitash wrote:
> In preparation for removing the deprecated strlcat() API[1], replace the
> chained string copies with a single snprintf() call.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 2/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init()
  2026-09-28  9:00 ` [PATCH v2 2/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init() Mariia Nikitash
@ 2026-09-28 17:38   ` Bart Van Assche
  0 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2026-09-28 17:38 UTC (permalink / raw)
  To: Mariia Nikitash, anil.gurumurthy, sudarsana.kalluru,
	James.Bottomley, mkp
  Cc: linux-scsi, linux-kernel, linux-hardening, morbo, kees,
	justinstitt, codemender-patching+linux

On 9/28/26 2:00 AM, Mariia Nikitash wrote:
> In preparation for removing the deprecated strlcat() API[1], replace the
> chained strscpy() and strlcat() calls with a single snprintf() call.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-09-28 17:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28  9:00 [PATCH v2 0/2] scsi: bfa: Replace strlcat() in symbolic name construction Mariia Nikitash
2026-09-28  9:00 ` [PATCH v2 1/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init() Mariia Nikitash
2026-09-28 17:36   ` Bart Van Assche
2026-09-28  9:00 ` [PATCH v2 2/2] scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init() Mariia Nikitash
2026-09-28 17:38   ` Bart Van Assche

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®