All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/37] scsi: mpt3sas: Validate firmware/user input and fix error-path bugs
@ 2026-11-18  9:56 Shivasharan S
  2026-11-18  9:56 ` [PATCH v2 01/37] scsi: mpt3sas: Validate firmware-reported IOCRequestFrameSize Shivasharan S
                   ` (36 more replies)
  0 siblings, 37 replies; 68+ messages in thread
From: Shivasharan S @ 2026-11-18  9:56 UTC (permalink / raw)
  To: linux-scsi, martin.petersen
  Cc: sathya.prakash, ranjan.kumar, chandrakanth.patil, sweeti.vandure,
	thenzl, mgandhi, loberman, Shivasharan S

This series hardens the mpt3sas driver against malformed firmware
data and invalid ioctl/passthrough input, and fixes a number of
locking, reference-count, memory-leak and use-after-free bugs in
the driver.

Changes in v2:
--------------
- Addressed the issues reported by the Sashiko review and the kernel
  test robot's build warning.

Patch 1:
- Handle U16 wrap and request_sz smaller than request frame plus two
  SGEs.
Patch 2:
- Reject pages larger than U16_MAX; zero the buffer with kzalloc().
Patch 3:
- Add ioc->shost check and also set ioc->shost before the ioc is added
  to mpt3sas_ioc_list.
Patch 4 (host_trace_buffer):
- Dropped the ctl_cmds.mutex locking from
  mpt3sas_process_trigger_data() to avoid the possible deadlock with
  the controller reset path; locking there will be handled in a
  separate patch.
- Reset ring_buffer_sz/offset when the trace buffer is (re)posted.
- Take ctl_cmds.mutex in host_trace_buffer_enable_show().
Patch 7 (SMP length):
- Reject request/response lengths <= 4 (previously < 4), which would
  have produced a zero-length SGE.
Patch 8 (device handles):
- Return 0 instead of -1 from _scsih_add_device() for an out-of-range
  handle.
Patch 9 (topology/IR events):
- Clamp EventDataLength to the max reply frame size;
- Reject events shorter than their header; the per-event entry counts
  are clamped to the remaining data.
Patch 14:
  - Fix -Wformat-truncation warning reported by the kernel test robot.
Patch 16:
- Added ioc->chip checks to _config_request(), make_ioc_ready,
  hard_reset_handler and the IR/NVMe shutdown helpers.
Patch 17:
- Fix signed count check for ValidEntries.
Patch 19:
- Reject hba_queue_depth values that would underflow scsiio_depth.
Patch 20:
- Fix signed overflow and bound page size to 2^12..2^16.
Patch 23:
- Validate against sas_node->num_phys rather than nr_phys_allocated.
Patch 26:
- Increase min reply_sz to sizeof(Mpi2SCSIIOReply_t) and reject
  chain segments with more than U8_MAX SGEs.
Patch 28:
- Check return value of _config_request() and return without issuing
  WRITE_NVRAM request.
Patch 36:
- Do the sg_tablesize * page_size multiplication in 64 bits.
v1: https://lore.kernel.org/linux-scsi/1793925772-1303-1-git-send-email-shivasharan.srikanteshwara@broadcom.com/

