Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Bridges" <icb@fastmail.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/5] scsi: lpfc: Replace strlcat() with seq_buf in lpfc_info()
Date: Wed, 29 Jul 2026 14:59:41 +0000	[thread overview]
Message-ID: <20260729145941.69EC51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260729144617.1388646-2-icb@fastmail.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Unsafe lockless iteration over the `pdev->bus->devices` list causes use-after-free vulnerabilities.
--

--- Patch [1]: [PATCH 1/5] scsi: lpfc: Replace strlcat() with seq_buf in lpfc_info() ---
commit f8c11b7b237ed1d074a50074665c19f1c5567a78
Author: Ian Bridges <icb@fastmail.org>
Subject: scsi: lpfc: Replace strlcat() with seq_buf in lpfc_info()

This commit replaces strlcat() and intermediate buffers with the seq_buf API
in lpfc_info(). This simplifies string construction while maintaining memory
safety and silent truncation behavior.

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

> diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
> index f2cab134af7f1..8a795c65e3c3e 100644
> --- a/drivers/scsi/lpfc/lpfc_scsi.c
> +++ b/drivers/scsi/lpfc/lpfc_scsi.c
[ ... ]
> @@ -5103,57 +5104,37 @@ lpfc_info(struct Scsi_Host *host)
[ ... ]
>  		/* PCI resettable */
> -		if (!lpfc_check_pci_resettable(phba)) {
> -			scnprintf(tmp, sizeof(tmp), " PCI resettable");
> -			strlcat(lpfcinfobuf, tmp, sizeof(lpfcinfobuf));
> -		}
> +		if (!lpfc_check_pci_resettable(phba))

[Severity: High]
This isn't a bug introduced by this patch, but is it safe to call
lpfc_check_pci_resettable() without holding the pci_bus_sem read lock?

Looking at lpfc_check_pci_resettable() in drivers/scsi/lpfc/lpfc_scsi.c,
it iterates over the pdev->bus->devices list:

drivers/scsi/lpfc/lpfc_scsi.c:lpfc_check_pci_resettable() {
    ...
	/* Walk the list of devices on the pci_dev's bus */
	list_for_each_entry(ptr, &pdev->bus->devices, bus_list) {
		/* Check for Emulex Vendor ID */
    ...
}

If a concurrent PCI hot-remove operation occurs, could the bus_list pointers
be freed while list_for_each_entry is following the next pointer, leading
to a use-after-free?

> +			seq_buf_printf(&s, " PCI resettable");
>  	}
>  
> -buffer_done:
>  	return lpfcinfobuf;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260729144617.1388646-1-icb@fastmail.org?part=1

  reply	other threads:[~2026-07-29 14:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29 14:46 [PATCH 0/5] scsi: lpfc: Remove all strlcat() uses Ian Bridges
2026-07-29 14:46 ` [PATCH 1/5] scsi: lpfc: Replace strlcat() with seq_buf in lpfc_info() Ian Bridges
2026-07-29 14:59   ` sashiko-bot [this message]
2026-07-29 14:46 ` [PATCH 2/5] scsi: lpfc: Replace strlcat() with scnprintf() in lpfc_vport_symbolic_node_name() Ian Bridges
2026-07-29 15:09   ` sashiko-bot
2026-07-29 14:46 ` [PATCH 3/5] scsi: lpfc: Replace strlcat() with seq_buf in lpfc_rx_monitor_report() Ian Bridges
2026-07-29 14:46 ` [PATCH 4/5] scsi: lpfc: Replace strlcat() with seq_buf in the debugfs dump helpers Ian Bridges
2026-07-29 14:46 ` [PATCH 5/5] scsi: lpfc: Replace strlcat() with sysfs_emit_at() in the sysfs show functions Ian Bridges
2026-07-29 15:45   ` sashiko-bot

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=20260729145941.69EC51F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=icb@fastmail.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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