Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yehyeong Lee" <yhlee@isslab.korea.ac.kr>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v5 2/3] scsi: bfa: drop unsolicited frames shorter than the headers they must hold
Date: Fri, 16 Oct 2026 16:11:41 +0000	[thread overview]
Message-ID: <sashiko-outbox-174607@kernel.org> (raw)
In-Reply-To: <20261016155441.1607196-3-yhlee@isslab.korea.ac.kr>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: bfa: OOB read of ELS command code due to missing payload bounds check
--

commit 31f50cb105260d95a224555b9e6f894b5a59692b
Author: Yehyeong Lee <yhlee@isslab.korea.ac.kr>

scsi: bfa: drop unsolicited frames shorter than the headers they must hold

bfa_fcs_uf_recv() keeps the received frame length in a u16 and hands it,
with a pointer to the frame, to every unsolicited frame consumer. Two
lengths are never checked.

> diff --git a/drivers/scsi/bfa/bfa_fcs.c b/drivers/scsi/bfa/bfa_fcs.c
> index 9b57312f43f50..8bb92f935a40f 100644
> --- a/drivers/scsi/bfa/bfa_fcs.c
> +++ b/drivers/scsi/bfa/bfa_fcs.c
> @@ -1527,6 +1527,14 @@ bfa_fcs_uf_recv(void *cbarg, struct bfa_uf_s *uf)
>  	struct fc_vft_s *vft;
>  	struct bfa_fcs_fabric_s *fabric;
>  
> +	/*
> +	 * every consumer reads the FC header, so the frame has to hold one
> +	 */
> +	if (len < sizeof(struct fchs_s)) {
> +		bfa_uf_free(uf);
> +		return;
> +	}
> +

[Severity: High]
Does this check need to account for the payload length when processing ELS
commands?

If a remote device sends an unsolicited FC frame of exactly 24 bytes with
fchs->type == FC_TYPE_ELS, can this cause a regression where the driver reads
beyond the verified length?

For example, in drivers/scsi/bfa/bfa_fcs.c:bfa_fcs_fabric_uf_recv():

    struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
    ...
    if ((pid == bfa_ntoh3b(FC_FABRIC_PORT)) &&
        (els_cmd->els_code == FC_ELS_FLOGI) && ...

And similarly in drivers/scsi/bfa/bfa_fcs_lport.c:bfa_fcs_lport_uf_recv():

    struct fc_els_cmd_s *els_cmd = (struct fc_els_cmd_s *) (fchs + 1);
    ...
    if ((fchs->type == FC_TYPE_ELS) &&
        (els_cmd->els_code == FC_ELS_PLOGI)) {

Because the driver recycles DMA buffers without zeroing them, the hardware DMA
writes only 24 bytes, leaving the old payload intact in the buffer. Could the
driver read the stale els_code and process the stale payload as a new command?

Should there be an additional length verification before accessing
els_cmd->els_code?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261016155441.1607196-1-yhlee@isslab.korea.ac.kr?part=2

  reply	other threads:[~2026-10-16 16:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 15:54 [PATCH v5 0/3] scsi: bfa: bound the unsolicited frame receive path Yehyeong Lee
2026-10-16 15:54 ` [PATCH v5 1/3] scsi: bfa: clamp the received unsolicited frame length to the buffer Yehyeong Lee
2026-10-16 15:54 ` [PATCH v5 2/3] scsi: bfa: drop unsolicited frames shorter than the headers they must hold Yehyeong Lee
2026-10-16 16:11   ` sashiko-bot [this message]
2026-10-16 18:25   ` Yehyeong Lee
2026-10-16 15:54 ` [PATCH v5 3/3] scsi: bfa: bound the RSCN event list by the received frame length Yehyeong Lee

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=sashiko-outbox-174607@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=yhlee@isslab.korea.ac.kr \
    /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