Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nilesh Javali" <njavali@marvell.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 07/14] scsi: qla2xxx: Skip vport DPC processing during vport deletion
Date: Wed, 21 Oct 2026 10:36:07 +0000	[thread overview]
Message-ID: <sashiko-outbox-180105@kernel.org> (raw)
In-Reply-To: <20261021102310.3854868-8-njavali@marvell.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: qla2xxx: wrong vha delete_progress check in qla2x00_do_dpc_all_vps()
--

commit 4fbe8fb96efa7d2224539e8ec6860bb2e6e4ec2d
Author: Manish Rangankar <mrangankar@marvell.com>

scsi: qla2xxx: Skip vport DPC processing during vport deletion

This commit attempts to prevent a race between virtual port dpc processing in
qla2x00_do_dpc_all_vps() and virtual port deletion by checking the
delete_progress flag before invoking qla2x00_do_dpc_vp(). A later commit in
the series ("scsi: qla2xxx: Fix use-after-free races during vport deletion")
updates this check from vha to vp, and another follow-up commit ("scsi:
qla2xxx: Re-acquire vport_slock and refresh tvp during vport DPC") further
updates the loop.

> diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
> index 4ad23d206add2..f7a08bc0093a5 100644
> --- a/drivers/scsi/qla2xxx/qla_mid.c
> +++ b/drivers/scsi/qla2xxx/qla_mid.c
> @@ -439,7 +439,7 @@ qla2x00_do_dpc_all_vps(scsi_qla_host_t *vha)
>  
>  	spin_lock_irqsave(&ha->vport_slock, flags);
>  	list_for_each_entry_safe(vp, tvp, &ha->vp_list, list) {
> -		if (vp->vp_idx) {
> +		if (vp->vp_idx && !vha->flags.delete_progress) {

[Severity: High]
Should this check vp->flags.delete_progress instead of
vha->flags.delete_progress?

In drivers/scsi/qla2xxx/qla_mid.c:qla2x00_do_dpc_all_vps(), vha is always the
base physical host:

	if (vha->vp_idx)
		return;

Each virtual port on ha->vp_list is represented by the loop iterator vp, and
drivers/scsi/qla2xxx/qla_attr.c:qla24xx_vport_delete() only sets
flags.delete_progress on the virtual port being deleted, never on the base
physical host. Checking vha->flags.delete_progress here causes the condition
to remain true for deleting virtual ports, allowing qla2x00_do_dpc_vp(vp) to
continue running concurrently with teardown and potentially causing a
use-after-free or null pointer dereference.

Although the follow-up commit "scsi: qla2xxx: Fix use-after-free races during
vport deletion" changes this to check !vp->flags.delete_progress, this commit
is broken on its own and is tagged for stable.

Additionally, even when checking vp->flags.delete_progress, is delete_progress
set early enough in drivers/scsi/qla2xxx/qla_attr.c:qla24xx_vport_delete() to
prevent races with qla2x00_do_dpc_vp()?

In drivers/scsi/qla2xxx/qla_attr.c:qla24xx_vport_delete():

	set_bit(VPORT_DELETE, &vha->dpc_flags);

	while (test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags))
		msleep(1000);


	qla24xx_disable_vp(vha);
	qla2x00_wait_for_sess_deletion(vha);

	qla_nvme_delete(vha);
	qla_enode_stop(vha);
	qla_edb_stop(vha);

	vha->flags.delete_progress = 1;

	qlt_remove_target(ha, vha);

	fc_remove_host(vha->host);

	scsi_remove_host(vha->host);

	/* Allow timer to run to drain queued items, when removing vp */
	qla24xx_deallocate_vp_id(vha);

Before flags.delete_progress is set, qla24xx_vport_delete() has already
waited for resync, disabled the vport, deleted sessions, and stopped
nvme/enode/edb. Could qla2x00_do_dpc_vp(vp) still enter during that window to
start a new loop resync, configure the vport, process purex items, or queue
relogin work, and then continue executing concurrently with
qlt_remove_target(), fc_remove_host(), and scsi_remove_host() before
qla24xx_deallocate_vp_id() waits for vref_count to drain?

Would it be safer to check test_bit(VPORT_DELETE, &vp->dpc_flags) here, matching
drivers/scsi/qla2xxx/qla_mid.c:qla2x00_alert_all_vps()?

>  			atomic_inc(&vp->vref_count);
>  			spin_unlock_irqrestore(&ha->vport_slock, flags);
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261021102310.3854868-1-njavali@marvell.com?part=7

  reply	other threads:[~2026-10-21 10:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-21 10:22 [PATCH 00/14] scsi: qla2xxx: Misc. Bug fixes Nilesh Javali
2026-10-21 10:22 ` [PATCH 01/14] scsi: qla2xxx: Update MAINTAINERS with new FC storage alias Nilesh Javali
2026-10-21 10:22 ` [PATCH 02/14] scsi: qla2xxx: Update few AENs for 29xx handling Nilesh Javali
2026-10-21 10:22 ` [PATCH 03/14] Revert "scsi: qla2xxx: Validate BSG request_len before reading vendor_cmd[]" Nilesh Javali
2026-10-21 10:39   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 04/14] scsi: qla2xxx: Wait for session deletion before full-login LIP Nilesh Javali
2026-10-21 10:23 ` [PATCH 05/14] scsi: qla2xxx: Fix double addition of fcport to gnl.fcport list Nilesh Javali
2026-10-21 10:43   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 06/14] scsi: qla2xxx: Fix scan state machine race and IRQ-unsafe sp_unmap Nilesh Javali
2026-10-21 10:39   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 07/14] scsi: qla2xxx: Skip vport DPC processing during vport deletion Nilesh Javali
2026-10-21 10:36   ` sashiko-bot [this message]
2026-10-21 10:23 ` [PATCH 08/14] scsi: qla2xxx: Add validation check for base vport index during delete Nilesh Javali
2026-10-21 10:43   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 09/14] scsi: qla2xxx: Validate vport before deletion Nilesh Javali
2026-10-21 10:23 ` [PATCH 10/14] scsi: qla2xxx: Fix use-after-free races during vport deletion Nilesh Javali
2026-10-21 10:40   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 11/14] scsi: qla2xxx: Re-acquire vport_slock and refresh tvp during vport DPC Nilesh Javali
2026-10-21 10:43   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 12/14] scsi: qla2xxx: Yield work_lock in fabric scan path Nilesh Javali
2026-10-21 10:37   ` sashiko-bot
2026-10-21 10:23 ` [PATCH 13/14] scsi: qla2xxx: Fix purex IOCB copy size on non-29xx adapters Nilesh Javali
2026-10-21 10:23 ` [PATCH 14/14] scsi: qla2xxx: Update version to 12.00.00.2610b1 Nilesh Javali

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-180105@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=njavali@marvell.com \
    --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