From: sashiko-bot@kernel.org
To: "Yehyeong Lee" <yhlee@isslab.korea.ac.kr>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/2] scsi: aacraid: bound the SRB sense data copy to the source buffer
Date: Tue, 13 Oct 2026 14:15:24 +0000 [thread overview]
Message-ID: <sashiko-outbox-169890@kernel.org> (raw)
In-Reply-To: <20261013140214.3156938-2-yhlee@isslab.korea.ac.kr>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] scsi: aacraid: silent data corruption due to clobbered scsicmd->result
--
commit 41e55cd2865c820cb5e9b169fa01f61a9291992f
Author: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
scsi: aacraid: bound the SRB sense data copy to the source buffer
aac_srb_callback() copies the sense data from an adapter SRB reply into
the command's sense buffer, using a length that is only capped at
SCSI_SENSE_BUFFERSIZE (96 bytes). The source, srbreply->sense_data, is
AAC_SENSE_BUFFERSIZE (30 bytes), so an adapter that reports a larger
sense_data_size makes the copy read up to 66 bytes past the sense array.
Cap the copy at the size of the source array, matching the container
sense paths in this driver.
Cc: stable@vger.kernel.org
> diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
> --- a/drivers/scsi/aacraid/aachba.c
> +++ b/drivers/scsi/aacraid/aachba.c
> @@ -3418,7 +3418,7 @@ static void aac_srb_callback(void *context, struct fib * fibptr)
> pr_warn("aac_srb_callback: srb failed, status = %d\n",
> le32_to_cpu(srbreply->status));
> len = min_t(u32, le32_to_cpu(srbreply->sense_data_size),
> - SCSI_SENSE_BUFFERSIZE);
> + sizeof(srbreply->sense_data));
> scsicmd->result = DID_ERROR << 16 | SAM_STAT_CHECK_CONDITION;
> memcpy(scsicmd->sense_buffer,
> srbreply->sense_data, len);
> }
>
> /*
> * Next check the srb status
> */
> switch ((le32_to_cpu(srbreply->srb_status))&0x3f) {
> case SRB_STATUS_ERROR_RECOVERY:
> case SRB_STATUS_PENDING:
> case SRB_STATUS_SUCCESS:
> scsicmd->result = DID_OK << 16;
[Severity: Critical]
Does this code unconditionally overwrite the error status set during a FIB
failure?
If the adapter returns a FIB failure (srbreply->status != ST_OK), the block
above sets scsicmd->result to DID_ERROR << 16 | SAM_STAT_CHECK_CONDITION.
It then immediately falls through to the switch on srb_status. For values
like SRB_STATUS_PENDING or SRB_STATUS_SUCCESS, the switch assigns
scsicmd->result = DID_OK << 16.
Could this clobber the error status and discard the SAM_STAT_CHECK_CONDITION
bit? If srbreply->scsi_status happens to be 0, the command would complete as
DID_OK despite the earlier error.
Can this lead to silent data corruption by causing the OS to ignore the
copied sense buffer and incorrectly assume data was safely written?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261013140214.3156938-1-yhlee@isslab.korea.ac.kr?part=1
next prev parent reply other threads:[~2026-10-13 14:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 14:02 [PATCH 0/2] scsi: aacraid: bound adapter-declared sense lengths Yehyeong Lee
2026-10-13 14:02 ` [PATCH 1/2] scsi: aacraid: bound the SRB sense data copy to the source buffer Yehyeong Lee
2026-10-13 14:15 ` sashiko-bot [this message]
2026-10-13 14:02 ` [PATCH 2/2] scsi: aacraid: bound the HBA sense response " Yehyeong Lee
2026-10-13 14:16 ` 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=sashiko-outbox-169890@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