From: sashiko-bot@kernel.org
To: "Dave Marquardt" <davemarq@linux.ibm.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v13 03/11] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation
Date: Wed, 07 Oct 2026 19:44:41 +0000 [thread overview]
Message-ID: <sashiko-outbox-163321@kernel.org> (raw)
In-Reply-To: <20261007-ibmvfc-fpin-support-v13-3-b816abfa4fcc@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] scsi: ibmvfc: double free of sub-CRQs on partial registration failure
- [Low] scsi: ibmvfc: unprotected H_FREE_SUB_CRQ on uninitialized or double-freed queues
--
commit 0fde5959dd5d7f8887aa67ee2fa7032b0dd6353a
Author: Tyrel Datwyler <tyreld@linux.ibm.com>
scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation
Guard the memset() in ibmvfc_deregister_channel() behind a check of
scrq->msgs.handle to prevent a NULL dereference when the function is
called on a queue that was never allocated, such as async_sub_crq when
multi-queue is disabled or initialization failed before
ibmvfc_alloc_queue() was reached.
> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> index 145d559041f12..6a42d15db9ec5 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
> @@ -6480,8 +6480,10 @@ static void ibmvfc_deregister_channel(struct ibmvfc_host *vhost,
> dev_err(dev, "Failed to free sub-crq[%d]: rc=%ld\n", index, rc);
[Severity: High]
Can a partial registration failure lead to a double-free of the sub-CRQ
resource?
In ibmvfc_reg_sub_crqs(), if registration fails midway, it deregisters the
already registered queues by calling ibmvfc_deregister_channel():
drivers/scsi/ibmvscsi/ibmvfc-core.c:ibmvfc_reg_sub_crqs() {
...
for (i = 0; i < channels->max_queues; i++) {
if (ibmvfc_register_channel(vhost, channels, i)) {
for (j = i; j > 0; j--)
ibmvfc_deregister_channel(vhost, channels, j - 1);
...
}
However, ibmvfc_deregister_channel() doesn't zero scrq->cookie, and
vhost->mq_enabled remains true.
When a subsequent adapter reset or teardown occurs, ibmvfc_dereg_sub_crqs()
loops over all queues and calls ibmvfc_deregister_channel() again on the
same queues, potentially causing a double-free at the hypervisor level.
Could scrq->cookie be cleared after successfully freeing the sub-CRQ to
prevent this?
> /* Clean out the queue */
> - memset(scrq->msgs.crq, 0, PAGE_SIZE);
> - scrq->cur = 0;
> + if (scrq->msgs.handle) {
[Severity: Low]
Is the H_FREE_SUB_CRQ hypercall safe to execute on uninitialized queues?
The memset() is now properly guarded by scrq->msgs.handle, but the
H_FREE_SUB_CRQ hypercall just above this block continues to run
unconditionally.
If a queue was never registered or was already deregistered (such as during
the ibmvfc_reg_sub_crqs() rollback), the unconditional hypercall will fail
and generate a spurious "Failed to free sub-crq..." error message.
Should the hypercall logic also be protected against uninitialized or already
freed queues?
> + memset(scrq->msgs.crq, 0, PAGE_SIZE);
> + scrq->cur = 0;
> + }
>
> LEAVE;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261007-ibmvfc-fpin-support-v13-0-b816abfa4fcc@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-10-07 19:44 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 19:25 [PATCH v13 00/11] scsi: ibmvfc: make ibmvfc support FPIN messages Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 01/11] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 02/11] scsi: ibmvfc: fix potential clobbering of rc after failed irq setup Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 03/11] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation Dave Marquardt via B4 Relay
2026-10-07 19:44 ` sashiko-bot [this message]
2026-10-09 18:34 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 04/11] scsi: ibmvfc: add basic FPIN support Dave Marquardt via B4 Relay
2026-10-07 19:41 ` sashiko-bot
2026-10-08 21:24 ` Dave Marquardt
2026-10-09 5:20 ` kernel test robot
2026-10-09 14:45 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 05/11] scsi: ibmvfc: add NOOP command support Dave Marquardt via B4 Relay
2026-10-07 19:36 ` sashiko-bot
2026-10-12 19:24 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 06/11] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 07/11] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Dave Marquardt via B4 Relay
2026-10-09 13:22 ` kernel test robot
2026-10-09 14:50 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 08/11] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Dave Marquardt via B4 Relay
2026-10-07 19:44 ` sashiko-bot
2026-10-12 19:44 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 09/11] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Dave Marquardt via B4 Relay
2026-10-07 19:25 ` [PATCH v13 10/11] scsi: ibmvfc: register and use asynchronous sub CRQ for events Dave Marquardt via B4 Relay
2026-10-07 19:42 ` sashiko-bot
2026-10-07 19:25 ` [PATCH v13 11/11] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-10-07 19:33 ` sashiko-bot
2026-10-07 19:52 ` Dave Marquardt
2026-10-09 20:29 ` kernel test robot
2026-10-12 19:50 ` Dave Marquardt
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=sashiko-outbox-163321@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=davemarq@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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