linux/net
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
..
6lowpan net: 6lowpan: fix mismatched comments 2026-09-02 09:03:06 +02:00
9p
802
8021q vlan: ensure sufficient headroom in vlan_dev_hard_header() 2026-09-24 11:00:59 -07:00
atm pppoatm: ensure a writable skb header and linear data 2026-09-15 17:07:01 -07:00
batman-adv treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
bluetooth net: turn sk_peer_pid into an array indexed by pid type 2026-10-12 10:58:21 +02:00
bpf bpf: Use kvfree() in xdp_test_run_teardown() 2026-09-12 12:11:41 -07:00
bridge ipv4: validate checksum_start before completing checksum 2026-10-08 11:03:47 -07:00
can can: fix unique skb identifier regression under RPS 2026-10-01 17:05:03 +02:00
ceph libceph: remove pinning assertion in ceph_msg_data_iter_next() 2026-09-02 12:23:05 +02:00
core vfs-7.4-rc1.shared.net-next.pidfd 2026-10-19 20:32:52 -10:00
dcb
devlink devlink: fix devlink_rel reference leak when notify work is pending 2026-10-06 17:16:14 -07:00
dns_resolver keys, dns: Drop unused NUL terminator from upayload->data 2026-08-10 16:20:42 -07:00
dsa net: dsa: tag_brcm: legacy FCS: request needed tailroom 2026-09-09 13:31:08 -07:00
ethernet
ethtool net: ethtool: let tsconfig reach a PHY-only timestamp provider 2026-09-28 19:26:41 -07:00
handshake file: make struct fd_prepare const and kill its err field 2026-09-23 09:27:44 +02:00
hsr net: hsr: enable promiscuous mode on interlink port with fwd offload 2026-09-10 08:45:00 -07:00
ieee802154 ieee802154: 6lowpan: fix NULL dereference in lowpan_newlink 2026-09-02 09:54:27 +02:00
ife net/sched: act_ife: Only operate on Ethernet frames 2026-08-24 11:59:59 -07:00
ipv4 ipv4: do not warn on route notification size race 2026-10-08 11:32:36 -07:00
ipv6 calipso: keep BIG TCP payload_len in calipso_skbuff_setattr() 2026-10-15 12:50:03 +02:00
iucv net/iucv: fix the recvmsg window update 2026-08-31 15:51:22 -07:00
kcm file: make struct fd_prepare const and kill its err field 2026-09-23 09:27:44 +02:00
key
l2tp net: l2tp: do not propagate multicast notification errors 2026-08-24 11:43:28 -07:00
l3mdev
lapb
llc llc: fix skb UAF and leaks on llc_mac_hdr_init() failure 2026-09-24 11:00:59 -07:00
mac80211 wifi: mac80211: don't estimate airtime for unsupported rate widths 2026-10-07 12:46:15 +02:00
mac802154 mac802154: fix use-after-free of sdata via queued RX frames 2026-09-03 11:00:54 +02:00
mctp net/mctp: publish the mctp_dev only after it is initialised 2026-09-25 16:34:40 -07:00
mpls Summary 2026-08-20 08:46:41 -07:00
mptcp mptcp: fix bad accounting in __mptcp_subflow_push_pending() 2026-09-17 08:14:33 -07:00
ncsi net/ncsi: fix heap OOB read in NCSI_CMD_SEND_CMD payload length 2026-08-05 17:24:57 -07:00
netfilter ipv4: validate checksum_start before completing checksum 2026-10-08 11:03:47 -07:00
netlabel
netlink netlink: avoid hashing the network namespace pointer 2026-10-15 10:27:45 +02:00
nfc nfc: llcp: fix slab-out-of-bounds reads when logging service names 2026-09-23 22:13:17 +02:00
nsh
openvswitch net: openvswitch: validate transport header presence in set_ipv6_addr 2026-10-08 11:33:38 -07:00
packet net/packet: call packet_parse_headers after virtio_net_hdr_to_skb 2026-10-08 10:59:20 -07:00
phonet
psample
psp net: psp: avoid conflicts with skb->decrypted and sk_validate_xmit_skb() 2026-09-16 19:18:24 -07:00
qrtr net: qrtr: resend HELLO on MHI resume 2026-09-20 11:21:10 -07:00
rds net/rds: don't let the rdma_cm destroy an id RDS still owns on route failure 2026-10-12 18:12:03 +02:00
rfkill
rxrpc treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
sched net/sched: fix use-after-free in __tcf_action_put() 2026-10-15 13:00:02 +02:00
sctp sctp: revalidate output stream after association connect wait 2026-10-13 10:28:23 +02:00
shaper
smc net/smc: protect clcsock lifetime in smc_getname 2026-10-08 11:33:12 -07:00
strparser strparser: make sure __strp_recv isn't running before tearing down the parser 2026-10-06 18:29:12 -07:00
sunrpc treewide: refresh kmalloc_obj() conversions 2026-09-04 21:37:00 -07:00
switchdev
tipc tipc: destroy topsrv workqueues before closing connections 2026-10-02 08:20:15 +01:00
tls tls: device: fix out-of-bounds write in tls_append_frag() 2026-08-25 10:04:02 +02:00
unix vfs-7.4-rc1.shared.net-next.pidfd 2026-10-19 20:32:52 -10:00
vmw_vsock vsock: treat TCP_CLOSING as once-established 2026-10-12 16:55:20 +02:00
wireless wifi: cfg80211: preserve hidden-group beacon IE ownership 2026-09-22 10:47:54 +02:00
x25
xdp xsk: Use a 32-bit compare in xsk_map_gen_lookup 2026-09-17 10:56:16 -07:00
xfrm ipv4: validate checksum_start before completing checksum 2026-10-08 11:03:47 -07:00
compat.c net: af_unix: useful handling of LSM denials on SCM_RIGHTS 2026-08-17 18:14:52 -07:00
devres.c
Kconfig
Kconfig.debug
Makefile
socket.c Merge __{get,put}_user() removal branch 2026-10-21 07:19:30 -10:00
sysctl_net.c net: enforce net sysctl registration 2026-08-13 13:12:21 +02:00