From: Jeff Moyer <jmoyer@redhat.com>
To: Logan Gunthorpe <logang@deltatee.com>
Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org,
Intel SCU Linux support <intel-linux-scu@intel.com>,
Artur Paszkiewicz <artur.paszkiewicz@intel.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Christoph Hellwig <hch@lst.de>, Jens Axboe <axboe@kernel.dk>,
james.smart@broadcom.com, dick.kennedy@broadcom.com
Subject: Re: [PATCH] scsi: isci: initialize shost fully before calling scsi_add_host()
Date: Tue, 08 Jan 2019 16:25:26 -0500 [thread overview]
Message-ID: <x49imyy7sft.fsf@segfault.boston.devel.redhat.com> (raw)
In-Reply-To: <20190108205043.3122-1-logang@deltatee.com> (Logan Gunthorpe's message of "Tue, 8 Jan 2019 13:50:43 -0700")
Logan Gunthorpe <logang@deltatee.com> writes:
> scsi_mq_setup_tags(), which is called by scsi_add_host(), calculates
> the command size to allocate based on the prot_capabilities. In the
> isci driver, scsi_host_set_prot() is called after scsi_add_host()
> so the command size gets calculated to be smaller than it needs to be.
> Eventually, scsi_mq_init_request() locates the 'prot_sdb' after the command
> assuming it was sized correctly and a buffer overrun may occur.
[...]
> To prevent this, the calls to scsi_host_set_prot() are moved into
> isci_host_alloc() before the call to scsi_add_host(). Out of caution,
> also move the similar call to scsi_host_set_guard().
>
> Fixes: 3d2d75254915 ("[SCSI] isci: T10 DIF support")
> Link: http://lkml.kernel.org/r/da851333-eadd-163a-8c78-e1f4ec5ec857@deltatee.com
> Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
> Cc: Intel SCU Linux support <intel-linux-scu@intel.com>
> Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
> Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
> Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Jeff Moyer <jmoyer@redhat.com>
Nice job, and excellent commit message. We'll need a similar patch for
lpfc.
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
> ---
> drivers/scsi/isci/init.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c
> index 68b90c4f79a3..1727d0c71b12 100644
> --- a/drivers/scsi/isci/init.c
> +++ b/drivers/scsi/isci/init.c
> @@ -576,6 +576,13 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)
> shost->max_lun = ~0;
> shost->max_cmd_len = MAX_COMMAND_SIZE;
>
> + /* turn on DIF support */
> + scsi_host_set_prot(shost,
> + SHOST_DIF_TYPE1_PROTECTION |
> + SHOST_DIF_TYPE2_PROTECTION |
> + SHOST_DIF_TYPE3_PROTECTION);
> + scsi_host_set_guard(shost, SHOST_DIX_GUARD_CRC);
> +
> err = scsi_add_host(shost, &pdev->dev);
> if (err)
> goto err_shost;
> @@ -663,13 +670,6 @@ static int isci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> goto err_host_alloc;
> }
> pci_info->hosts[i] = h;
> -
> - /* turn on DIF support */
> - scsi_host_set_prot(to_shost(h),
> - SHOST_DIF_TYPE1_PROTECTION |
> - SHOST_DIF_TYPE2_PROTECTION |
> - SHOST_DIF_TYPE3_PROTECTION);
> - scsi_host_set_guard(to_shost(h), SHOST_DIX_GUARD_CRC);
> }
>
> err = isci_setup_interrupts(pdev);
next prev parent reply other threads:[~2019-01-08 21:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-08 20:50 [PATCH] scsi: isci: initialize shost fully before calling scsi_add_host() Logan Gunthorpe
2019-01-08 21:25 ` Jeff Moyer [this message]
2019-01-08 21:30 ` Jens Axboe
2019-01-09 3:29 ` Martin K. Petersen
2019-01-09 18:41 ` Christoph Hellwig
2019-01-10 9:11 ` John Garry
2019-01-12 2:34 ` Martin K. Petersen
2019-01-14 12:10 ` John Garry
2019-01-16 2:54 ` Martin K. Petersen
2019-01-16 14:44 ` John Garry
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=x49imyy7sft.fsf@segfault.boston.devel.redhat.com \
--to=jmoyer@redhat.com \
--cc=artur.paszkiewicz@intel.com \
--cc=axboe@kernel.dk \
--cc=dick.kennedy@broadcom.com \
--cc=hch@lst.de \
--cc=intel-linux-scu@intel.com \
--cc=james.smart@broadcom.com \
--cc=jejb@linux.ibm.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=martin.petersen@oracle.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).