linux/arch/riscv
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
..
boot riscv: dts: sifive unmatched: Add gpio poweroff 2022-01-20 09:37:23 -08:00
configs RISC-V: nommu_virt: Drop unused SLAB_MERGE_DEFAULT 2022-01-20 12:48:14 -08:00
errata riscv: errata: alternative: mark vendor_patch_func __initdata 2022-01-09 11:02:46 -08:00
include uaccess: generalize access_ok() 2022-02-25 09:36:05 +01:00
kernel uaccess: fix type mismatch warnings from access_ok() 2022-02-25 09:36:05 +01:00
kvm KVM/arm64 fixes for 5.17, take #2 2022-02-05 00:58:25 -05:00
lib riscv: extable: consolidate definitions 2022-01-05 17:52:47 -08:00
mm RISC-V: Do not use cpumask data structure for hartid bitmap 2022-01-20 09:27:22 -08:00
net riscv: bpf: Fix eBPF's exception tables 2022-01-19 10:50:02 -08:00
Kbuild kbuild: use more subdir- for visiting subdirectories while cleaning 2021-10-24 13:49:46 +09:00
Kconfig RISC-V Patches for the 5.17 Merge Window, Part 2 2022-01-22 09:34:49 +02:00
Kconfig.debug RISC-V: Remove EARLY_PRINTK support 2018-12-17 10:23:46 -08:00
Kconfig.erratas riscv: enable SiFive errata CIP-453 and CIP-1200 Kconfig only if CONFIG_64BIT=y 2021-05-06 09:40:13 -07:00
Kconfig.socs RISC-V: Add StarFive SoC Kconfig option 2021-11-28 20:03:34 +01:00
Makefile riscv: fix building external modules 2021-11-18 23:06:23 -08:00