From: Stanley Jhu <stanleyjhu@google.com>
To: sashiko-bot@kernel.org
Cc: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
Brian Kao <powenkao@google.com>,
Stanley Jhu <stanleyjhu@google.com>
Subject: Re: [PATCH v3] scsi: ufs: core: Keep internal commands dispatchable during error handling
Date: Sat, 12 Sep 2026 21:53:06 +0800 [thread overview]
Message-ID: <20260912135306.2324266-1-stanleyjhu@google.com> (raw)
In-Reply-To: <20260912133739.826361F00893@smtp.kernel.org>
On Sat, 12 Sep 2026 13:37:39 +0000, sashiko-bot@kernel.org wrote:
> Is it possible for hba->host->pseudo_sdev and its request_queue to be freed
> before we access it here?
If that race is reachable, it is not reachable through the code this patch
adds. The same function already dereferences a pointer that teardown frees
earlier than pseudo_sdev, and it does so before the new code runs:
drivers/ufs/core/ufshcd.c:ufshcd_err_handling_prepare() {
pm_runtime_get_sync(hba->dev);
ufshcd_rpm_get_sync(hba);
if (pm_runtime_status_suspended(&hba->ufs_device_wlun->sdev_gendev) || <-- existing
hba->is_sys_suspended) {
...
blk_mq_quiesce_tagset(&hba->host->tag_set);
blk_mq_unquiesce_queue(hba->host->pseudo_sdev->request_queue); <-- added here
}
And the pseudo device is freed last, by design:
drivers/scsi/scsi_scan.c:scsi_forget_host() {
list_for_each_entry(sdev, &shost->__devices, siblings) {
if (scsi_device_is_pseudo_dev(sdev) ||
sdev->sdev_state == SDEV_DEL)
continue;
__scsi_remove_device(sdev); /* the UFS Device WLUN goes here */
...
}
/*
* Remove the pseudo device last since it may be needed during removal
* of other SCSI devices.
*/
if (shost->pseudo_sdev)
__scsi_remove_device(shost->pseudo_sdev);
}
So any error handler run that reaches the new line has already dereferenced
ufs_device_wlun, which was freed first. The same holds for
ufshcd_err_handling_unprepare(), which only runs after prepare().
Thanks,
Stanley Jhu
prev parent reply other threads:[~2026-09-12 13:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 13:16 [PATCH v3] scsi: ufs: core: Keep internal commands dispatchable during error handling Stanley Jhu
2026-09-12 13:37 ` sashiko-bot
2026-09-12 13:53 ` Stanley Jhu [this message]
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=20260912135306.2324266-1-stanleyjhu@google.com \
--to=stanleyjhu@google.com \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.org \
--cc=powenkao@google.com \
--cc=sashiko-bot@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox