Skip to content

drivers/base: Introduce revocable

Tzung-Bi Shih driver-core linux-gpio lkml 15 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v15 Latest4 patches 1 replyIn review
  2. v145 patches 7 repliesSuperseded
  3. v133 patches 2 repliesSuperseded
Earlier versions · 12
VersionPostedPatchesRepliesStatus
v123 patches2 repliesSuperseded
v115 patches5 repliesSuperseded
v109 patches15 repliesSuperseded
v99 patches4 repliesSuperseded
v83 patches2 repliesSuperseded
v73 patches14 repliesSuperseded
v63 patches1 replySuperseded
v57 patches34 repliesSuperseded
v47 patches3 repliesSuperseded
v35 patches34 repliesSuperseded
v25 patches0 repliesSuperseded
v13 patches6 repliesSuperseded

Changes in v15 from the cover letter

- Rebase onto v7.4-rc1.
- Fix resource and kthread cleanup on error paths in KUnit tests.
- Rename revocable struct members in GPIO and reset subsystems.
- Separate patch 4 (KUnit tests for reset controller) out.

Patches in v15 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4revocable: Revocable resource managementDocumentation/driver-api/driver-model/index.rst Documentation/driver-api/driver-model/revocable.rst MAINTAINERS +3 more+977 -10 replies
2/4revocable: Add KUnit test casesMAINTAINERS drivers/base/test/Kconfig drivers/base/test/Makefile +1 more+606 -00 replies
3/4gpio: Leverage revocable for accessing struct gpio_chipdrivers/gpio/gpiolib-cdev.c drivers/gpio/gpiolib-sysfs.c drivers/gpio/gpiolib.c +1 more+156 -2430 replies
4/4reset: Leverage revocable for accessing struct reset_controller_devdrivers/reset/core.c include/linux/reset-controller.h+42 -861 reply

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by.

PatchBartosz Golaszewski
1/4T-b
2/4T-b
3/4T-b
4/4

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v15 thread

Cover letter [PATCH v15 0/4] drivers/base: Introduce revocable

This series introduces the "revocable" mechanism, a synchronization primitive designed to prevent Use-After-Free errors.

- Patch 1 introduces the revocable which is an implementation of ideas from the talk [1][2].

- Patch 2 adds KUnit test cases.

- Patch 3 transitions the UAF prevention logic within the GPIO core (gpiolib) to use the "revocable" mechanism.

The existing code aims to prevent UAF issues when the underlying GPIO chip is removed. The patch replaces that custom logic with the generic "revocable" API, which is designed to handle such lifecycle dependencies. There should be no changes in behavior.

- Patch 4 transitions the reset controller framework to use the "revocable" mechanism.

Since v9, there are two ways to manage the resource provider handle.
- Embedded allocation: patch 3 is the user.
- Dynamic allocation: patch 4 is the user.

[1] https://lpc.events/event/17/contributions/1627/
[2] https://lpc.events/event/19/contributions/2262/
---
Greg, Danilo, Rafael, Johan,

Since the revert in February, the API and lifetime model have been redesigned, and the series now has concrete in-kernel users for both embedded allocation (gpiolib in patch 3) and dynamic allocation (reset in patch 4).

Do you think this series is heading in a direction that driver-core can accept, or do you still have fundamental concerns with the approach? I would appreciate your thoughts on whether we should continue working on this series.
---
v15:
- Rebase onto v7.4-rc1.
- Fix resource and kthread cleanup on error paths in KUnit tests.
- Rename revocable struct members in GPIO and reset subsystems.
- Separate patch 4 (KUnit tests for reset controller) out.

v14: https://lore.kernel.org/all/[email protected]
- Rebase onto next-20261009.
- See changelogs in [PATCH v14 1/5] and [PATCH v14 2/5] for revocable API and KUnit test updates.
- Add patches 4 and 5 for the reset controller framework.

v13: https://lore.kernel.org/all/[email protected]
- Rebase onto next-20260911.

v12: https://lore.kernel.org/all/[email protected]
- Rebase onto next-20260907.
- Drop patch 4 and 5.

v11: https://lore.kernel.org/all/[email protected]
- Rebase onto v7.1-rc3.
- Squash patches 4 to 7 into patch 3. A single patch for GPIO.

v10: https://lore.kernel.org/all/[email protected]
- Unify handling of embedded and dynamic allocation.

v9: https://lore.kernel.org/all/[email protected]
- Rebase onto v7.1-rc1.
- Remove the selftests patch as it makes less sense to test revocable APIs via kselftests.
- Merge patches 7 to 11 from
https://lore.kernel.org/all/[email protected]
into the series.
- Merge patch from
https://lore.kernel.org/all/[email protected]
- Merge patch from
https://lore.kernel.org/all/[email protected]

v8: https://lore.kernel.org/all/[email protected]
- Rework on the revocable APIs. See changelog in [PATCH v8 1/3] for details.

v7: https://lore.kernel.org/all/[email protected]
- Rebase onto next-20260115.

v6: https://lore.kernel.org/all/[email protected]
- Rebase onto next-20251106.
- Separate revocable core and use cases.

v5: https://lore.kernel.org/all/[email protected]
- Rebase onto next-20251015.
- Add more context about the PoC.
- Support multiple revocable providers in the PoC.

v4: https://lore.kernel.org/all/[email protected]
- Rebase onto next-20250922.
- Remove the 5th patch from v3.
- Add fops replacement PoC in 5th - 7th patches.

v3: https://lore.kernel.org/all/[email protected]
- Rebase onto https://lore.kernel.org/all/[email protected]
and next-20250912.
- The 4th patch changed accordingly.

v2: https://lore.kernel.org/all/[email protected]
- Rename "ref_proxy" -> "revocable".
- Add test cases in Kunit and selftest.

v1: https://lore.kernel.org/all/[email protected]

Tzung-Bi Shih (4):
revocable: Revocable resource management
revocable: Add KUnit test cases
gpio: Leverage revocable for accessing struct gpio_chip
reset: Leverage revocable for accessing struct reset_controller_dev

 .../driver-api/driver-model/index.rst         |   1 +
 .../driver-api/driver-model/revocable.rst     | 440 +++++++++++++
 MAINTAINERS                                   |  11 +
 drivers/base/Makefile                         |   2 +-
 drivers/base/revocable.c                      | 305 +++++++++
 drivers/base/test/Kconfig                     |   5 +
 drivers/base/test/Makefile                    |   2 +
 drivers/base/test/revocable-test.c            | 598 ++++++++++++++++++
 drivers/gpio/gpiolib-cdev.c                   |  77 +--
 drivers/gpio/gpiolib-sysfs.c                  |  32 +-
 drivers/gpio/gpiolib.c                        | 262 ++++----
 drivers/gpio/gpiolib.h                        |  28 +-
 drivers/reset/core.c                          | 125 ++--
 include/linux/reset-controller.h              |   3 +
 include/linux/revocable.h                     | 220 +++++++
 15 files changed, 1781 insertions(+), 330 deletions(-)
 create mode 100644 Documentation/driver-api/driver-model/revocable.rst
 create mode 100644 drivers/base/revocable.c
 create mode 100644 drivers/base/test/revocable-test.c
 create mode 100644 include/linux/revocable.h
Signature · 1 line
2.53.0