Shivasharan S (37):
  scsi: mpt3sas: Validate firmware-reported IOCRequestFrameSize
  scsi: mpt3sas: Validate RAID configuration page length
  scsi: mpt3sas: Pin Scsi_Host while an ioctl is using its ioc
  scsi: mpt3sas: Fix locking and bounds checks on host_trace_buffer
    sysfs files
  scsi: mpt3sas: Fix unlocked use of raid_device in
    enable_sdev_max_qd_store
  scsi: mpt3sas: Fix invalid kfree() of fw_event_work event_data
  scsi: mpt3sas: Validate SMP request/response length in bsg handler
  scsi: mpt3sas: Validate firmware/user supplied device handles against
    MaxDevHandle
  scsi: mpt3sas: Clamp topology/IR event entry counts to EventDataLength
  scsi: mpt3sas: NULL ioc->reply_post after freeing it
  scsi: mpt3sas: Fix port_table memory leak in _scsih_sas_port_refresh
  scsi: mpt3sas: Fix leak and dangling pointer for io_uring_poll_queues
  scsi: mpt3sas: Validate max_data_size in MPT3EVENTREPORT ioctl
  scsi: mpt3sas: Fix buffer overflow in _scsih_scsi_ioc_info
  scsi: mpt3sas: Fix Scsi_Host leak on invalid/tampered device probe
  scsi: mpt3sas: Fix page fault from stale ioc->chip after PCI error
    recovery
  scsi: mpt3sas: Clamp ValidEntries in driver trigger page update
    helpers
  scsi: mpt3sas: Clamp firmware reply copies to the allocated reply
    buffer
  scsi: mpt3sas: Reject implausibly small
    MaxReplyDescriptorPostQueueDepth
  scsi: mpt3sas: Validate CurrentHostPageSize before using it as a shift
    amount
  scsi: mpt3sas: Clamp sense_length before copying into
    transfer_packet->sense
  scsi: mpt3sas: Clamp num_luns in
    _scsih_wait_for_target_to_become_ready
  scsi: mpt3sas: Validate phy_number in mpt3sas_transport_update_links
  scsi: mpt3sas: Require CAP_SYS_RAWIO for mpt2ctl/mpt3ctl ioctls
  scsi: mpt3sas: Fix SGE offset boundary check in _ctl_do_mpt_command
  scsi: mpt3sas: Enforce minimum reply frame size and validate chain
    segment size
  scsi: mpt3sas: Replace panic() with error return in hard_reset_handler
  scsi: mpt3sas: Replace panic() calls with error returns in
    _config_request
  scsi: mpt3sas: Bound event-log copy size against reply frame size
  scsi: mpt3sas: Add _ctl_diag_buffer_reset() helper to clear diag
    buffer state
  scsi: mpt3sas: Restrict ioc_dump debugfs and replace raw ioc dump with
    text
  scsi: mpt3sas: Fix out-of-bounds bit operation in
    _scsih_check_topo_delete_events
  scsi: mpt3sas: Bound SMP passthrough buffer reads to actual buffer
    size
  scsi: mpt3sas: Release sas_device reference on error in
    mpt3sas_transport_port_add
  scsi: mpt3sas: NULL the event_log pointer after freeing it
  scsi: mpt3sas: Bound NVMe passthrough transfer size against PRP buffer
    capacity
  scsi: mpt3sas: Update driver version to 59.100.00.00

 drivers/scsi/mpt3sas/mpt3sas_base.c      | 142 +++++++++++++---
 drivers/scsi/mpt3sas/mpt3sas_base.h      |  16 +-
 drivers/scsi/mpt3sas/mpt3sas_config.c    |  95 ++++++++---
 drivers/scsi/mpt3sas/mpt3sas_ctl.c       | 201 ++++++++++++++++++----
 drivers/scsi/mpt3sas/mpt3sas_debugfs.c   |  49 +++++-
 drivers/scsi/mpt3sas/mpt3sas_scsih.c     | 203 +++++++++++++++++++----
 drivers/scsi/mpt3sas/mpt3sas_transport.c |  16 +-
 7 files changed, 608 insertions(+), 114 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 68+ messages in thread

end of thread, other threads:[~2026-11-18 11:01 UTC | newest]

