All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yaohan Li" <shunsheng1218@gmail.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: ufs: core: disable exception work before removing hwmon
Date: Thu, 26 Nov 2026 11:22:43 +0000	[thread overview]
Message-ID: <sashiko-outbox-235373@kernel.org> (raw)
In-Reply-To: <20261126111400.2828356-1-shunsheng1218@gmail.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] scsi: ufs: core: use-after-free in
  ufshcd_rpm_dev_flush_recheck_work() [1]
--

commit a1077f0758756bac493f25126be2d29218ae49d7
Author: Yaohan Li <shunsheng1218@gmail.com>

scsi: ufs: core: disable exception work before removing hwmon

This commit calls disable_work_sync(&hba->eeh_work) in ufshcd_remove()
before unregistering hwmon so that running or newly queued exception work
cannot access the freed hwmon device.

> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 00a7637a1487d..f2a132c27fa0e 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -11024,6 +11024,7 @@ void ufshcd_remove(struct ufs_hba *hba)
>  {
>  	if (hba->ufs_device_wlun)
>  		ufshcd_rpm_get_sync(hba);
> +	disable_work_sync(&hba->eeh_work);

[Severity: Critical]
This problem wasn't introduced by this patch, but can
ufshcd_rpm_dev_flush_recheck_work() trigger a use-after-free on hba during
ufshcd_remove() [1]?

ufshcd_rpm_get_sync() resumes the device via __ufshcd_wl_resume(), which
only calls asynchronous cancel_delayed_work() on
hba->rpm_dev_flush_recheck_work:

drivers/ufs/core/ufshcd.c:__ufshcd_wl_resume() {
	...
	if (hba->dev_info.b_rpm_dev_flush_capable) {
		hba->dev_info.b_rpm_dev_flush_capable = false;
		cancel_delayed_work(&hba->rpm_dev_flush_recheck_work);
	}
	...
}

Because ufshcd_remove() does not call cancel_delayed_work_sync() on
hba->rpm_dev_flush_recheck_work, an already running worker can outlive
host teardown:

CPU0                                CPU1
ufshcd_remove()
                                    ufshcd_rpm_dev_flush_recheck_work()
  ufshcd_rpm_get_sync(hba)
    __ufshcd_wl_resume()
      cancel_delayed_work(...)
  ...
  // hba is torn down and freed
                                      ufshcd_rpm_put_sync(hba)  <-- use-after-free

[1] https://sashiko.dev/#/bug/linux-6d2939f8-3e6b-4a28-a988-2094ecabbec6

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126111400.2828356-1-shunsheng1218@gmail.com?part=1

  reply	other threads:[~2026-11-26 11:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 11:14 [PATCH] scsi: ufs: core: disable exception work before removing hwmon Yaohan Li
2026-11-26 11:22 ` sashiko-bot [this message]
2026-11-26 18:09 ` Bean Huo
2026-11-27  7:25 ` [PATCH v2] " Yaohan Li
2026-11-29 15:27   ` Bean Huo
2026-11-29 16:37   ` Bart Van Assche
2026-11-30 13:27     ` Yaohan Li

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=sashiko-outbox-235373@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shunsheng1218@gmail.com \
    /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 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.