Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1610imu; Tue, 8 Jan 2019 13:28:44 -0800 (PST) X-Google-Smtp-Source: ALg8bN7xzWvtylZc4BAogfbeo0/1YxyoNaFoayIR3Ui1kYTDKVjv8k0J9BFzZVgGeq43tN2AG2Pn X-Received: by 2002:a62:4d81:: with SMTP id a123mr3471413pfb.122.1546982924670; Tue, 08 Jan 2019 13:28:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546982924; cv=none; d=google.com; s=arc-20160816; b=ab/MfpLG9vQDO7DQrCHpBi5lPy+uPw5Hokry40hkGWUGSFNEbJr7Ze4J9r9tHAfwOs Etmx4cXnkiHLhGPiMk8N6DOg5Awp0nY9veeuRoiRzSZh1silJ5SEnGjgOZiLHhO4+ajB C1Fm3+nsziIUdmJn+O91mH/hoxgVbTmT6CBVhEiMIFCA2PN6KQ/Giw/7Fxy5M3ZmI3Xq YxGr+ULOLBjfUlhP/+6Hp4iqxeNu8rmTqIF890UUp9E8R4KOaG/tFKOJDi9rl4HkgI5P faP/Sq7P18c0mQyT/jClgJQBWzA803vwBpZZ5jehdg19cQ8C9873jbHS5V/rBKZSbseZ 9PxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=POMqYiB5tK5Zjff/i/ah5x5VohSzN/wFmaGL+d0pop8=; b=NKPE6+RmPLF6gHAuiAZ0V2mgw5a8ByBeK+M+0Mvrd2DuIGkK8brxj8IFJhLyyL4I4y WSAB6zg5eWKBqFFy4Ga3XOd131zgenGEdPKWWDsebcWzHDGlRbowY/vq36enANf0ubSQ BCSywhmgRa3SG/UfZZGk9DUepy6gDBP+0wI1OflbRVABcg6d8xX1n4cTXLJyrs8wvmXT UGNMsz24HQ3DuZFRmkaq+bdRwK+QqEe9rRPkHZQ3MJw4fCxbeAEBuV6aTSfP4nCuZBFq zSz6bkCCFkr2Dp/uWiCsXbQR+byaB3eAxuJBhGKHVYBiHtcXux3yqi0LOuY9CdgAbAwf 9yKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b13si11885818pgw.472.2019.01.08.13.28.29; Tue, 08 Jan 2019 13:28:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730090AbfAHVZa (ORCPT + 99 others); Tue, 8 Jan 2019 16:25:30 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53600 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729511AbfAHVZ3 (ORCPT ); Tue, 8 Jan 2019 16:25:29 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5AF58C065F95; Tue, 8 Jan 2019 21:25:28 +0000 (UTC) Received: from segfault.boston.devel.redhat.com (segfault.boston.devel.redhat.com [10.19.60.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 18F101001F5E; Tue, 8 Jan 2019 21:25:27 +0000 (UTC) From: Jeff Moyer To: Logan Gunthorpe Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Intel SCU Linux support , Artur Paszkiewicz , "James E.J. Bottomley" , "Martin K. Petersen" , Christoph Hellwig , Jens Axboe , james.smart@broadcom.com, dick.kennedy@broadcom.com Subject: Re: [PATCH] scsi: isci: initialize shost fully before calling scsi_add_host() References: <20190108205043.3122-1-logang@deltatee.com> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 Date: Tue, 08 Jan 2019 16:25:26 -0500 In-Reply-To: <20190108205043.3122-1-logang@deltatee.com> (Logan Gunthorpe's message of "Tue, 8 Jan 2019 13:50:43 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 08 Jan 2019 21:25:28 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Logan Gunthorpe 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 > Cc: Intel SCU Linux support > Cc: Artur Paszkiewicz > Cc: "James E.J. Bottomley" > Cc: "Martin K. Petersen" > Cc: Christoph Hellwig > Cc: Jens Axboe > Cc: Jeff Moyer Nice job, and excellent commit message. We'll need a similar patch for lpfc. Reviewed-by: Jeff Moyer > --- > 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);