Thread overview: 68+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18  9:56 [PATCH v2 00/37] scsi: mpt3sas: Validate firmware/user input and fix error-path bugs Shivasharan S
2026-11-18  9:56 ` [PATCH v2 01/37] scsi: mpt3sas: Validate firmware-reported IOCRequestFrameSize Shivasharan S
2026-11-18 10:28   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 02/37] scsi: mpt3sas: Validate RAID configuration page length Shivasharan S
2026-11-18 10:22   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 03/37] scsi: mpt3sas: Pin Scsi_Host while an ioctl is using its ioc Shivasharan S
2026-11-18 10:41   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 04/37] scsi: mpt3sas: Fix locking and bounds checks on host_trace_buffer sysfs files Shivasharan S
2026-11-18 10:37   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 05/37] scsi: mpt3sas: Fix unlocked use of raid_device in enable_sdev_max_qd_store Shivasharan S
2026-11-18 10:36   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 06/37] scsi: mpt3sas: Fix invalid kfree() of fw_event_work event_data Shivasharan S
2026-11-18 10:30   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 07/37] scsi: mpt3sas: Validate SMP request/response length in bsg handler Shivasharan S
2026-11-18 10:29   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 08/37] scsi: mpt3sas: Validate firmware/user supplied device handles against MaxDevHandle Shivasharan S
2026-11-18 10:33   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 09/37] scsi: mpt3sas: Clamp topology/IR event entry counts to EventDataLength Shivasharan S
2026-11-18  9:56 ` [PATCH v2 10/37] scsi: mpt3sas: NULL ioc->reply_post after freeing it Shivasharan S
2026-11-18 10:27   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 11/37] scsi: mpt3sas: Fix port_table memory leak in _scsih_sas_port_refresh Shivasharan S
2026-11-18 10:22   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 12/37] scsi: mpt3sas: Fix leak and dangling pointer for io_uring_poll_queues Shivasharan S
2026-11-18 10:32   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 13/37] scsi: mpt3sas: Validate max_data_size in MPT3EVENTREPORT ioctl Shivasharan S
2026-11-18 10:20   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 14/37] scsi: mpt3sas: Fix buffer overflow in _scsih_scsi_ioc_info Shivasharan S
2026-11-18 10:21   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 15/37] scsi: mpt3sas: Fix Scsi_Host leak on invalid/tampered device probe Shivasharan S
2026-11-18 10:26   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 16/37] scsi: mpt3sas: Fix page fault from stale ioc->chip after PCI error recovery Shivasharan S
2026-11-18 11:01   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 17/37] scsi: mpt3sas: Clamp ValidEntries in driver trigger page update helpers Shivasharan S
2026-11-18 10:29   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 18/37] scsi: mpt3sas: Clamp firmware reply copies to the allocated reply buffer Shivasharan S
2026-11-18 10:29   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 19/37] scsi: mpt3sas: Reject implausibly small MaxReplyDescriptorPostQueueDepth Shivasharan S
2026-11-18 10:33   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 20/37] scsi: mpt3sas: Validate CurrentHostPageSize before using it as a shift amount Shivasharan S
2026-11-18 10:33   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 21/37] scsi: mpt3sas: Clamp sense_length before copying into transfer_packet->sense Shivasharan S
2026-11-18 10:35   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 22/37] scsi: mpt3sas: Clamp num_luns in _scsih_wait_for_target_to_become_ready Shivasharan S
2026-11-18 10:32   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 23/37] scsi: mpt3sas: Validate phy_number in mpt3sas_transport_update_links Shivasharan S
2026-11-18 10:42   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 24/37] scsi: mpt3sas: Require CAP_SYS_RAWIO for mpt2ctl/mpt3ctl ioctls Shivasharan S
2026-11-18  9:56 ` [PATCH v2 25/37] scsi: mpt3sas: Fix SGE offset boundary check in _ctl_do_mpt_command Shivasharan S
2026-11-18 10:39   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 26/37] scsi: mpt3sas: Enforce minimum reply frame size and validate chain segment size Shivasharan S
2026-11-18 10:46   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 27/37] scsi: mpt3sas: Replace panic() with error return in hard_reset_handler Shivasharan S
2026-11-18  9:56 ` [PATCH v2 28/37] scsi: mpt3sas: Replace panic() calls with error returns in _config_request Shivasharan S
2026-11-18  9:56 ` [PATCH v2 29/37] scsi: mpt3sas: Bound event-log copy size against reply frame size Shivasharan S
2026-11-18 10:39   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 30/37] scsi: mpt3sas: Add _ctl_diag_buffer_reset() helper to clear diag buffer state Shivasharan S
2026-11-18  9:56 ` [PATCH v2 31/37] scsi: mpt3sas: Restrict ioc_dump debugfs and replace raw ioc dump with text Shivasharan S
2026-11-18 10:38   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 32/37] scsi: mpt3sas: Fix out-of-bounds bit operation in _scsih_check_topo_delete_events Shivasharan S
2026-11-18 10:38   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 33/37] scsi: mpt3sas: Bound SMP passthrough buffer reads to actual buffer size Shivasharan S
2026-11-18 10:40   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 34/37] scsi: mpt3sas: Release sas_device reference on error in mpt3sas_transport_port_add Shivasharan S
2026-11-18 10:51   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 35/37] scsi: mpt3sas: NULL the event_log pointer after freeing it Shivasharan S
2026-11-18  9:56 ` [PATCH v2 36/37] scsi: mpt3sas: Bound NVMe passthrough transfer size against PRP buffer capacity Shivasharan S
2026-11-18 10:47   ` sashiko-bot
2026-11-18  9:56 ` [PATCH v2 37/37] scsi: mpt3sas: Update driver version to 59.100.00.00 Shivasharan S

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.