linux-stable/arch/arm/kernel
Linus Torvalds 0c389d89ab maccess: make get_kernel_nofault() check for minimal type compatibility
Now that we've renamed probe_kernel_address() to get_kernel_nofault()
and made it look and behave more in line with get_user(), some of the
subtle type behavior differences end up being more obvious and possibly
dangerous.

When you do

        get_user(val, user_ptr);

the type of the access comes from the "user_ptr" part, and the above
basically acts as

        val = *user_ptr;

by design (except, of course, for the fact that the actual dereference
is done with a user access).

Note how in the above case, the type of the end result comes from the
pointer argument, and then the value is cast to the type of 'val' as
part of the assignment.

So the type of the pointer is ultimately the more important type both
for the access itself.

But 'get_kernel_nofault()' may now _look_ similar, but it behaves very
differently.  When you do

        get_kernel_nofault(val, kernel_ptr);

it behaves like

        val = *(typeof(val) *)kernel_ptr;

except, of course, for the fact that the actual dereference is done with
exception handling so that a faulting access is suppressed and returned
as the error code.

But note how different the casting behavior of the two superficially
similar accesses are: one does the actual access in the size of the type
the pointer points to, while the other does the access in the size of
the target, and ignores the pointer type entirely.

Actually changing get_kernel_nofault() to act like get_user() is almost
certainly the right thing to do eventually, but in the meantime this
patch adds logit to at least verify that the pointer type is compatible
with the type of the result.

