linux/drivers
Linus Torvalds 22a78a2543 Merge __{get,put}_user() removal branch
This is long over-due: the __get_user() and __put_user() functions are
entirely historical, and are never the rigth thing to use any more.  And
when mis-used (read: every case) they are not only slower than the right
thing, but also insecure because they don't check the user address
range.

Most of the usage sites have been converted long ago, but various
left-overs remained.  So this started out as a single patch that I wrote
as a "show people how to convert __{get,put}_user() to modern code".

In particular, Thomas last year implemented the very nice new scoped
user access region helpers (see commit e497310b4ffb: "uaccess: Provide
scoped user access regions") that makes the modern interfaces
particularly easy to use and really removes any excuse for the old
horrors.

That small example patch then grew to this, partly using Claude as a
glorified coccinelle script to apply the pattern to other places.

There were a few different reasons for using __put_user() and
__get_user() rather than the alternatives, but the original historical
one was performance: when doing multiple accesses off the same base
pointer, doing a single range check followed by multiple non-checked
accesses used to create smaller and faster code.

The keyword here is "used to".  It hasn't been true for years, because
the range check isn't actually the real cost these days.  The real cost
of user accesses on modern hardware is turning the user accesses on and
off in the first place (on x86, using the STAC/CLAC instructions).

Those sequences get turned into 'scoped_user_read_access() { }' blocks,
see for example that first patch in the series: "signal: use scoped user
access for old-style sigaction".

Another, historical reason for using __get_user() and friends is that
you actually want to do a kernel pointer access, but the pointer might
not be entirely reliable (typically during fault handling), so you want
to have exception handling for the kernel access.

The modern way to do that kind of non-faulting kernel access is using
"get_kernel_nofault()", but some code predates that helper existing at
all, and used __get_user() as a way to just get a memory access with
exception handling.  For that pattern, see for example "alpha: use
get_kernel_nofault() in dik_show_code()"

A third bad reason for using __get_user() and friends was that the
proper get_user() had a "might_fault()" in it, and code that ran in
atomic regions but hadn't disabled page faults would result in a
warning.  That kind of code needs to explicitly disable page faults,
because "atomic region" is not well defined at run-time and can be
invisible (eg a preempt-off region in a non-preemptible kernel).

See "vdpa_sim: disable page faults around vringh_need_notify_iotlb()"
for an example of that pattern, where the local_bh_disable() now also
grows a pagefault_disable(), which makes the normal get_user() no longer
warn about the user access in non-process context, because it can see
that the potential page fault will not cause problems.

And finally, the really nasty reason to use __get_user() and friends:
pointers that can be either kernel pointers or user pointers.  We've
gotten rid of almost all such cases, but a couple remained.  See for
example "x86/sev: Use explicit user-or-kernel accessors for #VC memory
operands".

NOTE! This series removes all __get/put_user() calls from generic code
but only does the final removal of the whole interface on x86.  Other
architectures have not been entirely converted, for a variety of reasons:

 - arm64 makes __{get,put}_user() be exactly the same as
   {get,put}_user() so it's harmless and didn't have the dangers of the
   legacy use cases.

 - any architecture that uses <asm-generic/uaccess.h> will still use
   __{get,put}_user as the underlying helper function name

 - several architectures had some legacy uses that weren't entirely
   trivial and I didn't want to extend this patch series to things that
   I don't know and that don't really matter.

but I did do a couple of the obvious "follows the exact same pattern"
just because it could be done mindlessly and automatically.

Let's see if I broke anything, but we should have done this years ago.

* uaccess-cleanups: (48 commits)
  drm/i915/gem: ignore errors on presumed_offset write-back
  powerpc/align: use get_user_instr() for a user-mode instruction
  powerpc/signal64: use scoped user access in setup_trampoline()
  powerpc/signal64: use get_user() for the single context reads
  powerpc/signal32: use get_user() for the single context reads
  KVM: PPC: Book3S HV: use get_user()/put_user() for the HPT fd
  powerpc/powernv: use get_user()/put_user() in the LPC debugfs files
  s390: use get_user()/put_user() instead of the unchecked variants
  ARM: OABI: use scoped user access in epoll_put_uevent()
  ARM: signal: stop using __put_user() for the signal frame
  ARM: signal: check the FDPIC function descriptor address
  alpha: split the prefetch check in do_page_fault() by mode
  openrisc: use get_kernel_nofault() in show_registers()
  alpha: use get_kernel_nofault() in dik_show_code()
  nios2: use scoped user access for the signal frame
  nios2: check the signal frame address before writing to it
  hexagon: use scoped user access for the signal frame
  alpha: use scoped user access when setting up signal frames
  alpha: use scoped user access in the sigreturn path
  alpha: use scoped user access in osf_sigaction()
  ...
2026-10-21 07:19:30 -10:00
..
accel accel/rocket: search every core slot when looking up a scheduler 2026-10-13 13:54:27 +02:00
accessibility braille: nbcon: Allow to use a serial console with NBCON API as Braille console 2026-10-02 10:26:42 +02:00
acpi configfs: Updates for v7.4 2026-10-20 16:25:43 -10:00
amba
android vfs-7.4-rc1.idmap 2026-10-19 17:57:49 -10:00
ata ata: libata-scsi: do not lose CHECK CONDITION for failed ATAPI commands 2026-09-30 10:42:26 +02:00
atm
auxdisplay
base Scheduler updates: 2026-10-20 12:35:35 -10:00
bcma
block xen: branch for v7.4-rc1 2026-10-20 14:33:15 -10:00
bluetooth Bluetooth: btintel_pcie: use managed IRQ teardown 2026-10-02 11:25:53 -04:00
bus
cache
cdrom
cdx
char Merge __{get,put}_user() removal branch 2026-10-21 07:19:30 -10:00
clk soc: fixes for 7.3, part 2 2026-10-08 06:44:07 +02:00
clocksource hyperv-next for v7.3-rc1 2026-08-26 16:47:40 -07:00
comedi
connector
counter
cpufreq cpufreq: intel_pstate: Fix max_freq fallback in cpufreq_update_pressure() 2026-09-29 12:23:20 +02:00
cpuidle cpuidle: dt_idle_genpd: kfree() the original name allocation 2026-09-01 17:28:56 +02:00
crypto - Report in sysfs which SEV confidential computing features are enabled in the 2026-10-20 11:31:05 -10:00
cxl cxl/pci: Add the PMUs after configuring events 2026-10-04 17:02:28 +00:00
dax
dca
devfreq treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
dibs dibs: Unregister dibs_class after error 2026-09-04 16:12:24 -07:00
dio
dma dmaengine fixes for v7.3 2026-09-20 10:45:22 -07:00
dma-buf Revert "dma-buf: Make DMABUF_DEBUG default to y on DEBUG_KERNEL kernels" 2026-10-13 19:26:28 +05:30
dpll dpll: use exact lookup for reference sync pin id 2026-09-21 17:19:42 -07:00
edac - Orphan several EDAC drivers: i82975x, x38, xgene, i3200. Those have been 2026-10-20 08:14:43 -10:00
eisa
extcon
firewire firewire: core: fix race condition in split transaction handling 2026-10-18 11:59:35 +09:00
firmware chrome-platform-firmware: Updates for v7.4 2026-10-20 15:02:13 -10:00
fpga treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
fsi
fwctl
gnss
gpib
gpio vfs-7.4-rc1.file 2026-10-19 17:35:50 -10:00
gpu Merge __{get,put}_user() removal branch 2026-10-21 07:19:30 -10:00
greybus
hid hid-for-linus-2026100201 2026-10-02 09:51:11 -07:00
hsi
hte
hv Core features: 2026-10-20 07:55:19 -10:00
hwmon hwmon: (hp-wmi-sensors) Improve raw WMI string handling 2026-09-16 17:08:19 -07:00
hwspinlock
hwtracing coresight: perf: Suppress ITRACE start records 2026-10-04 17:09:23 +00:00
i2c i2c: xiic: restore non-managed runtime PM to fix clk WARN flood 2026-10-15 22:34:34 +02:00
i3c treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
idle
iio iio: adc: ad_sigma_delta: fix use-after-free on unbind 2026-09-30 18:59:56 +01:00
infiniband RDMA v7.3 first rc pull 2026-09-14 09:58:12 -07:00
input Input updates for v7.3-rc6 2026-10-11 08:10:43 -07:00
interconnect Revert "interconnect: qcom: x1e80100: enable QoS configuration" 2026-09-16 15:55:38 +03:00
iommu s390 updates for 7.4 merge window 2026-10-20 14:28:32 -10:00
ipack
irqchip irqchip/gic-v5: Preserve ICC_CR0_EL1 state 2026-09-07 21:44:17 +02:00
leds LEDs for v7.3 2026-08-27 11:05:51 -07:00
macintosh macintosh: ans-lcd: use get_user() for reading user bytes 2026-10-20 08:07:29 -10:00
mailbox treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
mcb
md dm-integrity: validate the superblock on resume 2026-10-01 13:18:00 +02:00
media vfs-7.4-rc1.file 2026-10-19 17:35:50 -10:00
memory
memstick memstick: rtsx_usb_ms: complete requests after eject instead of dropping them 2026-09-30 17:53:31 +02:00
message
mfd treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
misc Core features: 2026-10-20 07:55:19 -10:00
mmc mmc: cavium-thunderx: destroy slot platform devices on remove 2026-09-28 17:57:23 +02:00
most
mtd ubi: use put_user() when filling the erase counter array 2026-10-19 19:24:03 -10:00
mux
net Core features: 2026-10-20 07:55:19 -10:00
nfc nfc: pn533: fix OOB read in pn533_acr122_is_rx_frame_valid() 2026-09-23 22:13:18 +02:00
ntb
nubus
nvdimm treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
nvme block-7.3-20261010 2026-10-11 09:00:33 -07:00
nvmem
of Devicetree fixes for v7.3, part 2: 2026-10-01 12:47:16 -07:00
opp OPP updates for 7.3-rc2 2026-09-09 19:03:00 +02:00
parisc
parport
pci Merge __{get,put}_user() removal branch 2026-10-21 07:19:30 -10:00
pcmcia
peci
perf Core features: 2026-10-20 07:55:19 -10:00
phy phy: mediatek: phy-mtk-hdmi-mt8195: Fix TMDS clk bit ratio setting 2026-09-13 16:05:23 +05:30
pinctrl pinctrl: sunxi: dt: do not accumulate npins across probe attempts 2026-10-12 11:30:12 +02:00
platform chrome-platform-firmware: Updates for v7.4 2026-10-20 15:02:13 -10:00
pmdomain pmdomain: rockchip: don't ignore clock lookup errors on attach 2026-09-28 15:36:50 +02:00
pnp PNP: isapnp: use put_user() in the proc read loop 2026-10-19 19:24:01 -10:00
power power sequencing fixes for v7.3 2026-10-16 08:17:30 -07:00
powercap More power management updates for 7.3-rc1 2026-08-26 14:13:26 -07:00
pps
ps3
ptp ptp: ocp: fix PCIe delay estimation calculation 2026-10-08 11:01:02 -07:00
pwm
rapidio
ras - Mark the mpc85xx and ThunderX EDAC drivers as orphaned due to lack of 2026-08-31 20:10:39 -07:00
regulator regulator: ltc3676: don't read the write-only HRST and CLIRQ registers 2026-10-06 17:59:42 +02:00
remoteproc remoteproc: qcom_q6v5_pas: Fix error masking in qcom_pas_stop() 2026-08-31 11:45:00 -05:00
resctrl - Push down into arch code the rounding of bandwidth control user values due 2026-10-20 10:11:04 -10:00
reset Mostly the usual clk driver updates and new SoC additions plus non-critical 2026-08-26 11:14:30 -07:00
rpmsg
rtc rtc: spear: initialize IRQ state before requesting alarm IRQ 2026-09-21 22:46:42 +02:00
s390 s390 updates for 7.4 merge window 2026-10-20 14:28:32 -10:00
sbus
scsi xen: branch for v7.4-rc1 2026-10-20 14:33:15 -10:00
sh
siox
slimbus
soc Core features: 2026-10-20 07:55:19 -10:00
soundwire soundwire: cadence_master: wait and cancel cdns->work before clock stop 2026-09-08 19:19:42 +05:30
spi spi: spi-fsl-lpspi: directly return ret in fsl_lpspi_transfer_one() 2026-10-15 22:37:15 +01:00
spmi
ssb
staging tty: fix saved termios reset race 2026-10-01 11:05:17 +02:00
target scsi: target: iscsi: Fix race in discovery auth updates 2026-10-13 23:08:43 -04:00
tc
tee Reject zero-sized allocations in tee_dyn_shm_alloc_helper() 2026-10-03 23:33:02 +02:00
thermal thermal: gov_step_wise: Fix stale mitigation vote with non-zero lower bounds 2026-09-22 21:16:11 +02:00
thunderbolt thunderbolt: Fixes for v7.3-rc6 2026-10-01 13:26:31 +02:00
tty printk fixes for 7.3-rc7 2026-10-06 11:32:54 +02:00
ufs SCSI fixes on 20261018 2026-10-18 09:06:02 -10:00
uio
usb usb: mtu3: Fix a double-dereference splat in TP_printk 2026-10-08 06:36:57 +02:00
vdpa vdpa_sim: disable page faults around vringh_need_notify_iotlb() 2026-10-20 08:05:08 -10:00
vfio
vhost vhost: vringh: use get_user()/put_user() for IOTLB 16-bit accesses 2026-10-20 08:06:57 -10:00
video fbdev fixes for 7.3-rc3: 2026-09-12 08:06:04 -07:00
virt configfs: Updates for v7.4 2026-10-20 16:25:43 -10:00
virtio virtio_input: stop callbacks before unregistering input device 2026-09-07 18:54:04 -04:00
w1
watchdog watchdog: da9063: fix suspend/resume handling of HW_RUNNING watchdog 2026-09-18 08:10:45 -07:00
xen Merge __{get,put}_user() removal branch 2026-10-21 07:19:30 -10:00
zorro zorro: Use assign_bit() where applicable 2026-09-27 16:20:43 +02:00
Kconfig
Makefile