Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: ghuicao@163.com
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: qla2xxx: Fix buffer overrun in login template
Date: Fri, 07 Aug 2026 09:47:51 +0000	[thread overview]
Message-ID: <20260807094752.2EF2D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807093429.102604-1-ghuicao@163.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The fix for the buffer overrun shifts the PLOGI payload by 4 bytes, corrupting the Fibre Channel Service Parameters and breaking connection establishment.
--

--- Patch [1]: [PATCH] scsi: qla2xxx: Fix buffer overrun in login template ---
commit a554cfebac5525fe6bc8fe781ea87856585aeee0
Author: Cao Guanghui <caoguanghui@kylinos.cn>

scsi: qla2xxx: Fix buffer overrun in login template

This patch aims to fix a buffer overrun by changing the destination
pointer for the PLOGI ELS payload copy from the fl_csp field (offset 4)
to the start of the fc_els_flogi structure (offset 0).

> diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
> index e746c9274cded..7e50cff79b5c6 100644
> --- a/drivers/scsi/qla2xxx/qla_init.c
> +++ b/drivers/scsi/qla2xxx/qla_init.c
> @@ -5666,7 +5666,7 @@ static void qla_get_login_template(scsi_qla_host_t *vha)
>  		       "PLOGI ELS param read fail.\n");
>  		return;
>  	}
> -	q = (__be32 *)&ha->plogi_els_payld.fl_csp;
> +	q = (__be32 *)&ha->plogi_els_payld;

[Severity: High]
Does this change shift the firmware's payload backwards by 4 bytes
relative to the struct fields?

The commit message indicates moving the pointer to the start of the
struct does not affect any reader. However, looking at the consumers of
this data, they explicitly expect the firmware payload to align at
offsetof(fl_csp).

For example, in qla24xx_els_dcmd2_iocb() the driver copies the data like
this:

drivers/scsi/qla2xxx/qla_iocb.c:qla24xx_els_dcmd2_iocb()
    memcpy(elsio->u.els_plogi.els_plogi_pyld->data,
           (void *)&ha->plogi_els_payld + offsetof(struct fc_els_flogi, fl_csp),
           sizeof(ha->plogi_els_payld) - offsetof(struct fc_els_flogi, fl_csp));

Similarly, qla24xx_process_purex_rdp() reads sp_bb_cred from within fl_csp:

drivers/scsi/qla2xxx/qla_os.c:qla24xx_process_purex_rdp()
    be16_to_cpu(ha->plogi_els_payld.fl_csp.sp_bb_cred);

If the firmware payload consists purely of the Service Parameters without
a 4-byte ELS header, pointing q to the start of the structure will write
the parameters into the fl_cmd field.

Would this cause consumers reading from offsetof(fl_csp) to skip the
first 4 bytes of the actual parameters and read misaligned data,
potentially breaking connection establishments?

>  
>  	bp = (uint32_t *)ha->init_cb;
>  	cpu_to_be32_array(q, bp, sz / 4);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260807093429.102604-1-ghuicao@163.com?part=1

      reply	other threads:[~2026-08-07  9:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07  9:34 [PATCH] scsi: qla2xxx: Fix buffer overrun in login template ghuicao
2026-08-07  9:47 ` sashiko-bot [this message]

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=20260807094752.2EF2D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ghuicao@163.com \
    --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