From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796073789; b=dTnFTIpwL1ABKgRvqCVb0ohvlQ3TdjDm2bI3a6Y+qdi0eBfBq3X3X6mp5CQ9dt4deQHW 4NfsESM3iMLAY35Nf0fvvi9jLuRk1biav0t5bUuB5ucKj7MtMgnRFCsGhCBp7T6Wl3eFR M+GCUtiDSMIvoRGlc9DWO0Y26/vKVD9LGjAov3A5gedH9mkBX9ixoKG3yDrNqTp93zHYa IuLrfT4JJ024hFt0Ae0kh4R83zjYwDHMMB8XzxnTpjQ1vW4NUlhtg3DELnoUWxHWR6uxC nxKNKt2HHubPBYyHwkb9CRHQ5DkYWnuZr5shuaz4rZyvnHjLa9KmFNJFBeN+1pyRo2w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796073789; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=i1ExZvnwhX4udMXIFGY7qzR6D16PZRGhZlWugXN4YBQ=; b=LQBo4l4ZBUJgPQPNCLFZcJj6MJq0y9r6wteaGepYUIt9RaN7cQDr6jKDX2xycJMCMsDJ oHQmLyLO275h9zOXf6YK0OMVfi6FVD71/htd8BF+X2D2cPy5C2Tm+p55z0RlrrTt0hUMm iBXloYiBwhT9NDbiMSKsilGQsef8HYVJ9g6AeXB5NeWLag8ERsUg6TuhMwBUwH2K2RYRH 0bS5RiVJuppwiSRzbcAx6mK5S2INfU7yoOi8aVEXO5xKKbeufIiV7/0r67FxFnCJpXtx4 XZ2wPOgTuvDRV6/Qr/ElgDPga4WympOqWQ5CbJ6pYLcLnOiytimCsr1cpLiqL32hCaA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IuCVPSXu; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DEDB8606A31A for ; Mon, 30 Nov 2026 21:23:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IuCVPSXu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79A861F000C1; Mon, 30 Nov 2026 21:23:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796073789; bh=i1ExZvnwhX4udMXIFGY7qzR6D16PZRGhZlWugXN4YBQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=IuCVPSXuvZRizsyKXJsO1+aaycHVSNc3IvJ+pjqV7vG5ZQey0S/w1gyee8V2CB6py cCBdiRCBqGJDkmmW5hfUkYuIcW7IdUm/hESIwtW9V3aF/SFfrEzniy2MABkKwyRqhA w2Oc/fvnwO+t5lJ4/gYiLtaYA4uUVhS21mt0l9nU52/1uR3xv4HDBVe1AM7ZD3cnNG 7i1/1w09WkvWUZyAp6G78NcgYAdU3dSbD3ZMCRQ82b/QNAuYtmPrKdhV3mBOx0DRPa kdk985hSIRPi0hSwAvzKtTjXwkjKwt6rKxX4hEb4llYN/rn7dqq02HQRT+/vScBwaX 4izt8tk/z+FaQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v20 12/13] scsi: ibmvfc: register and use asynchronous sub CRQ for events Reply-To: sashiko-reviews@lists.linux.dev To: "Dave Marquardt" Cc: linux-scsi@vger.kernel.org In-Reply-To: <20261130-ibmvfc-fpin-support-v20-12-50beb6e4b62a@linux.ibm.com> References: <20261130-ibmvfc-fpin-support-v20-0-50beb6e4b62a@linux.ibm.com> <20261130-ibmvfc-fpin-support-v20-12-50beb6e4b62a@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 21:23:09 +0000 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] scsi: ibmvfc: NULL dereference on scsi->scrqs in ibmvfc_channel_setup() - [Medium] scsi: ibmvfc: stale active_queues and do_enquiry on CRQ reset and re-enable -- commit 4e91118011515253d54521b6e51230ef63114d4c Author: Dave Marquardt scsi: ibmvfc: register and use asynchronous sub CRQ for events This commit wires the asynchronous sub-CRQ into the ibmvfc sub-CRQ allocation, registration, channel setup, and teardown lifecycle alongside the SCSI and NVMe channel queues. > diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/= ibmvfc-core.c > index 5e8b25673ff5d..4a67a1a472f22 100644 > --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c > +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c [ ... ] > @@ -988,8 +989,20 @@ static int ibmvfc_reenable_crq_queue(struct ibmvfc_h= ost *vhost) > spin_unlock(vhost->crq.q_lock); > spin_unlock_irqrestore(&vhost->host->host_lock, flags); > =20 > - ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs); > - ibmvfc_reg_sub_crqs(vhost, &vhost->nvme_scrqs); > + if (ibmvfc_reg_sub_crqs(vhost, &vhost->async_scrqs) || > + ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs) || > + ibmvfc_reg_sub_crqs(vhost, &vhost->nvme_scrqs)) { > + ibmvfc_dereg_sub_crqs(vhost, &vhost->async_scrqs); > + ibmvfc_dereg_sub_crqs(vhost, &vhost->scsi_scrqs); > + ibmvfc_dereg_sub_crqs(vhost, &vhost->nvme_scrqs); > + spin_lock_irqsave(&vhost->host->host_lock, flags); > + vhost->do_enquiry =3D 0; > + vhost->mq_enabled =3D 0; > + vhost->async_scrqs.active_queues =3D 0; > + vhost->scsi_scrqs.active_queues =3D 0; > + vhost->nvme_scrqs.active_queues =3D 0; > + spin_unlock_irqrestore(&vhost->host->host_lock, flags); > + } > =20 > return rc; > } [Severity: Medium] Does ibmvfc_reenable_crq_queue() (and ibmvfc_reset_crq() below) leave active_queues stale when ibmvfc_reg_sub_crqs() succeeds, and re-enable vhost->do_enquiry even when vhost->mq_enabled is already 0? Both functions deregister all sub-CRQs and clear vhost->using_channels =3D 0 under host_lock, but only zero active_queues if ibmvfc_reg_sub_crqs() fails. While vhost->using_channels is 0=E2=80=94or permanently after migra= tion to a VIOS that does not advertise IBMVFC_CAN_SUPPORT_CHANNELS=E2=80=94callers = that test only active_queues (such as ibmvfc_nvme_active() and ibmvfc_nvme_create_queue()) will see non-zero active_queues with stale vios_cookie handles. In addition, both functions set vhost->do_enquiry =3D 1 unconditionally before calling ibmvfc_reg_sub_crqs(). Because ibmvfc_reg_sub_crqs() returns 0 immediately when vhost->mq_enabled is 0, a prior registration failure that cleared vhost->mq_enabled =3D 0 causes the error block to be skipped, leaving vhost->do_enquiry =3D 1 with no sub-CRQs allocated or registered. Resetting active_queues alongside vhost->using_channels =3D 0 and setting vhost->do_enquiry =3D vhost->mq_enabled under host_lock in both functions would avoid both issues. [ ... ] > @@ -5925,12 +5954,19 @@ static void ibmvfc_channel_setup_done(struct ibmv= fc_event *evt) > ibmvfc_dbg(vhost, "Channel Setup succeeded\n"); > flags =3D be32_to_cpu(setup->flags); > vhost->do_enquiry =3D 0; > - scsi->active_queues =3D be32_to_cpu(setup->num_scsi_subq_channels); > - nvme->active_queues =3D be32_to_cpu(setup->num_nvme_subq_channels); > + scsi->active_queues =3D min(be32_to_cpu(setup->num_scsi_subq_channels), > + scsi->max_queues); > + nvme->active_queues =3D nvme->scrqs ? > + min(be32_to_cpu(setup->num_nvme_subq_channels), > + nvme->max_queues) : 0; > + async->active_queues =3D (async->scrqs && setup->async_sub_crq_handle)= ? 1 : 0; > =20 > if (flags & IBMVFC_CHANNELS_CANCELED) { > ibmvfc_dbg(vhost, "Channels Canceled\n"); > vhost->using_channels =3D 0; > + scsi->active_queues =3D 0; > + nvme->active_queues =3D 0; > + async->active_queues =3D 0; > break; > } > =20 > @@ -5942,6 +5978,8 @@ static void ibmvfc_channel_setup_done(struct ibmvfc= _event *evt) > for (i =3D 0; i < nvme->active_queues; i++) > nvme->scrqs[i].vios_cookie =3D > be64_to_cpu(setup->channel_handles[scsi->active_queues + i]); > + for (i =3D 0; i < async->active_queues; i++) > + async->scrqs[i].vios_cookie =3D be64_to_cpu(setup->async_sub_crq_hand= le); > =20 > ibmvfc_dbg(vhost, "Using %u SCSI channels\n", > scsi->active_queues); > @@ -5976,10 +6014,11 @@ static void ibmvfc_channel_setup(struct ibmvfc_ho= st *vhost) > struct ibmvfc_event *evt =3D ibmvfc_get_reserved_event(&vhost->crq); > struct ibmvfc_channels *scsi =3D &vhost->scsi_scrqs; > struct ibmvfc_channels *nvme =3D &vhost->nvme_scrqs; > + struct ibmvfc_channels *async =3D &vhost->async_scrqs; > unsigned int scsi_channels =3D > min(scsi->desired_queues, vhost->max_vios_scsi_channels); > - unsigned int nvme_channels =3D > - min(nvme->desired_queues, vhost->max_vios_nvme_channels); > + unsigned int nvme_channels =3D nvme->scrqs ? > + min(nvme->desired_queues, vhost->max_vios_nvme_channels) : 0; > int level =3D IBMVFC_DEFAULT_LOG_LEVEL; > int i; > =20 > @@ -6003,6 +6042,9 @@ static void ibmvfc_channel_setup(struct ibmvfc_host= *vhost) > cpu_to_be64(nvme->scrqs[i].cookie); > } > =20 > + if (async->scrqs) > + setup_buf->async_sub_crq_handle =3D cpu_to_be64(async->scrqs[0].cookie= ); [Severity: High] Can ibmvfc_channel_setup() and ibmvfc_channel_setup_done() dereference a NULL scsi->scrqs pointer when mq_enabled is 0? In ibmvfc_probe(), scsi->desired_queues and scsi->max_queues are initialized to at least 1 and vhost->do_enquiry is set to 1 even when mq_enabled is 0, while ibmvfc_init_sub_crqs() returns early without allocating scsi->scrqs. When ibmvfc_channel_setup() and ibmvfc_channel_setup_done() run, nvme->scrqs and async->scrqs are checked for NULL, but scsi_channels and scsi->active_queues are computed without checking scsi->scrqs, leading to a NULL pointer dereference on scsi->scrqs[i].cookie and scsi->scrqs[i].vios_cookie. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-ibmvfc-fpi= n-support-v20-0-50beb6e4b62a@linux.ibm.com?part=3D12