From: Bart Van Assche <bvanassche@acm.org>
To: John Garry <john.garry@huawei.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
linux-scsi@vger.kernel.org, Ming Lei <ming.lei@redhat.com>,
Hannes Reinecke <hare@suse.de>,
ericspero@icloud.com, jason600.groome@gmail.com
Subject: Re: [PATCH 3/3] scsi: sd: Rework asynchronous resume support
Date: Thu, 30 Jun 2022 12:28:24 -0700 [thread overview]
Message-ID: <149f0b6d-ae98-90c9-0ce4-ddf5f769a3fc@acm.org> (raw)
In-Reply-To: <b55be9e0-e1b7-8c8e-7c40-0cb633e381d3@acm.org>
On 6/30/22 11:57, Bart Van Assche wrote:
> On 6/30/22 09:23, John Garry wrote:
>> On 28/06/2022 23:21, Bart Van Assche wrote:
>>> +/* A START command finished. May be called from interrupt context. */
>>> +static void sd_start_done(struct request *req, blk_status_t status)
>>> +{
>>> + const struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req);
>>> + struct scsi_disk *sdkp = scsi_disk(req->q->disk);
>>> +
>>> + sdkp->start_result = scmd->result;
>>> + WARN_ON_ONCE(scmd->sense_len > SCSI_SENSE_BUFFERSIZE);
>>
>> If scmd->sense_len > SCSI_SENSE_BUFFERSIZE, do you really want to go
>> on to copy at sdkp->start_sense_buffer (which is of size
>> SCSI_SENSE_BUFFERSIZE)? Won't that cause a corruption?
>
> scsi_mq_init_request() allocates a buffer with size
> SCSI_SENSE_BUFFERSIZE. SCSI LLDs copy sense data into that buffer. I am
> not aware of any SCSI LLD that modifies the cmd->sense_buffer pointer.
> So if scmd->sense_len would be larger than SCSI_SENSE_BUFFERSIZE that
> either indicates that the LLD reported a sense length that is too large
> or that it wrote outside the bounds of the sense buffer. Do we really
> need to add a protection in the SCSI core against buggy LLDs?
A result of the above is that SCSI_SENSE_BUFFERSIZE bytes can be copied
instead of scmd->sense_len. I will make that change.
Bart.
prev parent reply other threads:[~2022-06-30 19:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 22:21 [PATCH 0/3] Reduce ATA disk resume time Bart Van Assche
2022-06-28 22:21 ` [PATCH 1/3] scsi: core: Move the definition of SCSI_QUEUE_DELAY Bart Van Assche
2022-06-28 22:21 ` [PATCH 2/3] scsi: core: Retry after a delay if the device is becoming ready Bart Van Assche
2022-06-29 1:21 ` Ming Lei
2022-06-29 22:06 ` Bart Van Assche
2022-06-28 22:21 ` [PATCH 3/3] scsi: sd: Rework asynchronous resume support Bart Van Assche
2022-06-29 6:02 ` Hannes Reinecke
2022-06-30 16:09 ` Bart Van Assche
2022-06-30 16:23 ` John Garry
2022-06-30 18:57 ` Bart Van Assche
2022-06-30 19:28 ` Bart Van Assche [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=149f0b6d-ae98-90c9-0ce4-ddf5f769a3fc@acm.org \
--to=bvanassche@acm.org \
--cc=ericspero@icloud.com \
--cc=hare@suse.de \
--cc=jaegeuk@kernel.org \
--cc=jason600.groome@gmail.com \
--cc=john.garry@huawei.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ming.lei@redhat.com \
/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).