From: sashiko-bot@kernel.org
To: hyunjungg <hj351016@gmail.com>,
"Olivia Mackall" <olivia@selenic.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
linux-crypto@vger.kernel.org
Subject: Re: [PATCH] hwrng: cctrng - cancel deferred works on unbind to avoid use-after-free
Date: Sat, 07 Nov 2026 10:21:17 +0000 [thread overview]
Message-ID: <sashiko-outbox-202815@kernel.org> (raw)
In-Reply-To: <20261107100238.3542588-1-hj351016@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:
- [High] hwrng: cctrng - runtime resume before enabling runtime PM in
cctrng_probe() [1]
--
commit 8e1ce791cb06b2432af8b8abe4b88073b7383901
Author: Hyunjung Ko <hj351016@gmail.com>
hwrng: cctrng - cancel deferred works on unbind to avoid use-after-free
This commit replaces INIT_WORK() with devm_work_autocancel() for
compwork and startwork in cctrng_probe() so that pending work items are
canceled on driver unbind before drvdata is freed.
> diff --git a/drivers/char/hw_random/cctrng.c b/drivers/char/hw_random/cctrng.c
> index 03401ee59a8e8..138cc7072b023 100644
> --- a/drivers/char/hw_random/cctrng.c
> +++ b/drivers/char/hw_random/cctrng.c
[ ... ]
> @@ -497,8 +498,14 @@ static int cctrng_probe(struct platform_device *pdev)
> return dev_err_probe(dev, PTR_ERR(drvdata->clk),
> "Failed to get or enable the clock\n");
>
> - INIT_WORK(&drvdata->compwork, cc_trng_compwork_handler);
> - INIT_WORK(&drvdata->startwork, cc_trng_startwork_handler);
> + rc = devm_work_autocancel(dev, &drvdata->compwork,
> + cc_trng_compwork_handler);
> + if (rc)
> + return rc;
> + rc = devm_work_autocancel(dev, &drvdata->startwork,
> + cc_trng_startwork_handler);
> + if (rc)
> + return rc;
> spin_lock_init(&drvdata->read_lock);
>
> /* register the driver isr function */
[Severity: High]
This problem wasn't introduced by this patch, but later in cctrng_probe(),
does cc_trng_pm_get() fail with -EACCES when CONFIG_PM is enabled [1]?
drivers/char/hw_random/cctrng.c:cctrng_probe() {
...
/* init PM */
rc = cc_trng_pm_init(drvdata);
if (rc)
return dev_err_probe(dev, rc, "cc_trng_pm_init failed\n");
/* increment device's usage counter */
rc = cc_trng_pm_get(dev);
if (rc)
return dev_err_probe(dev, rc, "cc_trng_pm_get returned %x\n", rc);
...
/* All set, we can allow auto-suspend */
cc_trng_pm_go(drvdata);
...
}
cc_trng_pm_init() calls pm_runtime_set_active(), while pm_runtime_enable()
is deferred until cc_trng_pm_go() at the end of probe. When
cc_trng_pm_get() calls pm_runtime_resume_and_get(), runtime PM is still
disabled and dev->power.last_status is RPM_INVALID, so rpm_resume()
returns -EACCES and cctrng_probe() aborts.
[1] https://sashiko.dev/#/bug/linux-6da7f352-ac7d-4b81-8569-a1008cfc3400
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261107100238.3542588-1-hj351016@gmail.com?part=1
prev parent reply other threads:[~2026-11-07 10:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 10:02 [PATCH] hwrng: cctrng - cancel deferred works on unbind to avoid use-after-free hyunjungg
2026-11-07 10:21 ` sashiko-bot [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=sashiko-outbox-202815@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=hj351016@gmail.com \
--cc=linux-crypto@vger.kernel.org \
--cc=olivia@selenic.com \
--cc=sashiko-reviews@lists.linux.dev \
/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