In many cases, this involves just casting the pointer to 'void *' to
make it obvious that the type of the pointer is not the important part.
It's not how 'get_user()' acts, but at least the behavioral difference
is now obvious and explicit.

Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-06-18 12:10:37 -07:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
arch_timer.c ARM: 8913/1: arch_timer: include <asm/arch_timer.h> 2019-10-27 21:14:43 +00:00
armksyms.c crypto: lib/sha1 - remove unnecessary includes of linux/cryptohash.h 2020-05-08 15:32:17 +10:00
asm-offsets.c arm: Remove 32bit KVM host support 2020-03-24 10:56:04 +00:00
atags.h ARM: mark setup_machine_tags() stub as __init __noreturn 2019-05-14 19:52:48 -07:00
atags_compat.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
atags_parse.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
atags_proc.c ARM: 8973/1: Add missing newline terminator to kernel message 2020-05-07 20:53:10 +01:00
bios32.c
bugs.c treewide: fix typos of SPDX-License-Identifier 2019-06-01 18:29:58 +02:00
cpuidle.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 159 2019-05-30 11:26:37 -07:00
crash_dump.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
debug.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
devtree.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
dma-isa.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
dma.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
early_printk.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
efi.c mm/pgtable: drop pgtable_t variable from pte_fn_t functions 2019-07-12 11:05:46 -07:00
elf.c arm32/64/elf: Split READ_IMPLIES_EXEC from executable PT_GNU_STACK 2020-04-20 19:42:19 +02:00
entry-armv.S ARM: uaccess: consolidate uaccess asm to asm/uaccess-asm.h 2020-05-03 17:30:24 +01:00
entry-common.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
entry-ftrace.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
entry-header.S ARM: uaccess: consolidate uaccess asm to asm/uaccess-asm.h 2020-05-03 17:30:24 +01:00
entry-v7m.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
fiq.c arm: fix the flush_icache_range arguments in set_fiq_handler 2020-06-08 11:05:57 -07:00
fiqasm.S
ftrace.c maccess: rename probe_kernel_{read,write} to copy_{from,to}_kernel_nofault 2020-06-17 10:57:41 -07:00
head-common.S ARM: 8914/1: NOMMU: Fix exc_ret for XIP 2019-10-10 22:23:20 +01:00
head-inflate-data.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
head-nommu.S ARM: 8914/1: NOMMU: Fix exc_ret for XIP 2019-10-10 22:23:20 +01:00
head.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
hibernate.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 194 2019-05-30 11:29:22 -07:00
hw_breakpoint.c ARM: 8927/1: ARM/hw_breakpoint: add more ARMv8 debug architecture versions support 2019-11-15 22:21:08 +00:00
hyp-stub.S arm: Remove the ability to set HYP vectors outside of the decompressor 2020-03-24 10:56:05 +00:00
insn.c
io.c
irq.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
isa.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
iwmmxt.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
jump_label.c
kgdb.c maccess: rename probe_kernel_{read,write} to copy_{from,to}_kernel_nofault 2020-06-17 10:57:41 -07:00
machine_kexec.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
Makefile Linux 5.5-rc1 2019-12-10 10:11:00 +01:00
module-plts.c ARM: 8910/1: fix missing declartion of module_frob_arch_sections 2019-10-27 21:14:38 +00:00
module.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
module.lds
opcodes.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
paravirt.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
patch.c arm/patch: Fix !MMU compile 2020-02-11 12:56:27 +01:00
perf_callchain.c
perf_event_v6.c
perf_event_v7.c ARM: 8873/1: perf: cleanup cppcheck shifting warning 2019-08-23 11:38:46 +01:00
perf_event_xscale.c
perf_regs.c
pj4-cp0.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
process.c mmap locking API: use coccinelle to convert mmap_sem rwsem call sites 2020-06-09 09:39:14 -07:00
psci_smp.c ARM: 8919/1: make unexported functions static 2019-10-31 16:58:52 +00:00
ptrace.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
reboot.c ARM: Use reboot_cpu instead of hardcoding it to 0 2020-03-25 12:59:33 +01:00
reboot.h
relocate_kernel.S ARM: 8962/1: kexec: drop invalid assembly argument 2020-03-12 11:29:02 +00:00
return_address.c ARM: 8918/2: only build return_address() if needed 2019-11-15 22:21:07 +00:00
setup.c arch/arm/setup: Drop dummy_con initialization 2020-01-14 15:29:15 +01:00
signal.c ARM: signal: Mark expected switch fall-through 2019-08-09 19:47:15 -05:00
signal.h ARM: 8920/1: share get_signal_page from signal.c to process.c 2019-10-31 16:58:53 +00:00
sigreturn_codes.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
sleep.S ARM: 8847/1: pm: fix HYP/SVC mode mismatch when MCPM is used 2019-02-26 11:32:54 +00:00
smccc-call.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 282 2019-06-05 17:36:37 +02:00
smp.c mm: don't include asm/pgtable.h if linux/mm.h is already included 2020-06-09 09:39:13 -07:00
smp_scu.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
smp_tlb.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
smp_twd.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
stacktrace.c ARM: 8948/1: Prevent OOB access in stacktrace 2020-01-25 18:18:11 +00:00
suspend.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
swp_emulate.c mmap locking API: use coccinelle to convert mmap_sem rwsem call sites 2020-06-09 09:39:14 -07:00
sys_arm.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
sys_oabi-compat.c ARM: compat: remove KERNEL_DS usage in sys_oabi_epoll_ctl() 2020-04-21 17:49:30 +01:00
tcm.c ARM: 8925/1: tcm: include <asm/tcm.h> for missing declarations 2019-10-31 16:58:56 +00:00
thumbee.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 333 2019-06-05 17:37:06 +02:00
time.c ARM/time: Replace <linux/clk-provider.h> by <linux/of_clk.h> 2020-05-15 22:54:57 +02:00
topology.c ARM: 8943/1: Fix topology setup in case of CPU hotplug for CONFIG_SCHED_MC 2019-12-06 11:51:02 +00:00
traps.c maccess: make get_kernel_nofault() check for minimal type compatibility 2020-06-18 12:10:37 -07:00
unwind.c arm: add loglvl to unwind_backtrace() 2020-06-09 09:39:10 -07:00
v7m.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
vdso.c mmap locking API: convert mmap_sem comments 2020-06-09 09:39:14 -07:00
vmlinux-xip.lds.S arm: Remove HYP/Stage-2 page-table support 2020-03-24 10:56:05 +00:00
vmlinux.lds.h arm: Remove HYP/Stage-2 page-table support 2020-03-24 10:56:05 +00:00
vmlinux.lds.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
xscale-cp0.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00