linux/arch/mips
Arnd Bergmann 12700c17fc uaccess: generalize access_ok()
There are many different ways that access_ok() is defined across
architectures, but in the end, they all just compare against the
user_addr_max() value or they accept anything.

Provide one definition that works for most architectures, checking
against TASK_SIZE_MAX for user processes or skipping the check inside
of uaccess_kernel() sections.

For architectures without CONFIG_SET_FS(), this should be the fastest
check, as it comes down to a single comparison of a pointer against a
compile-time constant, while the architecture specific versions tend to
do something more complex for historic reasons or get something wrong.

Type checking for __user annotations is handled inconsistently across
architectures, but this is easily simplified as well by using an inline
function that takes a 'const void __user *' argument. A handful of
callers need an extra __user annotation for this.

Some architectures had trick to use 33-bit or 65-bit arithmetic on the
addresses to calculate the overflow, however this simpler version uses
fewer registers, which means it can produce better object code in the
end despite needing a second (statically predicted) branch.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Mark Rutland <mark.rutland@arm.com> [arm64, asm-generic]
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Stafford Horne <shorne@gmail.com>
Acked-by: Dinh Nguyen <dinguyen@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2022-02-25 09:36:05 +01:00
..
alchemy mips: alchemy: remove historic comment on gpio build constraints 2021-12-16 15:48:32 +01:00
ar7 mips: ar7: convert to CONFIG_COMMON_CLK 2021-06-08 17:00:09 +02:00
ath25 mips: Bulk conversion to generic_handle_domain_irq() 2021-08-12 11:39:40 +01:00
ath79 MIPS: ath79: drop _machine_restart again 2022-01-11 16:16:52 +01:00
bcm47xx MIPS: BCM47XX: Add support for Netgear WN2500RP v1 & v2 2022-01-09 15:41:50 +01:00
bcm63xx linux-watchdog 5.17-rc1 tag 2022-01-17 08:07:57 +02:00
bmips MIPS: bmips: Remove obsolete DMA mapping support 2022-01-11 11:55:41 +01:00
boot Kbuild updates for v5.17 2022-01-19 11:15:19 +02:00
cavium-octeon MIPS: octeon: Fix missed PTR->PTR_WD conversion 2022-02-01 08:35:12 +01:00
cobalt MIPS: Remove empty prom_free_prom_memory functions 2021-01-07 17:11:33 +01:00
configs - added support for more BCM47XX based devices 2022-01-14 15:08:36 +01:00
crypto asm-generic: unaligned always use struct helpers 2021-05-10 17:50:47 +02:00
dec mips: dec: provide the correctly capitalized config CPU_R4X00 in init error message 2021-12-16 15:47:37 +01:00
fw MIPS: Remove empty prom_free_prom_memory functions 2021-01-07 17:11:33 +01:00
generic MIPS: new Kconfig option ZBOOT_LOAD_ADDRESS 2022-01-02 14:17:30 +01:00
include uaccess: generalize access_ok() 2022-02-25 09:36:05 +01:00
ingenic MIPS: Kconfig: ingenic: Ensure MACH_INGENIC_GENERIC selects all SoCs 2021-06-01 11:44:47 +02:00
jazz MIPS/jazzdma: return error code from jazz_dma_map_sg() 2021-08-09 17:13:05 +02:00
kernel MIPS: Handle address errors for accesses above CPU max virtual user address 2022-02-25 09:36:05 +01:00
kvm ARM: 2022-02-05 09:55:59 -08:00
lantiq mips: lantiq: add support for clk_set_parent() 2022-01-02 14:14:41 +01:00
lib MIPS: Fix build error due to PTR used in more places 2022-01-27 09:04:19 +01:00
loongson2ef MIPS: Loongson2ef: Remove unnecessary {as,cc}-option calls 2021-12-09 10:27:14 +01:00
loongson32 MIPS: Remove empty prom_free_prom_memory functions 2021-01-07 17:11:33 +01:00
loongson64 PCI/sysfs: Find shadow ROM before static attribute initialization 2022-01-26 10:41:21 -06:00
math-emu MIPS: Use fallthrough for arch/mips 2020-05-07 11:55:47 +02:00
mm Merge branch 'akpm' (patches from Andrew) 2022-01-20 10:41:01 +02:00
mti-malta - converted Pistachio platform to use MIPS generic kernel 2021-09-03 11:11:54 -07:00
n64 mips: Add N64 machine type 2021-01-22 11:40:00 +01:00
net Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2021-12-10 15:56:13 -08:00
pci - added support for more BCM47XX based devices 2022-01-14 15:08:36 +01:00
pic32 clkdev: remove CONFIG_CLKDEV_LOOKUP 2021-06-08 17:00:09 +02:00
power
ralink pci-v5.17-changes 2022-01-16 08:08:11 +02:00
rb532 arch: remove spurious blkdev.h includes 2021-10-18 06:17:01 -06:00
sgi-ip22 MIPS: SGI-IP22: Remove unnecessary check of GCC option 2021-12-14 10:02:40 +01:00
sgi-ip27 - Config updates for BMIPS platform 2021-11-13 09:11:33 -08:00
sgi-ip30 memblock: rename memblock_free to memblock_phys_free 2021-11-06 13:30:41 -07:00
sgi-ip32 MIPS: Allow modules to set board_be_handler 2021-11-09 16:07:26 +01:00
sibyte - Config updates for BMIPS platform 2021-11-13 09:11:33 -08:00
sni MIPS: sni: Fix the build 2021-10-18 18:09:54 +02:00
tools MIPS: tools: Fix resource leak in elf-entry.c 2020-05-24 09:29:48 +02:00
txx9 MIPS: TXX9: Remove TX4939 SoC support 2022-01-02 14:12:03 +01:00
vdso MIPS: VDSO: remove -nostdlib compiler flag 2021-11-09 16:09:37 +01:00
vr41xx MIPS: Remove empty prom_free_prom_memory functions 2021-01-07 17:11:33 +01:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kbuild.platforms MIPS: fix duplicated slashes for Platform file path 2021-11-09 16:11:52 +01:00
Kconfig bitmap patches for 5.17-rc1 2022-01-23 06:20:44 +02:00
Kconfig.debug tracing: Refactor TRACE_IRQFLAGS_SUPPORT in Kconfig 2021-08-16 11:37:21 -04:00
Makefile MIPS: Makefile: Remove "ifdef need-compiler" for Kbuild.platforms 2021-12-14 10:02:48 +01:00
Makefile.postlink