twx-linux/drivers
Danilo Krummrich f5d3ef25d2 rust: devres: get rid of Devres' inner Arc
So far Devres uses an inner memory allocation and reference count, i.e.
an inner Arc, in order to ensure that the devres callback can't run into
a use-after-free in case where the Devres object is dropped while the
devres callback runs concurrently.

Instead, use a completion in order to avoid a potential UAF: In
Devres::drop(), if we detect that we can't remove the devres action
anymore, we wait for the completion that is completed from the devres
callback. If, in turn, we were able to successfully remove the devres
action, we can just go ahead.

This, again, allows us to get rid of the internal Arc, and instead let
Devres consume an `impl PinInit<T, E>` in order to return an
`impl PinInit<Devres<T>, E>`, which enables us to get away with less
memory allocations.

Additionally, having the resulting explicit synchronization in
Devres::drop() prevents potential subtle undesired side effects of the
devres callback dropping the final Arc reference asynchronously within
the devres callback.

Reviewed-by: Benno Lossin <lossin@kernel.org>
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://lore.kernel.org/r/20250626200054.243480-4-dakr@kernel.org
[ Move '# Invariants' below '# Examples'. - Danilo ]
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-06-28 18:08:50 +02:00
..
accel Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
accessibility
acpi Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
amba
android Char/Misc/IIO pull request for 6.16-rc1 2025-06-06 11:50:47 -07:00
ata ata: ahci: Disallow LPM for Asus B550-F motherboard 2025-06-17 11:11:39 +02:00
atm atm: atmtcp: Free invalid length skb in atmtcp_c_send(). 2025-06-17 18:42:44 -07:00
auxdisplay treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
base Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
bcma
block block-6.16-20250619 2025-06-19 23:29:35 -07:00
bluetooth Including fixes from bluetooth and wireless. 2025-06-12 09:50:36 -07:00
bus treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
cache
cdrom
cdx
char treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
clk I've recently moved computers (among other things) so I'm sending this from a 2025-05-30 09:15:40 -07:00
clocksource MFD for v6.16 2025-06-03 11:53:55 -07:00
comedi treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
connector
counter Second set of Counter updates for 6.16 2025-05-24 08:29:32 +02:00
cpufreq Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
cpuidle Merge branch 'pm-cpuidle' 2025-05-30 20:21:36 +02:00
crypto treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
cxl sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
dax
dca
devfreq
dio
dma treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
dma-buf udmabuf: use sgtable-based scatterlist wrappers 2025-06-11 13:18:07 +02:00
dpll
edac EDAC/igen6: Fix NULL pointer dereference 2025-06-18 20:19:45 +02:00
eisa
extcon
firewire treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
firmware sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
fpga
fsi sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
fwctl
gnss
gpio gpio: mlxbf3: only get IRQ for device instance 0 2025-06-18 12:19:39 +02:00
gpu rust: devres: get rid of Devres' inner Arc 2025-06-28 18:08:50 +02:00
greybus treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
hid sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
hsi treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
hte
hv hyperv-next for v6.16 2025-06-03 08:39:20 -07:00
hwmon hwmon: (ltc4282) avoid repeated register write 2025-06-16 06:30:58 -07:00
hwspinlock
hwtracing coresight: updates for Linux v6.16 2025-05-22 18:04:43 +02:00
i2c Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
i3c i3c: controllers do not need to depend on I3C 2025-05-24 22:49:07 +02:00
idle intel_idle: Update arguments of mwait_idle_with_hints() 2025-06-10 21:09:28 +02:00
iio sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
infiniband sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
input sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
interconnect
iommu iommu/tegra: Fix incorrect size calculation 2025-06-13 17:02:31 +02:00
ipack
irqchip irqchip/ath79-misc: Fix missing prototypes warnings 2025-06-20 21:38:52 +02:00
isdn treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
leds sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
macintosh
mailbox treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
mcb
md treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
media sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
memory treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
memstick treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
message
mfd MFD for v6.16 2025-06-03 11:53:55 -07:00
misc sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
mmc treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
most treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
mtd Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
mux
net Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
nfc treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
ntb
nubus
nvdimm
nvme block-6.16-20250614 2025-06-14 09:25:22 -07:00
nvmem sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
of samples: rust: platform: Add property child and reference args examples 2025-06-25 17:48:41 +02:00
opp
parisc
parport treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
pci Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
pcmcia sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
peci
perf arm64 updates for 6.16 2025-05-28 14:55:35 -07:00
phy phy-for-6.16 2025-06-05 08:20:21 -07:00
pinctrl pinctrl: sunxi: dt: Consider pin base when calculating bank number from pin 2025-06-10 14:35:40 +02:00
platform Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
pmdomain
pnp
power sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
powercap
pps treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
ps3
ptp Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
pwm pwm: axi-pwmgen: Fix handling of external clock 2025-06-06 13:16:50 -07:00
rapidio Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
ras
regulator regulator: fan53555: add enable_time support and soft-start times 2025-06-16 13:26:23 +01:00
remoteproc remoteproc updates for v6.16 2025-06-02 11:04:29 -07:00
reset
rpmsg
rtc treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
s390 Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
sbus
scsi Merge 6.16-rc3 into driver-core-next 2025-06-23 07:53:36 +02:00
sh
siox
slimbus
soc soc: drivers for 6.16 2025-05-31 07:53:30 -07:00
soundwire soundwire updates for 6.16 2025-06-05 08:07:24 -07:00
spi spi: tegra210-qspi: Remove cache operations 2025-06-13 17:30:56 +01:00
spmi
ssb
staging treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
target scsi: target: Fix NULL pointer dereference in core_scsi3_decode_spec_i_port() 2025-06-16 14:35:57 -04:00
tc
tee
thermal Thermal control updates for 6.16-rc1 2025-05-27 16:28:02 -07:00
thunderbolt
tty treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
ufs Merge branch '6.16/scsi-queue' into 6.16/scsi-fixes 2025-06-09 15:34:06 -04:00
uio Char/Misc/IIO pull request for 6.16-rc1 2025-06-06 11:50:47 -07:00
usb sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
vdpa vdpa/octeon_ep: Control PCI dev enabling manually 2025-05-27 10:27:53 -04:00
vfio pci-v6.16-changes 2025-06-04 11:26:17 -07:00
vhost virtio, vhost: features, fixes 2025-05-29 08:15:35 -07:00
video sysfs: treewide: switch back to bin_attribute::read()/write() 2025-06-17 10:44:13 +02:00
virt sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
virtio virtio_rtc: Add RTC class driver 2025-05-27 10:27:54 -04:00
w1 sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
watchdog treewide, timers: Rename from_timer() to timer_container_of() 2025-06-08 09:07:37 +02:00
xen xen/x86: fix initial memory balloon target 2025-05-23 07:09:00 +02:00
zorro sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
Kconfig
Makefile