From: sashiko-bot@kernel.org
To: "Bart Van Assche" <bvanassche@acm.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3 06/57] scsi: BusLogic: Prepare for enabling lock context analysis
Date: Thu, 30 Jul 2026 23:06:42 +0000 [thread overview]
Message-ID: <20260730230643.2DC131F000E9@smtp.kernel.org> (raw)
In-Reply-To: <045a86725b6f568d4f070c036d40d0352d25424a.1785451174.git.bvanassche@acm.org>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [Medium] The lock expressions used in the new `__must_hold` annotations do not syntactically match the lock variables used inside the functions and their callers, causing false positive context imbalance warnings in static analyzers.
- [Low] The patch misses several other functions in the driver that explicitly require the host lock, leaving the lock context annotations incomplete.
Pre-existing issues:
- [High] `spin_unlock_irq()` unconditionally enables interrupts in contexts where they must be preserved (e.g., inside `spin_lock_irqsave()` regions and hard IRQ handlers).
- [High] A failure in DMA mapping triggers a kernel panic via `BUG_ON()` rather than gracefully failing the command.
- [High] Missing memory barrier (`wmb()`) between CCB and Action Code writes in `blogic_write_outbox`.
--
--- Patch [6]: [PATCH v3 06/57] scsi: BusLogic: Prepare for enabling lock context analysis ---
commit 927e16987713b901aca16b28f9b8a4d54db270de
Author: Bart Van Assche <bvanassche@acm.org>
scsi: BusLogic: Prepare for enabling lock context analysis
This commit prepares the BusLogic SCSI driver for lock context analysis.
It adds the __must_hold() macro to document locking requirements for
blogic_qcmd_lck() and blogic_resetadapter().
> diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
> index f2a6ed710c770..dafec8b24e586 100644
> --- a/drivers/scsi/BusLogic.c
> +++ b/drivers/scsi/BusLogic.c
> @@ -2878,6 +2878,7 @@ static int blogic_hostreset(struct scsi_cmnd *SCpnt)
> */
>
> static enum scsi_qc_status blogic_qcmd_lck(struct scsi_cmnd *command)
> + __must_hold(command->device->host->host_lock)
> {
[Severity: Medium]
Will this annotation cause false positive context imbalance warnings in static
analyzers like Sparse?
The annotation requires command->device->host->host_lock, but the function
body internally unlocks and locks shost->host_lock:
spin_unlock_irq(shost->host_lock);
blogic_delay(1);
spin_lock_irq(shost->host_lock);
Since Sparse evaluates lock context expressions syntactically, will this
structural mismatch trigger the exact warnings this patch intends to prevent?
[Severity: High]
This isn't a bug introduced by this patch, but doesn't spin_unlock_irq()
unconditionally enable interrupts in contexts where they must be preserved?
Looking at blogic_qcmd_lck() in drivers/scsi/BusLogic.c:
spin_unlock_irq(shost->host_lock);
blogic_delay(1);
spin_lock_irq(shost->host_lock);
Since blogic_qcmd_lck() is called from inside a region protected by
spin_lock_irqsave() via DEF_SCSI_QCMD, does this break the caller's IRQ state
by forcefully enabling interrupts?
[Severity: High]
This is a pre-existing issue, but does a DMA mapping failure here trigger a
kernel panic instead of gracefully failing the command?
drivers/scsi/BusLogic.c:blogic_qcmd_lck() {
...
count = scsi_dma_map(command);
BUG_ON(count < 0);
...
}
Under high memory pressure or extreme fragmentation, could scsi_dma_map()
return a negative error code and cause a Denial of Service?
> void (*comp_cb)(struct scsi_cmnd *) = scsi_done;
> struct blogic_adapter *adapter =
[ ... ]
> diff --git a/drivers/scsi/BusLogic.h b/drivers/scsi/BusLogic.h
> index 24697a5bedc8b..c152b93fb6ddb 100644
> --- a/drivers/scsi/BusLogic.h
> +++ b/drivers/scsi/BusLogic.h
> @@ -1279,7 +1279,8 @@ static int blogic_sdev_configure(struct scsi_device *,
> struct queue_limits *lim);
> static void blogic_qcompleted_ccb(struct blogic_ccb *);
> static irqreturn_t blogic_inthandler(int, void *);
> -static int blogic_resetadapter(struct blogic_adapter *, bool hard_reset);
> +static int blogic_resetadapter(struct blogic_adapter *adapter, bool hard_reset)
> + __must_hold(adapter->scsi_host->host_lock);
[Severity: Medium]
Will this syntactic mismatch also cause warnings with static analyzers?
The caller blogic_hostreset() acquires shost->host_lock:
spin_lock_irq(shost->host_lock);
blogic_inc_count(&stats->adapter_reset_req);
rc = blogic_resetadapter(adapter, false);
spin_unlock_irq(shost->host_lock);
But the annotation requires adapter->scsi_host->host_lock. Could this
mismatch lead to analysis noise?
[Severity: Low]
Are there other functions in this driver that explicitly require the host
lock but missed this annotation?
Functions like blogic_alloc_ccb() and blogic_write_outbox() have header
comments explicitly stating "The Host Adapter's Lock should already have been
acquired by the caller":
static struct blogic_ccb *blogic_alloc_ccb(struct blogic_adapter *adapter)
static bool blogic_write_outbox(struct blogic_adapter *adapter,
enum blogic_action action, struct blogic_ccb *ccb)
Would adding __must_hold() to these functions complete the static analysis
coverage?
[Severity: High]
This isn't a bug introduced by this patch, but does blogic_resetadapter()
forcefully enable hardware interrupts inside a hardirq context?
The interrupt handler blogic_inthandler() calls blogic_resetadapter() on
errors. Inside blogic_resetadapter():
spin_unlock_irq(adapter->scsi_host->host_lock);
blogic_delay(2);
spin_lock_irq(adapter->scsi_host->host_lock);
Since this drops the lock using spin_unlock_irq() and busy-waits for 2
seconds, can this lead to hard IRQ re-entrancy, stack overflows, or potential
deadlocks?
[Severity: High]
This is a pre-existing issue, but is there a missing memory barrier in
blogic_write_outbox()?
drivers/scsi/BusLogic.c:blogic_write_outbox() {
...
next_outbox->ccb = ccb->dma_handle;
next_outbox->action = action;
blogic_execmbox(adapter);
...
}
Because these assignments to memory polled by DMA are not protected by a
compiler or memory barrier, can a weakly-ordered CPU reorder the stores to
next_outbox->ccb and next_outbox->action?
If the Host Adapter asynchronously polls and observes the new action code
before the CCB address is fully committed to memory, could this cause the
hardware to execute invalid or stale CCB addresses?
> static void blogic_msg(enum blogic_msglevel, char *, struct blogic_adapter *, ...);
> static int __init blogic_setup(char *);
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1785451174.git.bvanassche@acm.org?part=6
next prev parent reply other threads:[~2026-07-30 23:06 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 22:44 [PATCH v3 00/57] Enable lock context analysis for the SCSI subsystem Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 01/57] PCI: Convert to_pci_dev() into an inline function Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 02/57] scsi: scsi_debug: Prepare for enabling lock context analysis Bart Van Assche
2026-07-30 23:01 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 03/57] scsi: sg: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 04/57] scsi: st: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 05/57] scsi: BusLogic: Introduce two local variables Bart Van Assche
2026-07-30 23:01 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 06/57] scsi: BusLogic: Prepare for enabling lock context analysis Bart Van Assche
2026-07-30 23:06 ` sashiko-bot [this message]
2026-07-30 22:44 ` [PATCH v3 07/57] scsi: NCR5380: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 08/57] scsi: aacraid: " Bart Van Assche
2026-07-30 23:04 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 09/57] scsi: aic7xxx: Enable " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 10/57] scsi: aha152x: Prepare for enabling " Bart Van Assche
2026-07-30 23:18 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 11/57] scsi: aic7xxx: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 12/57] scsi: aic94xx: Enable " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 13/57] scsi: arcmsr: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 14/57] scsi: arm: " Bart Van Assche
2026-07-30 22:44 ` [PATCH v3 15/57] scsi: be2iscsi: Prepare for enabling " Bart Van Assche
2026-07-30 23:04 ` sashiko-bot
2026-07-30 22:44 ` [PATCH v3 16/57] scsi: be2iscsi: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 17/57] scsi: cxgbi: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 18/57] scsi: bfa: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 19/57] scsi: bnx2fc: " Bart Van Assche
2026-07-30 23:01 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 20/57] scsi: bnx2i: Introduce a local variable Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 21/57] scsi: bnx2i: Enable lock context analysis Bart Van Assche
2026-07-30 23:29 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 22/57] scsi: csiostor: " Bart Van Assche
2026-07-30 23:19 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 23/57] scsi: elx: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 24/57] scsi: esas2r: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 25/57] scsi: fcoe: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 26/57] scsi: fnic: " Bart Van Assche
2026-07-30 23:11 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 27/57] scsi: hisi_sas: " Bart Van Assche
2026-07-30 23:02 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 28/57] scsi: hpsa: Prepare for enabling " Bart Van Assche
2026-07-30 23:27 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 29/57] scsi: ibmvscsi: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 30/57] scsi: ibmvscsi_tgt: " Bart Van Assche
2026-07-30 23:27 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 31/57] scsi: ipr: Prepare for enabling " Bart Van Assche
2026-07-30 23:15 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 32/57] scsi: ips: " Bart Van Assche
2026-07-30 23:15 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 33/57] scsi: isci: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 34/57] scsi: libfc: " Bart Van Assche
2026-07-30 23:19 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 35/57] scsi: libiscsi: Prepare for enabling " Bart Van Assche
2026-07-30 23:17 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 36/57] scsi: libsas: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 37/57] scsi: libsas: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 38/57] scsi: lpfc: Prepare for enabling " Bart Van Assche
2026-07-30 23:09 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 39/57] scsi: megaraid_sas: " Bart Van Assche
2026-07-30 23:15 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 40/57] scsi: megaraid: Enable " Bart Van Assche
2026-07-30 23:15 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 41/57] scsi: mpt3sas: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 42/57] scsi: mvsas: " Bart Van Assche
2026-07-30 23:18 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 43/57] scsi: pcmcia: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 44/57] scsi: pm8001: " Bart Van Assche
2026-07-30 23:31 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 45/57] scsi: qedf: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 46/57] scsi: qedi: " Bart Van Assche
2026-07-30 23:17 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 47/57] scsi: qla1280: Prepare for enabling " Bart Van Assche
2026-07-30 23:19 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 48/57] scsi: qla2xxx: Enable " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 49/57] scsi: qla4xxx: " Bart Van Assche
2026-07-30 23:25 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 50/57] scsi: ufs: " Bart Van Assche
2026-07-30 23:19 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 51/57] scsi: iSCSI transport: Prepare for enabling " Bart Van Assche
2026-07-30 23:23 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 52/57] scsi: smartpqi: Enable " Bart Van Assche
2026-07-30 23:22 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 53/57] scsi: snic: " Bart Van Assche
2026-07-30 22:45 ` [PATCH v3 54/57] scsi: sym53c8xx_2: " Bart Van Assche
2026-07-30 23:27 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 55/57] scsi: core: Pass the SCSI host pointer directly Bart Van Assche
2026-07-30 23:22 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 56/57] scsi: core: Enable lock context analysis Bart Van Assche
2026-07-30 23:36 ` sashiko-bot
2026-07-30 22:45 ` [PATCH v3 57/57] scsi: core: Protect host state changes with the host lock Bart Van Assche
2026-07-30 23:32 ` 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=20260730230643.2DC131F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bvanassche@acm.org \
--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