From: Dave Marquardt <davemarq@linux.ibm.com>
To: sashiko-bot@kernel.org
Cc: sashiko-reviews@lists.linux.dev, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v13 05/11] scsi: ibmvfc: add NOOP command support
Date: Mon, 12 Oct 2026 14:24:19 -0500 [thread overview]
Message-ID: <87qzhuvi1o.fsf@linux.ibm.com> (raw)
In-Reply-To: <sashiko-outbox-163312@kernel.org> (sashiko-bot@kernel.org's message of "Wed, 07 Oct 2026 19:36:26 +0000")
sashiko-bot@kernel.org writes:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] scsi: ibmvfc: wild pointer dereference in ibmvfc_handle_scrq() during evt validation
> --
>
> commit 3a880d56c6f97510d8dc3b25b1c3b9b6711c3a6d
> Author: Dave Marquardt <davemarq@linux.ibm.com>
>
> scsi: ibmvfc: add NOOP command support
>
> Add support for handling IBMVFC_NOOP format CRQ messages from the
> VIOS partner. Advertise the client's ability to handle NOOP commands
> by setting the IBMVFC_CAN_USE_NOOP_CMD capability in ibmvfc_set_login_info().
> Handle and ignore IBMVFC_NOOP format messages in both ibmvfc_handle_crq()
> and ibmvfc_handle_scrq().
>
>> diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> index ac2571e9e1eb9..161d4679d7026 100644
>> --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c
>> +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c
>
> [ ... ]
>
>> @@ -4225,7 +4235,20 @@ static void ibmvfc_handle_scrq(struct ibmvfc_crq *crq, struct ibmvfc_host *vhost
>> case IBMVFC_CRQ_XPORT_EVENT:
>> return;
>> default:
>> - dev_err(vhost->dev, "Got and invalid message type 0x%02x\n", crq->valid);
>> + dev_err(vhost->dev, "Got an invalid message type 0x%02x\n", crq->valid);
>> + return;
>> + }
>> +
>> + if (crq->format == IBMVFC_NOOP) {
>> + if (vhost->state == IBMVFC_ACTIVE &&
>> + !ibmvfc_check_caps(vhost, IBMVFC_SUPPORT_NOOP_CMD))
>> + dev_err_ratelimited(vhost->dev,
>> + "Received unexpected NOOP command from partner\n");
>> + return;
>> + }
>> +
>> + if (unlikely(!evt)) {
>> + dev_err(vhost->dev, "Received null event\n");
>> return;
>> }
>>
>> /* The only kind of payload CRQs we should get are responses to
>> * things we send. Make sure this response is to something we
>> * actually sent
>> */
>> if (unlikely(!ibmvfc_valid_event(&evt->queue->evt_pool, evt))) {
>
> [Severity: High]
> Can this code dereference a wild pointer if the VIOS partner or hypervisor
> sends an arbitrary, non-zero garbage token in crq->ioba?
>
> At the top of ibmvfc_handle_scrq(), crq->ioba is cast to the evt pointer.
> While this patch adds a check to prevent a NULL pointer dereference, if
> crq->ioba is non-zero garbage, wouldn't evaluating evt->queue dereference
> that untrusted pointer before ibmvfc_valid_event() has a chance to safely
> validate it?
>
> Looking at ibmvfc_handle_crq(), it avoids dereferencing the event entirely
> during validation by checking against the host pool:
>
> if (unlikely(!ibmvfc_valid_event(&vhost->crq.evt_pool, evt))) {
>
> Could we do something similar here by passing the valid scrq directly into
> ibmvfc_handle_scrq() so it can safely use &scrq->evt_pool?
Okay, good idea. I'm removing the vhost parameter of
ibmvfc_handle_scrq() and adding a struct ibmvfc_queue *scrq
parameter, and updating the ibmvfc_valid_event call as suggested.
-Dave
next prev parent reply other threads:[~2026-10-12 19:24 UTC|newest]
Thread overview: 42+ 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 ` Dave Marquardt
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 ` Dave Marquardt
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 ` Dave Marquardt
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:25 ` Dave Marquardt
2026-10-07 19:44 ` sashiko-bot
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:25 ` Dave Marquardt
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:25 ` Dave Marquardt
2026-10-07 19:36 ` sashiko-bot
2026-10-12 19:24 ` Dave Marquardt [this message]
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 ` Dave Marquardt
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-07 19:25 ` Dave Marquardt
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:25 ` Dave Marquardt
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 ` Dave Marquardt
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:25 ` Dave Marquardt
2026-10-07 19:42 ` sashiko-bot
2026-10-13 22:02 ` Dave Marquardt
2026-10-07 19:25 ` [PATCH v13 11/11] scsi: ibmvfc: handle extended FPIN events Dave Marquardt via B4 Relay
2026-10-07 19:25 ` Dave Marquardt
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=87qzhuvi1o.fsf@linux.ibm.com \
--to=davemarq@linux.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-bot@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.