From: sashiko-bot@kernel.org
To: "Tzung-Bi Shih" <tzungbi@kernel.org>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH v16 4/4] reset: Leverage revocable for accessing struct reset_controller_dev
Date: Tue, 01 Dec 2026 13:15:05 +0000 [thread overview]
Message-ID: <sashiko-outbox-243364@kernel.org> (raw)
In-Reply-To: <20261201130303.14530-5-tzungbi@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] reset: race in reset_controller_unregister() breaks
reset_control_acquire()
--
commit 898d975d7b1e8a5978d7e104db12ced65e4b60a4
Author: Tzung-Bi Shih <tzungbi@kernel.org>
reset: Leverage revocable for accessing struct reset_controller_dev
This commit replaces the per-handle SRCU instances in struct reset_control
with a single reference-counted struct revocable allocated per
reset_controller_dev.
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index 0bff49d9b5586..afc17a3c698af 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
[ ... ]
> @@ -197,27 +197,29 @@ void reset_controller_unregister(struct reset_controller_dev *rcdev)
> * Numb but don't free the remaining reset control handles that are
> * still held by consumers.
> *
> - * Hold a temporary reference on rstc before clearing rstc->rcdev:
> - * once rstc->rcdev is NULL, a concurrent reset_control_put_internal()
> - * will not acquire rcdev->lock and could otherwise free rstc.
> + * Hold a temporary reference on rstc before revocable_revoke():
> + * once revocable_revoke() clears the resource pointer, a concurrent
> + * reset_control_put_internal() will not acquire rcdev->lock and
> + * could otherwise free rstc.
> */
> list_for_each_entry_safe(rstc, pos, &rcdev->reset_control_head, list) {
> kref_get(&rstc->refcnt);
> - rcu_assign_pointer(rstc->rcdev, NULL);
> list_move(&rstc->list, &reset_control_head);
> }
> }
>
> /*
> - * Run synchronize_srcu() outside rcdev->lock to avoid a circular
> + * Run revocable_revoke() outside rcdev->lock to avoid a circular
> * locking dependency with paths that acquire rcdev->lock inside
> - * the rstc->srcu read-side critical section.
> + * the revocable access critical section.
> */
> + revocable_revoke(rcdev->revocable);
> + revocable_put(rcdev->revocable);
[Severity: Medium]
Can moving all handles off rcdev->reset_control_head before
revocable_revoke() allow a concurrent reset_control_acquire() to succeed
on an already-acquired exclusive reset line?
Previously, rcu_assign_pointer(rstc->rcdev, NULL) was executed under
rcdev->lock alongside list_move(). Now the resource pointer is not
cleared until revocable_revoke() runs after rcdev->lock is dropped:
CPU0 CPU1
reset_controller_unregister() reset_control_acquire(rstc)
revocable_try_access_or_return()
// gets valid rcdev
lock(&rcdev->lock)
list_move(&rstc->list, ...)
unlock(&rcdev->lock)
lock(&rcdev->lock)
// rcdev->reset_control_head is empty
rstc->acquired = true; <-- bypasses check
unlock(&rcdev->lock)
revocable_revoke(rcdev->revocable)
Because rcdev->reset_control_head has already been emptied,
reset_control_acquire() does not see the other exclusive handle with
rc->acquired == true and returns 0 instead of -EBUSY. If the second
consumer then calls reset_control_reset(), reset_control_assert(), or
reset_control_deassert() before revocable_revoke() clears the pointer, it
can also manipulate the reset line while the first consumer still holds
exclusive control.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201130303.14530-1-tzungbi@kernel.org?part=4
prev parent reply other threads:[~2026-12-01 13:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 13:02 [PATCH v16 0/4] drivers/base: Introduce revocable Tzung-Bi Shih
2026-12-01 13:03 ` [PATCH v16 1/4] revocable: Revocable resource management Tzung-Bi Shih
2026-12-01 13:17 ` sashiko-bot
2026-12-01 13:03 ` [PATCH v16 2/4] revocable: Add KUnit test cases Tzung-Bi Shih
2026-12-01 13:03 ` [PATCH v16 3/4] gpio: Leverage revocable for accessing struct gpio_chip Tzung-Bi Shih
2026-12-01 13:03 ` [PATCH v16 4/4] reset: Leverage revocable for accessing struct reset_controller_dev Tzung-Bi Shih
2026-12-01 13:15 ` 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-243364@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tzungbi@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 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.