From: sashiko-bot@kernel.org
To: "Damien Le Moal" <dlemoal@kernel.org>
Cc: linux-s390@vger.kernel.org, linux-ide@vger.kernel.org,
"Heiko Carstens" <hca@linux.ibm.com>,
cassel@kernel.org, "Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
dlemoal@kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 22/40] scsi: myrX: use 16-bits defined sense codes
Date: Thu, 03 Sep 2026 04:01:07 +0000 [thread overview]
Message-ID: <20260903040107.DF0FF1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260903034201.112211-23-dlemoal@kernel.org>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Data Corruption: Incorrect offset used for writing the SCSI mode parameter block descriptor corrupts the 24-bit block length.
- [High] Command Timeout: The REQUEST_SENSE command in myrb_ldev_queuecommand returns without calling scsi_done(), leading to a hanging command.
- [High] Resource Leak: Returning SCSI_MLQUEUE_HOST_BUSY after a successful scsi_dma_map() without unmapping causes a DMA mapping leak.
- [High] Memory Leak: DMA pool allocations are leaked on the SG mapping error path in myrs_queuecommand.
--
commit 3eaecf993e28ec2a9d1c5ee8b1fc650d068a56f8
Author: Damien Le Moal <dlemoal@kernel.org>
scsi: myrX: use 16-bits defined sense codes
Refactor the Mylex RAID controller driver to use scsi_set_sense() and the
16-bits sense_code field of struct scsi_sense_hdr and replace all
hard-coded additional sense codes and additional sense code qualifiers
with the enum values defined in include/scsi/scsi_sense.h. This helps with
code clarity as the sense codes being processed are easier to test and
self-documented.
> diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
> index 3678b66310ed0..e7d796add9864 100644
> --- a/drivers/scsi/myrb.c
> +++ b/drivers/scsi/myrb.c
[ ... ]
> @@ -1398,7 +1400,7 @@ myrb_mode_sense(struct myrb_hba *cb, struct scsi_cmnd *scmd,
> static void myrb_request_sense(struct myrb_hba *cb,
> struct scsi_cmnd *scmd)
> {
> - scsi_build_sense(scmd, 0, NO_SENSE, 0, 0);
> + scsi_set_sense(scmd, 0, NO_SENSE, NO_ADDITIONAL_SENSE_INFORMATION);
> scsi_sg_copy_from_buffer(scmd, scmd->sense_buffer,
> SCSI_SENSE_BUFFERSIZE);
> }
[Severity: High]
This is a pre-existing issue, but looking at how myrb_request_sense() is used
in myrb_ldev_queuecommand() in drivers/scsi/myrb.c:
case REQUEST_SENSE:
myrb_request_sense(cb, scmd);
scmd->result = (DID_OK << 16);
return 0;
Because returning 0 indicates to the SCSI midlayer that the driver has
accepted the command and will complete it asynchronously, does failing to call
scsi_done(scmd) here cause the command to hang indefinitely and eventually
trigger a SCSI timeout?
[ ... ]
> @@ -1461,8 +1463,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,
> case MODE_SENSE:
> if ((scmd->cmnd[2] & 0x3F) != 0x3F &&
> (scmd->cmnd[2] & 0x3F) != 0x08) {
> - /* Illegal request, invalid field in CDB */
> - scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0);
> + scsi_set_sense(scmd, 0, ILLEGAL_REQUEST,
> + INVALID_FIELD_IN_CDB);
> } else {
> myrb_mode_sense(cb, scmd, ldev_info);
[Severity: Critical]
This is a pre-existing issue, but I noticed myrb_mode_sense() in
drivers/scsi/myrb.c writes the block size to the mode page block descriptor
using put_unaligned_be32():
static void myrb_mode_sense(struct myrb_hba *cb, struct scsi_cmnd *scmd,
struct myrb_ldev_info *ldev_info)
{
...
put_unaligned_be32(cb->ldev_block_size, &block_desc[5]);
Since the block length in the descriptor is a 24-bit field located at offsets
5, 6, and 7, won't writing a 32-bit value at offset 5 overflow the LSB into
offset 8 (the start of the mode page header)? For a typical 512 byte block
size, it seems this writes 2 instead of 512, completely corrupting capacity
reporting.
> scmd->result = (DID_OK << 16);
[ ... ]
> @@ -1544,8 +1546,8 @@ static enum scsi_qc_status myrb_ldev_queuecommand(struct Scsi_Host *shost,
> block_cnt = get_unaligned_be32(&scmd->cmnd[6]);
> break;
> default:
> - /* Illegal request, invalid opcode */
> - scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x20, 0);
> + scsi_set_sense(scmd, 0, ILLEGAL_REQUEST,
> + INVALID_COMMAND_OP_CODE);
> scsi_done(scmd);
> return 0;
> }
[Severity: High]
This is a pre-existing issue, but later in myrb_ldev_queuecommand() in
drivers/scsi/myrb.c, after the switch statement, the function maps DMA memory:
nsge = scsi_dma_map(scmd);
...
} else {
struct myrb_sge *hw_sgl;
dma_addr_t hw_sgl_addr;
int i;
hw_sgl = dma_pool_alloc(cb->sg_pool, GFP_ATOMIC, &hw_sgl_addr);
if (!hw_sgl)
return SCSI_MLQUEUE_HOST_BUSY;
Does returning SCSI_MLQUEUE_HOST_BUSY without calling scsi_dma_unmap() cause
a DMA mapping and IOMMU resource leak when the midlayer retries the command
and maps it again?
> diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
> index afd68225221a6..1192b01fab8ec 100644
> --- a/drivers/scsi/myrs.c
> +++ b/drivers/scsi/myrs.c
[ ... ]
> @@ -1603,7 +1607,8 @@ static enum scsi_qc_status myrs_queuecommand(struct Scsi_Host *shost,
>
> switch (scmd->cmnd[0]) {
> case REPORT_LUNS:
> - scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x20, 0x0);
> + scsi_set_sense(scmd, 0, ILLEGAL_REQUEST,
> + INVALID_COMMAND_OP_CODE);
> scsi_done(scmd);
> return 0;
> case MODE_SENSE:
> @@ -1612,8 +1617,8 @@ static enum scsi_qc_status myrs_queuecommand(struct Scsi_Host *shost,
>
> if ((scmd->cmnd[2] & 0x3F) != 0x3F &&
> (scmd->cmnd[2] & 0x3F) != 0x08) {
> - /* Illegal request, invalid field in CDB */
> - scsi_build_sense(scmd, 0, ILLEGAL_REQUEST, 0x24, 0);
> + scsi_set_sense(scmd, 0, ILLEGAL_REQUEST,
> + INVALID_FIELD_IN_CDB);
> } else {
> myrs_mode_sense(cs, scmd, ldev_info);
[Severity: Critical]
This is a pre-existing issue, but myrs_mode_sense() in drivers/scsi/myrs.c
has the identical bug as myrb_mode_sense() when writing the mode page block
descriptor:
static void myrs_mode_sense(struct myrs_hba *cs, struct scsi_cmnd *scmd,
struct myrs_ldev_info *ldev_info)
{
...
put_unaligned_be32(ldev_info->devsize_bytes, &block_desc[5]);
Does this similarly corrupt the 24-bit block length by writing a 32-bit value?
[Severity: High]
Additionally, this is another pre-existing issue in myrs_queuecommand() in
drivers/scsi/myrs.c. When processing commands with scatterlists, if
dma_pool_alloc() fails it returns SCSI_MLQUEUE_HOST_BUSY:
hw_sgl = dma_pool_alloc(cs->sg_pool, GFP_ATOMIC,
&hw_sgl_addr);
if (WARN_ON(!hw_sgl)) {
if (cmd_blk->dcdb) {
dma_pool_free(cs->dcdb_pool,
cmd_blk->dcdb,
cmd_blk->dcdb_dma);
...
return SCSI_MLQUEUE_HOST_BUSY;
}
Since scsi_dma_map() was already called earlier in the function, does
returning here without calling scsi_dma_unmap() leak the DMA mapping?
[Severity: High]
Finally, in the same scatterlist loop in myrs_queuecommand(), there is a
sanity check on hw_sgl:
scsi_for_each_sg(scmd, sgl, nsge, i) {
if (WARN_ON(!hw_sgl)) {
scsi_dma_unmap(scmd);
scmd->result = (DID_ERROR << 16);
scsi_done(scmd);
return 0;
}
When taking this error path, it calls scsi_done(scmd) but bypasses the normal
completion routine myrs_handle_scsi(). Does this permanently leak the
dma_pool_alloc() blocks for cmd_blk->sense and cmd_blk->dcdb?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903034201.112211-1-dlemoal@kernel.org?part=22
next prev parent reply other threads:[~2026-09-03 4:01 UTC|newest]
Thread overview: 130+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 3:41 [PATCH v2 00/40] Use defined 16-bits ASC/ASCQ combinations Damien Le Moal
2026-09-03 3:41 ` [PATCH v2 01/40] scsi: define all additional sense codes and their qualifiers Damien Le Moal
2026-09-03 3:55 ` sashiko-bot
2026-09-03 11:54 ` Johannes Thumshirn
2026-09-07 12:01 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 02/40] scsi: constants: use defined sense codes Damien Le Moal
2026-09-03 3:53 ` sashiko-bot
2026-09-03 12:35 ` Johannes Thumshirn
2026-09-07 12:02 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 03/40] scsi: constants: rename internal struct field names Damien Le Moal
2026-09-03 3:50 ` sashiko-bot
2026-09-03 12:37 ` Johannes Thumshirn
2026-09-07 12:04 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 04/40] scsi: rename sense field of struct scsi_failure Damien Le Moal
2026-09-03 3:53 ` sashiko-bot
2026-09-07 12:10 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 05/40] scsi: prepare for using 16-bits defined sense codes Damien Le Moal
2026-09-03 3:53 ` sashiko-bot
2026-09-03 12:39 ` Johannes Thumshirn
2026-09-07 12:16 ` Hannes Reinecke
2026-09-08 0:22 ` Damien Le Moal
2026-09-08 14:29 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 06/40] scsi: use struct scsi_sense_hdr to log sense keys and codes Damien Le Moal
2026-09-03 3:51 ` sashiko-bot
2026-09-07 12:18 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 07/40] scsi: core: use 16-bits defined sense codes Damien Le Moal
2026-09-03 3:56 ` sashiko-bot
2026-09-07 12:21 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 08/40] scsi: sd: " Damien Le Moal
2026-09-03 4:00 ` sashiko-bot
2026-09-07 12:25 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 09/40] scsi: sr: " Damien Le Moal
2026-09-03 3:54 ` sashiko-bot
2026-09-07 13:56 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 10/40] scsi: ses: " Damien Le Moal
2026-09-03 3:51 ` sashiko-bot
2026-09-07 12:27 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 11/40] scsi: ch: " Damien Le Moal
2026-09-03 3:50 ` sashiko-bot
2026-09-07 13:48 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 12/40] scsi: st: " Damien Le Moal
2026-09-03 3:49 ` sashiko-bot
2026-09-07 13:47 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 13/40] scsi: device_handlers: hp_sw: " Damien Le Moal
2026-09-03 3:49 ` sashiko-bot
2026-09-07 12:28 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 14/40] scsi: device_handlers: rdac: " Damien Le Moal
2026-09-03 3:51 ` sashiko-bot
2026-09-07 13:49 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 15/40] scsi: device_handlers: emc: " Damien Le Moal
2026-09-03 3:50 ` sashiko-bot
2026-09-07 13:48 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 16/40] scsi: device_handlers: alua: " Damien Le Moal
2026-09-03 3:52 ` sashiko-bot
2026-09-07 12:29 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 17/40] scsi: mpt3sas: " Damien Le Moal
2026-09-03 3:51 ` sashiko-bot
2026-09-07 12:29 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 18/40] scsi: mpi3mr: " Damien Le Moal
2026-09-03 3:51 ` sashiko-bot
2026-09-07 12:30 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 19/40] scsi: 3w-xxxx: " Damien Le Moal
2026-09-03 3:52 ` sashiko-bot
2026-09-07 13:51 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 20/40] scsi: leapraid: " Damien Le Moal
2026-09-03 3:52 ` sashiko-bot
2026-09-07 13:52 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 21/40] scsi: megaraid: " Damien Le Moal
2026-09-03 3:54 ` sashiko-bot
2026-09-07 12:33 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 22/40] scsi: myrX: " Damien Le Moal
2026-09-03 4:01 ` sashiko-bot [this message]
2026-09-07 12:34 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 23/40] scsi: smartpqi: " Damien Le Moal
2026-09-03 3:54 ` sashiko-bot
2026-09-07 12:35 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 24/40] scsi: qla2xxx: " Damien Le Moal
2026-09-03 4:00 ` sashiko-bot
2026-09-07 12:36 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 25/40] scsi: ps3rom: " Damien Le Moal
2026-09-03 4:01 ` sashiko-bot
2026-09-07 12:36 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 26/40] scsi: lpfc: " Damien Le Moal
2026-09-03 3:54 ` sashiko-bot
2026-09-07 12:37 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 27/40] scsi: stex: " Damien Le Moal
2026-09-03 3:59 ` sashiko-bot
2026-09-07 12:38 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 28/40] scsi: mvumi: " Damien Le Moal
2026-09-03 4:02 ` sashiko-bot
2026-09-07 12:38 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 29/40] scsi: libiscsi: " Damien Le Moal
2026-09-03 3:55 ` sashiko-bot
2026-09-07 12:40 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 30/40] scsi: ibmvscsi_tgt: " Damien Le Moal
2026-09-03 4:04 ` sashiko-bot
2026-09-07 12:40 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 31/40] scsi: scsi_debug: " Damien Le Moal
2026-09-03 4:01 ` sashiko-bot
2026-09-07 12:47 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 32/40] scsi: hpsa: " Damien Le Moal
2026-09-03 3:57 ` sashiko-bot
2026-09-07 12:52 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 33/40] scsi: storvsc: " Damien Le Moal
2026-09-03 3:58 ` sashiko-bot
2026-09-07 12:53 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 34/40] target: " Damien Le Moal
2026-09-03 4:02 ` sashiko-bot
2026-09-07 12:55 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 35/40] usb: storage: " Damien Le Moal
2026-09-03 4:01 ` sashiko-bot
2026-09-07 12:56 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 36/40] cdrom: " Damien Le Moal
2026-09-03 3:57 ` sashiko-bot
2026-09-07 13:17 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 37/40] ata: libata: " Damien Le Moal
2026-09-03 4:06 ` sashiko-bot
2026-09-03 9:10 ` Niklas Cassel
2026-09-07 13:19 ` Hannes Reinecke
2026-09-03 3:41 ` [PATCH v2 38/40] s390: scsi: " Damien Le Moal
2026-09-03 4:01 ` sashiko-bot
2026-09-07 13:20 ` Hannes Reinecke
2026-09-08 0:24 ` Damien Le Moal
2026-09-03 3:42 ` [PATCH v2 39/40] scsi: cleanup scsi_proto.h Damien Le Moal
2026-09-03 4:00 ` sashiko-bot
2026-09-07 13:41 ` Hannes Reinecke
2026-09-03 3:42 ` [PATCH v2 40/40] scsi: remove scsi_build_sense() and scsi_build_sense_buffer() Damien Le Moal
2026-09-03 3:58 ` sashiko-bot
2026-09-03 9:15 ` Niklas Cassel
2026-09-07 13:43 ` Hannes Reinecke
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=20260903040107.DF0FF1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=cassel@kernel.org \
--cc=dlemoal@kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-s390@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.