From: sashiko-bot@kernel.org
To: "Shivasharan S" <shivasharan.srikanteshwara@broadcom.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 16/37] scsi: mpt3sas: Fix page fault from stale ioc->chip after PCI error recovery
Date: Fri, 06 Nov 2026 01:22:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-200509@kernel.org> (raw)
In-Reply-To: <1793925772-1303-17-git-send-email-shivasharan.srikanteshwara@broadcom.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: mpt3sas: NULL ioc->chip dereference in teardown and reset paths
--
commit 118d4e051f29076a6276971b9fb64bd8927def06
Author: Shivasharan S <shivasharan.srikanteshwara@broadcom.com>
scsi: mpt3sas: Fix page fault from stale ioc->chip after PCI error recovery
This commit sets ioc->chip to NULL when unmapping controller resources in
mpt3sas_base_unmap_resources(), guards mpt3sas_base_mask_interrupts() and
mpt3sas_base_unmask_interrupts() against a NULL ioc->chip pointer, and skips
zero-length memory BARs in mpt3sas_base_map_resources().
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
> index 060482ba20aef..f0ed1bea64bbc 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_base.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
> @@ -1645,6 +1645,8 @@ mpt3sas_base_mask_interrupts(struct MPT3SAS_ADAPTER *ioc)
> u32 him_register;
>
> ioc->mask_interrupts = 1;
> + if (!ioc->chip)
> + return;
> him_register = ioc->base_readl(&ioc->chip->HostInterruptMask);
> him_register |= MPI2_HIM_DIM + MPI2_HIM_RIM + MPI2_HIM_RESET_IRQ_MASK;
> writel(him_register, &ioc->chip->HostInterruptMask);
> @@ -1662,6 +1664,8 @@ mpt3sas_base_unmask_interrupts(struct MPT3SAS_ADAPTER *ioc)
> {
> u32 him_register;
>
> + if (!ioc->chip)
> + return;
> him_register = ioc->base_readl(&ioc->chip->HostInterruptMask);
> him_register &= ~MPI2_HIM_RIM;
> writel(him_register, &ioc->chip->HostInterruptMask);
> @@ -3579,6 +3583,7 @@ mpt3sas_base_unmap_resources(struct MPT3SAS_ADAPTER *ioc)
>
> if (ioc->chip_phys) {
> iounmap(ioc->chip);
> + ioc->chip = NULL;
> ioc->chip_phys = 0;
> }
[Severity: High]
When mpt3sas_base_unmap_resources() sets ioc->chip = NULL (such as during
scsih_pci_error_detected() on pci_channel_io_frozen, scsih_suspend(), or when
mpt3sas_base_map_resources() fails in scsih_pci_slot_reset() or
scsih_resume()), can the surrounding teardown and reset paths still
dereference a NULL ioc->chip pointer?
In drivers/scsi/mpt3sas/mpt3sas_scsih.c, scsih_shutdown() and scsih_remove()
run several helpers right around the newly guarded
mpt3sas_base_mask_interrupts() call without checking if ioc->chip is NULL:
drivers/scsi/mpt3sas/mpt3sas_scsih.c:scsih_shutdown() {
...
if (ioc->is_aero_ioc)
mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply,
&ioc->ioc_pg1_copy);
_scsih_ir_shutdown(ioc);
_scsih_nvme_shutdown(ioc);
mpt3sas_base_mask_interrupts(ioc);
mpt3sas_base_stop_watchdog(ioc);
ioc->shost_recovery = 1;
mpt3sas_base_make_ioc_ready(ioc, SOFT_RESET);
...
}
drivers/scsi/mpt3sas/mpt3sas_scsih.c:scsih_remove() {
...
if (ioc->is_aero_ioc)
mpt3sas_config_set_ioc_pg1(ioc, &mpi_reply,
&ioc->ioc_pg1_copy);
/* release all the volumes */
_scsih_ir_shutdown(ioc);
...
}
Specifically:
1. mpt3sas_config_set_ioc_pg1() (when ioc->is_aero_ioc is set) calls
_config_request() -> mpt3sas_wait_for_ioc() -> mpt3sas_base_get_iocstate(),
which reads &ioc->chip->Doorbell in drivers/scsi/mpt3sas/mpt3sas_base.c:
s = ioc->base_readl_ext_retry(&ioc->chip->Doorbell);
2. _scsih_ir_shutdown() (when ioc->ir_firmware is set and raid_device_list is
non-empty) and _scsih_nvme_shutdown() (when pcie_device_list is non-empty)
both call ioc->put_smid_default(ioc, smid), which writes to
&ioc->chip->RequestDescriptorPostLow or
&ioc->chip->AtomicRequestDescriptorPost without checking ioc->chip or
ioc->pci_error_recovery.
3. In scsih_shutdown(), mpt3sas_base_make_ioc_ready(ioc, SOFT_RESET) is
called unconditionally without the if (ioc->chip_phys && ioc->chip) check used
in mpt3sas_base_free_resources(). Because mpt3sas_base_make_ioc_ready() only
checks ioc->pci_error_recovery and not ioc->chip, any path where ioc->chip is
NULL and ioc->pci_error_recovery is 0 (for example, after
scsih_pci_slot_reset() clears ioc->pci_error_recovery = 0 and fails
mpt3sas_base_map_resources(), or after scsih_suspend() / failed
scsih_resume()) calls mpt3sas_base_get_iocstate(ioc, 0) and dereferences
&ioc->chip->Doorbell.
4. Similarly, in mpt3sas_base_hard_reset_handler() in
drivers/scsi/mpt3sas/mpt3sas_base.c, mpt3sas_wait_for_commands_to_complete()
and mpt3sas_base_make_ioc_ready() immediately precede and follow
mpt3sas_base_mask_interrupts() and both call mpt3sas_base_get_iocstate(),
dereferencing &ioc->chip->Doorbell when ioc->chip is NULL.
Should these callers and mpt3sas_base_get_iocstate() /
mpt3sas_base_make_ioc_ready() also guard against !ioc->chip?
--
Sashiko AI review · https://sashiko.dev/#/patchset/1793925772-1303-1-git-send-email-shivasharan.srikanteshwara@broadcom.com?part=16
next prev parent reply other threads:[~2026-11-06 1:22 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 0:42 [PATCH 00/37] scsi: mpt3sas: Validate firmware/user input and fix error-path bugs Shivasharan S
2026-11-06 0:42 ` [PATCH 01/37] scsi: mpt3sas: Validate firmware-reported IOCRequestFrameSize Shivasharan S
2026-11-06 1:17 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 02/37] scsi: mpt3sas: Validate RAID configuration page length Shivasharan S
2026-11-06 1:15 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 03/37] scsi: mpt3sas: Pin Scsi_Host while an ioctl is using its ioc Shivasharan S
2026-11-06 1:19 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 04/37] scsi: mpt3sas: Fix locking and bounds checks on host_trace_buffer sysfs files Shivasharan S
2026-11-06 1:25 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 05/37] scsi: mpt3sas: Fix unlocked use of raid_device in enable_sdev_max_qd_store Shivasharan S
2026-11-06 0:42 ` [PATCH 06/37] scsi: mpt3sas: Fix invalid kfree() of fw_event_work event_data Shivasharan S
2026-11-06 0:42 ` [PATCH 07/37] scsi: mpt3sas: Validate SMP request/response length in bsg handler Shivasharan S
2026-11-06 1:17 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 08/37] scsi: mpt3sas: Validate firmware/user supplied device handles against MaxDevHandle Shivasharan S
2026-11-06 1:15 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 09/37] scsi: mpt3sas: Clamp topology/IR event entry counts to EventDataLength Shivasharan S
2026-11-06 1:13 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 10/37] scsi: mpt3sas: NULL ioc->reply_post after freeing it Shivasharan S
2026-11-06 0:42 ` [PATCH 11/37] scsi: mpt3sas: Fix port_table memory leak in _scsih_sas_port_refresh Shivasharan S
2026-11-06 0:42 ` [PATCH 12/37] scsi: mpt3sas: Fix leak and dangling pointer for io_uring_poll_queues Shivasharan S
2026-11-06 0:42 ` [PATCH 13/37] scsi: mpt3sas: Validate max_data_size in MPT3EVENTREPORT ioctl Shivasharan S
2026-11-06 0:42 ` [PATCH 14/37] scsi: mpt3sas: Fix buffer overflow in _scsih_scsi_ioc_info Shivasharan S
2026-11-06 11:16 ` kernel test robot
2026-11-06 11:30 ` kernel test robot
2026-11-06 0:42 ` [PATCH 15/37] scsi: mpt3sas: Fix Scsi_Host leak on invalid/tampered device probe Shivasharan S
2026-11-06 0:42 ` [PATCH 16/37] scsi: mpt3sas: Fix page fault from stale ioc->chip after PCI error recovery Shivasharan S
2026-11-06 1:22 ` sashiko-bot [this message]
2026-11-06 0:42 ` [PATCH 17/37] scsi: mpt3sas: Clamp ValidEntries in driver trigger page update helpers Shivasharan S
2026-11-06 1:09 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 18/37] scsi: mpt3sas: Clamp firmware reply copies to the allocated reply buffer Shivasharan S
2026-11-06 0:42 ` [PATCH 19/37] scsi: mpt3sas: Reject implausibly small MaxReplyDescriptorPostQueueDepth Shivasharan S
2026-11-06 1:17 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 20/37] scsi: mpt3sas: Validate CurrentHostPageSize before using it as a shift amount Shivasharan S
2026-11-06 1:12 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 21/37] scsi: mpt3sas: Clamp sense_length before copying into transfer_packet->sense Shivasharan S
2026-11-06 0:42 ` [PATCH 22/37] scsi: mpt3sas: Clamp num_luns in _scsih_wait_for_target_to_become_ready Shivasharan S
2026-11-06 0:42 ` [PATCH 23/37] scsi: mpt3sas: Validate phy_number in mpt3sas_transport_update_links Shivasharan S
2026-11-06 1:11 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 24/37] scsi: mpt3sas: Require CAP_SYS_RAWIO for mpt2ctl/mpt3ctl ioctls Shivasharan S
2026-11-06 0:42 ` [PATCH 25/37] scsi: mpt3sas: Fix SGE offset boundary check in _ctl_do_mpt_command Shivasharan S
2026-11-06 0:42 ` [PATCH 26/37] scsi: mpt3sas: Enforce minimum reply frame size and validate chain segment size Shivasharan S
2026-11-06 1:24 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 27/37] scsi: mpt3sas: Replace panic() with error return in hard_reset_handler Shivasharan S
2026-11-06 0:42 ` [PATCH 28/37] scsi: mpt3sas: Replace panic() calls with error returns in _config_request Shivasharan S
2026-11-06 1:18 ` sashiko-bot
2026-11-06 0:42 ` [PATCH 29/37] scsi: mpt3sas: Bound event-log copy size against reply frame size Shivasharan S
2026-11-06 0:42 ` [PATCH 30/37] scsi: mpt3sas: Add _ctl_diag_buffer_reset() helper to clear diag buffer state Shivasharan S
2026-11-06 0:42 ` [PATCH 31/37] scsi: mpt3sas: Restrict ioc_dump debugfs and replace raw ioc dump with text Shivasharan S
2026-11-06 0:42 ` [PATCH 32/37] scsi: mpt3sas: Fix out-of-bounds bit operation in _scsih_check_topo_delete_events Shivasharan S
2026-11-06 0:42 ` [PATCH 33/37] scsi: mpt3sas: Bound SMP passthrough buffer reads to actual buffer size Shivasharan S
2026-11-06 0:42 ` [PATCH 34/37] scsi: mpt3sas: Release sas_device reference on error in mpt3sas_transport_port_add Shivasharan S
2026-11-06 0:42 ` [PATCH 35/37] scsi: mpt3sas: NULL the event_log pointer after freeing it Shivasharan S
2026-11-06 0:42 ` [PATCH 36/37] scsi: mpt3sas: Bound NVMe passthrough transfer size against PRP buffer capacity Shivasharan S
2026-11-06 0:42 ` [PATCH 37/37] scsi: mpt3sas: Update driver version to 59.100.00.00 Shivasharan S
2026-11-06 1:37 ` 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-200509@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shivasharan.srikanteshwara@broadcom.com \
/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.