From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796046395; b=oNjSHxr+EEcgD+z2RMJWHDOXYBfSIqOn5PZ3n6HeuQONyrTygqu11cPoQlo8jOfFJnUv 7z5IwvAnysoXnnQhJrfcBlrcGQLAFXlsH2PqloklWwjeol23tcCr91Ej7sWo1EKgNXa29 J837LU611+lHHBDbxhX6skhvxbs9evyIOF66mJ9onandgsUeTbFGkSWryUlY3/hDpfHax dlfS3aF15vaGJPRNMlW1O5OE+J46xRqbc0e2hQYmmnzMKNejQOuDU+RJH7o5FOfiB6iAI dAUkbo1FrlGohkOnTmiCnn5rpG8+K8kckWnUxSfRvFVYevg8KRXteQY9w1FbcPtVTww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796046395; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=k09fbYLOhIEtsZeEXGynmVs6SksOf+dKwoTD06MkzSQ=; b=oPDomcx69EbON0NwSyEgZ8ctgXCBJNlF4krvNsZfC0BoDrWQnSS3c0Be6Dn/hbHFOjW5 6mt4VrKIunLBJJBBdi1SX7CbzOu6MHrmy5GMiaBMgbCt0kSTqkJFhCo/uZKC7YkpxqWuY v3KPD/6Bqzz9kKbO3QCtEx0lECd5zobqJJgMFMU88UBLm6YUDB9jGeTNFye6y5ZNJvrqN r1fry+jvPFnb2XuoewRPdZB+HDarBwysUrX7jG1B1k69RpD+Y8rqaIcbCXaTYY6k3llSb tYu3eD+UopJQNmUvMfCm8pB0TF/+zLorTeXXQzwwXPhARoYtPsRdIxbF+PWsZbM/XDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nAAjK7ev; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C01B606A69B for ; Mon, 30 Nov 2026 13:46:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nAAjK7ev Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F6F81F0181E; Mon, 30 Nov 2026 13:46:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796046394; bh=k09fbYLOhIEtsZeEXGynmVs6SksOf+dKwoTD06MkzSQ=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=nAAjK7evjp4KV9+t2auF2YM6P7aKbV48M5aq7TZ4XG2iqTqAxoMc7ydHF+ENwU8nK mMS31Mp9duzTclH5YxtI3ePIP1zPhgnjyW/Lq+R/Ze5HAWh+gwIfV5uviF6SqYen4m FFhTgrWDjDgDfzgm4E/ja3OIlmE5vJH+WDYX/KoKNhN0lq62H1b1CehyZJbvCHGYSS dndvkOAMskPsYipIzrrT0/4AN/LsGldaFFdx8/MlrAeoKVuhZTG4IbkMiQV+K5btRq bhgw/iLa9fYqco1iXPYj5TGAwT77E9CUZxkztk/xE8x/S8tbXxJjXgtV7d0KUIUuT2 8xgep8GpjcSEA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v5 10/12] scsi: mpt3sas: Serialize interrupt-time sdev block with hostdata teardown Reply-To: sashiko-reviews@lists.linux.dev To: "Jeff Layton" Cc: linux-scsi@vger.kernel.org In-Reply-To: <20261130-sas-abba-v5-10-487c39d1114f@kernel.org> References: <20261130-sas-abba-v5-0-487c39d1114f@kernel.org> <20261130-sas-abba-v5-10-487c39d1114f@kernel.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 13:46:34 +0000 X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] scsi: mpt3sas: sleeping in IRQ context via shost_for_each_device() -- commit 1a4b089456cad5e9b57e64d60c29eab7e4c9da7f Author: Jeff Layton scsi: mpt3sas: Serialize interrupt-time sdev block with hostdata teardown This commit adds ioc->block_lock to serialize _scsih_block_io_device() against sdev->hostdata initialization and teardown in scsih_sdev_init() and scsih_sdev_destroy(). > diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/= mpt3sas_scsih.c > index e2973fbb8814c..de77bf0137f3b 100644 > --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c > +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c [ ... ] > @@ -4403,26 +4412,30 @@ _scsih_block_io_device(struct MPT3SAS_ADAPTER *io= c, u16 handle) > struct MPT3SAS_DEVICE *sas_device_priv_data; > struct scsi_device *sdev; > struct _sas_device *sas_device; > + unsigned long flags; > =20 > sas_device =3D mpt3sas_get_sdev_by_handle(ioc, handle); > =20 > shost_for_each_device(sdev, ioc->shost) { > + spin_lock_irqsave(&ioc->block_lock, flags); > sas_device_priv_data =3D sdev->hostdata; > if (!sas_device_priv_data) > - continue; > + goto next; > if (sas_device_priv_data->sas_target->handle !=3D handle) > - continue; > + goto next; > if (sas_device_priv_data->block) > - continue; > + goto next; > if (sas_device && sas_device->pend_sas_rphy_add) > - continue; > + goto next; > if (sas_device_priv_data->ignore_delay_remove) { > sdev_printk(KERN_INFO, sdev, > "%s skip device_block for SES handle(0x%04x)\n", > __func__, sas_device_priv_data->sas_target->handle); > - continue; > + goto next; > } > _scsih_internal_device_block(sdev, sas_device_priv_data); > +next: > + spin_unlock_irqrestore(&ioc->block_lock, flags); > } [Severity: High] Can shost_for_each_device() in _scsih_block_io_device() drop the final reference on sdev in interrupt context? shost_for_each_device() pins sdev via scsi_device_get() and releases it on the next iteration via scsi_device_put(). In the race with __scsi_remove_device() that this patch addresses, __scsi_remove_device() calls ->sdev_destroy(sdev) and immediately drops its own reference with put_device(): CPU0 CPU1 () __scsi_remove_device() _scsih_block_io_device() __scsi_iterate_devices() scsi_device_get(sdev) scsih_sdev_destroy(sdev) spin_lock_irqsave(&ioc->block_lock) sdev->hostdata =3D NULL spin_unlock_irqrestore(&ioc->block_lock) ... put_device(&sdev->sdev_gendev) spin_lock_irqsave(&ioc->block_loc= k) ... spin_unlock_irqrestore(&ioc->bloc= k_lock) __scsi_iterate_devices() scsi_device_put(sdev) scsi_device_dev_release() might_sleep() <-- sleep in= irq scsi_device_dev_release() calls might_sleep(), cancel_work_sync(), blk_put_queue() and mutex_lock(&sdev->inquiry_mutex) from hard interrupt context. Using __shost_for_each_device() under shost->host_lock avoids taking and dropping sdev references in interrupt context. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-sas-abba-v= 5-0-487c39d1114f@kernel.org?part=3D10