All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Praneeth Balasubramanian" <praneethb2002@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 6/9] scsi: csiostor: hold hw lock when issuing port stats mailbox command
Date: Sat, 05 Dec 2026 06:47:04 +0000	[thread overview]
Message-ID: <sashiko-outbox-251143@kernel.org> (raw)
In-Reply-To: <20261205063229.2518424-7-praneethb2002@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] scsi: csiostor: spin_lock_irq() held across mdelay() mailbox
  poll in sysfs
- [Low] scsi: csiostor: commit message wrongly claims all other mailbox
  users lock
--

commit 3e9312623f9e3af6f4f38c2c746ee8490b4ad18e
Author: Praneeth Balasubramanian <praneethb2002@gmail.com>

scsi: csiostor: hold hw lock when issuing port stats mailbox command

This commit takes hw->lock with spin_lock_irq() around csio_mb_issue()
in csio_get_phy_port_stats().

> csio_get_phy_port_stats() calls csio_mb_issue() without holding
> hw->lock. The comment above csio_mb_issue() says that the caller should
> hold the hw lock, and the other mailbox users in the driver do.

[Severity: Low]
Is the commit message accurate in saying that the other mailbox users in
the driver hold hw->lock?

Several reset and configuration paths explicitly drop hw->lock before
issuing mailbox commands, such as csio_hw_initialize() ->
csio_config_queues() and csio_hw_configure() -> csio_hw_flash_fw().

Since csio_device_reset() can run those paths while the fc_host sysfs
attributes are exposed, holding hw->lock here does not close all
concurrent mailbox races.

[ ... ]

> diff --git a/drivers/scsi/csiostor/csio_lnode.c b/drivers/scsi/csiostor/csio_lnode.c
> index 161973957976b..7fef0882862f6 100644
> --- a/drivers/scsi/csiostor/csio_lnode.c
> +++ b/drivers/scsi/csiostor/csio_lnode.c
> @@ -1408,11 +1408,14 @@ csio_get_phy_port_stats(struct csio_hw *hw, uint8_t portid,
>  			portparams.nstats = 4;
>  		csio_fcoe_read_portparams_init_mb(hw, mbp, CSIO_MB_DEFAULT_TMO,
>  							&portparams, NULL);
> +		spin_lock_irq(&hw->lock);
>  		if (csio_mb_issue(hw, mbp)) {
>  			csio_err(hw, "Issue of FCoE port params failed!\n");
>  			mempool_free(mbp, hw->mb_mempool);
> +			spin_unlock_irq(&hw->lock);
>  			return -EINVAL;
>  		}
> +		spin_unlock_irq(&hw->lock);
>  		csio_mb_process_portparams_rsp(hw, mbp, &retval,
>  						&portparams, port_stats);
>  	}

[Severity: High]
Can holding hw->lock with interrupts disabled across csio_mb_issue() stall
adapter I/O and trigger hardlockups?

With cbfn NULL and CSIO_MB_DEFAULT_TMO (10 seconds), csio_mb_issue()
unconditionally runs mdelay(5) before its first status read and polls up
to 10 seconds.  Across the three loop iterations, each sysfs read holds
hw->lock with IRQs off for at least 15 ms, or 10 seconds on a timeout.

hw->lock is taken by csio_queuecommand() on every SCSI submission and by
csio_process_scsi_cmpl() in hardirq context.  An unprivileged user reading
the world-readable fc_host statistics attributes in a loop can starve
storage I/O and interrupts across CPUs, and a timeout risks a hardlockup.

Since csio_get_stats() runs in sleepable sysfs context,
csio_get_phy_port_stats() could issue the mailbox command asynchronously
with a callback completing mbp->cmplobj and wait outside hw->lock via
wait_for_completion().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205063229.2518424-1-praneethb2002@gmail.com?part=6

  reply	other threads:[~2026-12-05  6:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  6:32 [PATCH 0/9] scsi: fix missing locking and dump length checks in several drivers Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 1/9] scsi: bnx2i: Hold the session back_lock around iscsi_itt_to_task() Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 2/9] scsi: mpt3sas: do not keep an enclosure pointer across a host reset Praneeth Balasubramanian
2026-12-05  6:46   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 3/9] scsi: pmcraid: Take host_lock around scsi_report_bus_reset() Praneeth Balasubramanian
2026-12-05  6:43   ` sashiko-bot
2026-12-05  8:20     ` Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 4/9] scsi: ipr: Skip dump entries whose length is not a 4 byte multiple Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 5/9] scsi: arm: Fix eh_abort race against the interrupt handler Praneeth Balasubramanian
2026-12-05  6:50   ` sashiko-bot
2026-12-05  8:20     ` Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 6/9] scsi: csiostor: hold hw lock when issuing port stats mailbox command Praneeth Balasubramanian
2026-12-05  6:47   ` sashiko-bot [this message]
2026-12-05  8:20     ` Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 7/9] scsi: fnic: Hold fnic_lock for the oxid calls in the FIP timer work Praneeth Balasubramanian
2026-12-05  6:32 ` [PATCH 8/9] scsi: qla2xxx: Hold qp_lock when completing command in abort timeout Praneeth Balasubramanian
2026-12-05  6:58   ` sashiko-bot
2026-12-05  6:32 ` [PATCH 9/9] scsi: target: core: Fix PRgeneration race in REGISTER AND MOVE Praneeth Balasubramanian
2026-12-05  6:56   ` sashiko-bot

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-251143@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=praneethb2002@gmail.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 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.