From: sashiko-bot@kernel.org
To: "Ciro Iriarte" <ciro.iriarte+software@gmail.com>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org
Subject: Re: [PATCH] scsi: elx: efct: report residual for status-only Data-In responses
Date: Fri, 04 Dec 2026 18:31:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-250423@kernel.org> (raw)
In-Reply-To: <b82e2805-2368-43c6-9686-927fcf8731d6@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] scsi: elx: efct: signed int wrap of rsp.residual in
efct_lio_queue_status()
- [Low] scsi: elx: efct: contradictory stale comment left in
efct_lio_queue_status()
--
commit a54c529a9f1575d63dad16f1055e12ab0ca4bab4
Author: Ciro Iriarte <ciro.iriarte+software@gmail.com>
scsi: elx: efct: report residual for status-only Data-In responses
This patch changes efct_lio_queue_status() to compute rsp.residual as
io->exp_xfer_len - io->transferred for DMA_FROM_DEVICE commands instead
of copying LIO's residual_count.
> diff --git a/drivers/scsi/elx/efct/efct_lio.c b/drivers/scsi/elx/efct/efct_lio.c
> index 67d686dd6fb33..033bac6856549 100644
> --- a/drivers/scsi/elx/efct/efct_lio.c
> +++ b/drivers/scsi/elx/efct/efct_lio.c
> @@ -671,7 +671,15 @@ efct_lio_queue_status(struct se_cmd *cmd)
> /* Check for residual underrun or overrun, mark negitive value for
> * underrun to recognize in HW
> */
> - if (cmd->se_cmd_flags & SCF_OVERFLOW_BIT)
> + /*
> + * For a Data-In command, report the part of FCP_DL that was not
> + * transferred, as the initiator counts it. LIO's residual describes
> + * the data buffer, not a data phase skipped because the command
> + * ended with a non-GOOD status (e.g. CHECK CONDITION).
> + */
[Severity: Low]
This isn't a bug, but the old comment right above the new one has the
sign backwards ("mark negitive value for underrun", while negative
means overrun here and in efct_scsi_send_resp()). Replacing the old
comment instead of stacking both would avoid the contradiction.
> + if (cmd->data_direction == DMA_FROM_DEVICE)
> + rsp.residual = io->exp_xfer_len - io->transferred;
[Severity: Medium]
Can rsp.residual wrap to a negative value when a Data-In command has
FCP_DL >= 0x80000000 and fails before transferring data?
efct_populate_io_fcp_cmd() sets u32 io->exp_xfer_len directly from
be32_to_cpu(cmnd->fc_dl) without bounding it to INT_MAX, while
rsp.residual in struct efct_scsi_cmd_resp is a signed 32-bit int.
With io->transferred == 0, values >= 0x80000000 wrap into [INT_MIN, -1].
efct_scsi_send_resp() then treats residual <= 0 as an overrun, setting
FCP_RESID_OVER instead of FCP_RESID_UNDER and negating residual, which
corrupts the wire count and overflows signed int at INT_MIN.
Widening residual to s64 (or using a u32 residual with an explicit
direction flag) would cover the full 32-bit FCP_DL range.
--
Sashiko AI review · https://sashiko.dev/#/patchset/b82e2805-2368-43c6-9686-927fcf8731d6@gmail.com?part=1
prev parent reply other threads:[~2026-12-04 18:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 18:08 [PATCH] scsi: elx: efct: report residual for status-only Data-In responses Ciro Iriarte
2026-12-04 18:31 ` 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=sashiko-outbox-250423@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ciro.iriarte+software@gmail.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=target-devel@vger.kernel.org \
/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