From: Fiona Ebner <f.ebner@proxmox.com>
To: Guenter Roeck <linux@roeck-us.net>, Hannes Reinecke <hare@suse.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>, Fam Zheng <fam@euphon.net>,
qemu-block@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH] scsi: megasas: Internal cdbs have 16-byte length
Date: Fri, 3 Mar 2023 10:02:35 +0100 [thread overview]
Message-ID: <a294096d-1604-585c-6703-293cf8193b0c@proxmox.com> (raw)
In-Reply-To: <20230228171129.4094709-1-linux@roeck-us.net>
Am 28.02.23 um 18:11 schrieb Guenter Roeck:
> Host drivers do not necessarily set cdb_len in megasas io commands.
> With commits 6d1511cea0 ("scsi: Reject commands if the CDB length
> exceeds buf_len") and fe9d8927e2 ("scsi: Add buf_len parameter to
> scsi_req_new()"), this results in failures to boot Linux from affected
> SCSI drives because cdb_len is set to 0 by the host driver.
> Set the cdb length to its actual size to solve the problem.
>
Tested-by: Fiona Ebner <f.ebner@proxmox.com>
But I do have a question:
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> hw/scsi/megasas.c | 14 ++------------
> 1 file changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
> index 9cbbb16121..d624866bb6 100644
> --- a/hw/scsi/megasas.c
> +++ b/hw/scsi/megasas.c
> @@ -1780,7 +1780,7 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
> uint8_t cdb[16];
> int len;
> struct SCSIDevice *sdev = NULL;
> - int target_id, lun_id, cdb_len;
> + int target_id, lun_id;
>
> lba_count = le32_to_cpu(cmd->frame->io.header.data_len);
> lba_start_lo = le32_to_cpu(cmd->frame->io.lba_lo);
> @@ -1789,7 +1789,6 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
>
> target_id = cmd->frame->header.target_id;
> lun_id = cmd->frame->header.lun_id;
> - cdb_len = cmd->frame->header.cdb_len;
>
> if (target_id < MFI_MAX_LD && lun_id == 0) {
> sdev = scsi_device_find(&s->bus, 0, target_id, lun_id);
> @@ -1804,15 +1803,6 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
> return MFI_STAT_DEVICE_NOT_FOUND;
> }
>
> - if (cdb_len > 16) {
> - trace_megasas_scsi_invalid_cdb_len(
> - mfi_frame_desc(frame_cmd), 1, target_id, lun_id, cdb_len);
> - megasas_write_sense(cmd, SENSE_CODE(INVALID_OPCODE));
> - cmd->frame->header.scsi_status = CHECK_CONDITION;
> - s->event_count++;
> - return MFI_STAT_SCSI_DONE_WITH_ERROR;
> - }
Shouldn't we still fail when cmd->frame->header.cdb_len > 16? Or is the
consequence of
> Host drivers do not necessarily set cdb_len in megasas io commands.
that this can be uninitialized memory and we need to assume it was not
explicitly set?
Best Regards,
Fiona
> -
> cmd->iov_size = lba_count * sdev->blocksize;
> if (megasas_map_sgl(s, cmd, &cmd->frame->io.sgl)) {
> megasas_write_sense(cmd, SENSE_CODE(TARGET_FAILURE));
> @@ -1823,7 +1813,7 @@ static int megasas_handle_io(MegasasState *s, MegasasCmd *cmd, int frame_cmd)
>
> megasas_encode_lba(cdb, lba_start, lba_count, is_write);
> cmd->req = scsi_req_new(sdev, cmd->index,
> - lun_id, cdb, cdb_len, cmd);
> + lun_id, cdb, sizeof(cdb), cmd);
> if (!cmd->req) {
> trace_megasas_scsi_req_alloc_failed(
> mfi_frame_desc(frame_cmd), target_id, lun_id);
next prev parent reply other threads:[~2023-03-03 9:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 17:11 [PATCH] scsi: megasas: Internal cdbs have 16-byte length Guenter Roeck
2023-02-28 22:00 ` Philippe Mathieu-Daudé
2023-03-01 12:42 ` Michael Tokarev
2024-02-17 9:06 ` Michael Tokarev
2024-02-17 15:36 ` Guenter Roeck
2024-11-21 18:53 ` Fabiano Rosas
2023-03-03 9:02 ` Fiona Ebner [this message]
2023-03-03 15:10 ` Guenter Roeck
2023-03-06 7:36 ` Fiona Ebner
2024-11-21 19:41 ` Paolo Bonzini
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=a294096d-1604-585c-6703-293cf8193b0c@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=fam@euphon.net \
--cc=hare@suse.com \
--cc=linux@roeck-us.net \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).