Re: [PATCH] scsi: mpt3sas: Fix use-after-free race in event log access

From: Markus Elfring

Date: Sun Jan 18 2026 - 01:05:28 EST



> Fix by setting ioc->remove_host while holding pci_access_mutex. This
> ensures the ioctl path either completes before removal starts, or sees
> the flag and returns -EAGAIN.

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?



> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -11264,7 +11264,10 @@ static void scsih_remove(struct pci_dev *pdev)
> if (_scsih_get_shost_and_ioc(pdev, &shost, &ioc))
> return;
>
> + /* Set remove_host flag under pci_access_mutex to synchronize with ioctl path */
> + mutex_lock(&ioc->pci_access_mutex);
> ioc->remove_host = 1;
> + mutex_unlock(&ioc->pci_access_mutex);

Would it become feasible to apply a scoped_guard() call?
https://elixir.bootlin.com/linux/v6.19-rc5/source/include/linux/mutex.h#L253


>
> if (!pci_device_is_present(pdev)) {
> mpt3sas_base_pause_mq_polling(ioc);


Regards,
Markus