linux/drivers/scsi/smartpqi
Mike McGowen 1a5c5a2f88 scsi: smartpqi: Fix device resources accessed after device removal
[ Upstream commit b518e86d1a ]

Correct possible race conditions during device removal.

Previously, a scheduled work item to reset a LUN could still execute
after the device was removed, leading to use-after-free and other
resource access issues.

This race condition occurs because the abort handler may schedule a LUN
reset concurrently with device removal via sdev_destroy(), leading to
use-after-free and improper access to freed resources.

  - Check in the device reset handler if the device is still present in
    the controller's SCSI device list before running; if not, the reset
    is skipped.

  - Cancel any pending TMF work that has not started in sdev_destroy().

  - Ensure device freeing in sdev_destroy() is done while holding the
    LUN reset mutex to avoid races with ongoing resets.

Fixes: 2d80f4054f ("scsi: smartpqi: Update deleting a LUN via sysfs")
Reviewed-by: Scott Teel <scott.teel@microchip.com>
Reviewed-by: Scott Benesh <scott.benesh@microchip.com>
Signed-off-by: Mike McGowen <mike.mcgowen@microchip.com>
Signed-off-by: Don Brace <don.brace@microchip.com>
Link: https://patch.msgid.link/20251106163823.786828-3-don.brace@microchip.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2025-12-18 14:02:53 +01:00
..
Kconfig scsi: smartpqi: Update copyright to 2023 2023-05-08 07:17:12 -04:00
Makefile scsi: smartpqi: add spdx 2019-03-18 16:48:28 -04:00
smartpqi.h scsi: smartpqi: add counter for parity write stream requests 2024-08-28 22:10:34 -04:00
smartpqi_init.c scsi: smartpqi: Fix device resources accessed after device removal 2025-12-18 14:02:53 +01:00
smartpqi_sas_transport.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
smartpqi_sis.c move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00
smartpqi_sis.h scsi: smartpqi: Add fw log to kdump 2024-08-28 22:10:34 -04:00