linux/drivers/base
Tzung-Bi Shih 4d7dc4d1a6 revocable: Fix races in revocable_alloc() using RCU
There are two race conditions when allocating a revocable instance:

1. After a struct revocable_provider is revoked, the caller might still
   hold a dangling pointer to it.  A subsequent call to
   revocable_alloc() can trigger a use-after-free.
2. If revocable_provider_release() runs concurrently with
   revocable_alloc(), the memory of struct revocable_provider can be
   accessed during or after kfree().

To fix these:
- Manage the lifetime of struct revocable_provider using RCU.  Annotate
  pointers to it with __rcu and use kfree_rcu() for deallocation.
- Update revocable_alloc() to safely acquire a reference using RCU
  primitives.
- Update revocable_provider_revoke() to take a double pointer (`**rp`).
  It atomically NULLs out the caller's pointer before starting
  revocation.  This prevents the caller from holding a dangling pointer.
- Drop devm_revocable_provider_alloc().  The devm-managed model cannot
  support the required double-pointer semantic for safe pointer nulling.

Reported-by: Johan Hovold <johan@kernel.org>
Closes: https://lore.kernel.org/all/aXdy-b3GOJkzGqYo@hovoldconsulting.com/
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
Link: https://patch.msgid.link/20260129143733.45618-2-tzungbi@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-02-03 12:30:43 +01:00
..
firmware_loader Char/Misc/IIO driver updates for 6.19-rc1 2025-12-06 18:34:24 -08:00
power PM: runtime: Do not clear needs_force_resume with enabled runtime PM 2025-12-16 12:58:57 +01:00
regmap regmap: Fix race condition in hwspinlock irqsave routine 2026-01-12 12:25:29 +00:00
test drivers: base: test: Add ...find_device_by...(... NULL) tests 2024-12-24 09:48:09 +01:00
arch_numa.c arch_numa: Restore nid checks before registering a memblock with a node 2024-12-01 22:04:52 +02:00
arch_topology.c Merge 6.18-rc3 into driver-core-next 2025-10-27 08:02:50 +01:00
attribute_container.c driver core: attribute_container: change return type to void 2026-01-16 16:46:14 +01:00
auxiliary.c driver core: auxiliary bus: Optimize logic of auxiliary_match_id() 2025-09-06 20:12:36 +02:00
auxiliary_sysfs.c driver core: auxiliary bus: show auxiliary device IRQs 2024-07-11 14:17:03 -07:00
base.h driver core: fix inverted "locked" suffix of driver_match_device() 2026-02-01 22:24:25 +01:00
bus.c driver core: fix inverted "locked" suffix of driver_match_device() 2026-02-01 22:24:25 +01:00
cacheinfo.c cacheinfo: Add arch hook to compress CPU h/w id into 32 bits for cache-id 2025-07-16 15:04:27 +02:00
class.c drivers: core: remove device_link argument from class_compat_[create|remove]_link 2025-01-10 15:42:20 +01:00
component.c component: do not try to unbind unbound components 2025-04-15 18:05:40 +02:00
container.c driver core: container: make container_subsys const 2023-12-21 13:56:10 +01:00
core.c driver core: WQ_PERCPU added to alloc_workqueue users 2025-11-26 15:21:29 +01:00
cpu.c tick/nohz: Expose housekeeping CPUs in sysfs 2025-11-26 15:20:51 +01:00
dd.c driver core: fix inverted "locked" suffix of driver_match_device() 2026-02-01 22:24:25 +01:00
devcoredump.c devcoredump: Fix circular locking dependency with devcd->mutex. 2025-10-17 09:47:40 +02:00
devres.c devres: Remove unused devm_free_percpu() 2025-11-19 10:26:22 +13:00
devtmpfs.c devtmpfs: Replace simple_strtoul with kstrtoint in mount_param 2026-01-16 16:44:43 +01:00
driver.c driver core: Introduce device_iter_t for device iterating APIs 2025-01-10 15:26:12 +01:00
faux.c driver core: faux: stop using static struct device 2026-01-21 14:17:58 +01:00
firmware.c
hypervisor.c
init.c driver core: add a faux bus for use when a simple device/bus is needed 2025-02-13 16:58:51 +01:00
isa.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00
Kconfig revocable: Add Kunit test cases 2026-01-16 16:16:51 +01:00
Makefile revocable: Add Kunit test cases 2026-01-16 16:16:51 +01:00
map.c driver: base: Prefer unsigned int to bare use of unsigned 2021-07-21 17:30:09 +02:00
memory.c Significant patch series in this merge are as follows: 2025-12-05 13:52:43 -08:00
module.c drivers: base: handle module_kobject creation 2025-04-16 15:10:55 +02:00
node.c drivers/base/node: fold unregister_node() into unregister_one_node() 2025-11-16 17:28:03 -08:00
physical_location.c driver core: location: Use str_yes_no() helper function 2025-02-21 09:20:30 +01:00
physical_location.h driver core: physical_location.h remove extern from function prototypes 2023-03-24 15:35:48 +01:00
pinctrl.c
platform-msi.c platform-msi: Add msi_remove_device_irq_domain() in platform_device_msi_free_irqs_all() 2025-05-07 17:49:00 +02:00
platform.c platform: Add firmware-agnostic irq and affinity retrieval interface 2025-10-27 17:16:32 +01:00
property.c ACPI: Add support for nargs_prop in acpi_fwnode_get_reference_args() 2025-09-25 19:48:47 -06:00
revocable.c revocable: Fix races in revocable_alloc() using RCU 2026-02-03 12:30:43 +01:00
revocable_test.c revocable: Fix races in revocable_alloc() using RCU 2026-02-03 12:30:43 +01:00
soc.c driver core: mark remaining local bus_type variables as const 2023-12-21 13:56:30 +01:00
swnode.c software node: allow referencing firmware nodes 2025-11-20 16:51:48 +01:00
syscore.c syscore: Pass context data to callbacks 2025-11-14 10:01:52 +01:00
topology.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
trace.c devres: Enable trace events 2021-06-15 17:14:36 +02:00
trace.h devres: Fix page faults when tracing devres from unloaded modules 2024-10-14 08:21:09 +02:00
transport_class.c driver core: attribute_container: change return type to void 2026-01-16 16:46:14 +01:00