linux/arch/sparc/kernel
Mark Brown 25d4054cc9 mm: make arch_get_unmapped_area() take vm_flags by default
Patch series "mm: Care about shadow stack guard gap when getting an
unmapped area", v2.

As covered in the commit log for c44357c2e7 ("x86/mm: care about shadow
stack guard gap during placement") our current mmap() implementation does
not take care to ensure that a new mapping isn't placed with existing
mappings inside it's own guard gaps.  This is particularly important for
shadow stacks since if two shadow stacks end up getting placed adjacent to
each other then they can overflow into each other which weakens the
protection offered by the feature.

On x86 there is a custom arch_get_unmapped_area() which was updated by the
above commit to cover this case by specifying a start_gap for allocations
with VM_SHADOW_STACK.  Both arm64 and RISC-V have equivalent features and
use the generic implementation of arch_get_unmapped_area() so let's make
the equivalent change there so they also don't get shadow stack pages
placed without guard pages.  The arm64 and RISC-V shadow stack
implementations are currently on the list:

   https://lore.kernel.org/r/20240829-arm64-gcs-v12-0-42fec94743
   https://lore.kernel.org/lkml/20240403234054.2020347-1-debug@rivosinc.com/

Given the addition of the use of vm_flags in the generic implementation we
also simplify the set of possibilities that have to be dealt with in the
core code by making arch_get_unmapped_area() take vm_flags as standard. 
This is a bit invasive since the prototype change touches quite a few
architectures but since the parameter is ignored the change is
straightforward, the simplification for the generic code seems worth it.


This patch (of 3):

When we introduced arch_get_unmapped_area_vmflags() in 961148704a ("mm:
introduce arch_get_unmapped_area_vmflags()") we did so as part of properly
supporting guard pages for shadow stacks on x86_64, which uses a custom
arch_get_unmapped_area().  Equivalent features are also present on both
arm64 and RISC-V, both of which use the generic implementation of
arch_get_unmapped_area() and will require equivalent modification there. 
Rather than continue to deal with having two versions of the functions
let's bite the bullet and have all implementations of
arch_get_unmapped_area() take vm_flags as a parameter.

The new parameter is currently ignored by all implementations other than
x86.  The only caller that doesn't have a vm_flags available is
mm_get_unmapped_area(), as for the x86 implementation and the wrapper used
on other architectures this is modified to supply no flags.

No functional changes.

Link: https://lkml.kernel.org/r/20240904-mm-generic-shadow-stack-guard-v2-0-a46b8b6dc0ed@kernel.org
Link: https://lkml.kernel.org/r/20240904-mm-generic-shadow-stack-guard-v2-1-a46b8b6dc0ed@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Acked-by: Helge Deller <deller@gmx.de>	[parisc]
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Cc: Andreas Larsson <andreas@gaisler.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: Chris Zankel <chris@zankel.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Cc: Gerald Schaefer <gerald.schaefer@linux.ibm.com>
Cc: Guo Ren <guoren@kernel.org>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Cc: Matt Turner <mattst88@gmail.com>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Naveen N Rao <naveen@kernel.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Sven Schnelle <svens@linux.ibm.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: WANG Xuerui <kernel@xen0n.name>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2024-09-09 16:39:13 -07:00
..
syscalls sparc: fix compat recv/recvfrom syscalls 2024-06-25 15:57:25 +02:00
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
adi_64.c sparc64: Fix prototype warnings in adi_64.c 2024-04-22 15:33:06 +02:00
apc.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
asm-offsets.c arch: fix asm-offsets.c building with -Wmissing-prototypes 2023-11-23 11:32:31 +01:00
audit.c audit: add support for the openat2 syscall 2021-10-01 16:52:48 -04:00
auxio_32.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
auxio_64.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
btext.c sparc: Use shared font data 2024-02-16 16:49:58 +01:00
central.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
cherrs.S
chmc.c sparc: chmc: Convert to platform remove callback returning void 2024-04-22 16:51:57 +02:00
compat_audit.c audit: add support for the openat2 syscall 2021-10-01 16:52:48 -04:00
cpu.c mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
cpumap.c sparc: Annotate struct cpuinfo_tree with __counted_by 2023-10-06 13:25:17 -07:00
cpumap.h
devices.c
ds.c Normalise "name (ad@dr)" MODULE_AUTHORs to "name <ad@dr>" 2024-03-06 13:07:39 -08:00
dtlb_miss.S
dtlb_prot.S
ebus.c
entry.h sparc64: Add support for ADI register fields, ASIs and traps 2018-03-18 07:38:45 -07:00
entry.S sparc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-22 18:12:25 +09:00
etrap_32.S
etrap_64.S sparc64: Add support for ADI (Application Data Integrity) 2018-03-18 07:38:48 -07:00
fpu_traps.S
ftrace.c ftrace: Cleanup ftrace_dyn_arch_init() 2021-10-08 19:41:39 -04:00
getsetcc.S
head_32.S sparc32: Fix truncated relocation errors when linking large kernels 2024-07-11 15:58:18 +02:00
head_64.S sparc: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-22 18:12:25 +09:00
helpers.S treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
hvapi.c sparc64: Oracle DAX infrastructure 2018-01-22 08:17:15 -08:00
hvcalls.S sparc64: Oracle DAX infrastructure 2018-01-22 08:17:15 -08:00
hvtramp.S
idprom.c
iommu_common.h sparc: remove the mapping_error dma_map_ops method 2018-12-06 06:56:40 -08:00
iommu-common.c dma-mapping: introduce dma_get_seg_boundary_nr_pages() 2020-09-03 18:12:15 +02:00
iommu.c sparc/iommu: don't set failed sg dma_address to DMA_MAPPING_ERROR 2021-08-09 17:13:06 +02:00
ioport.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
irq_32.c sparc32: Fix build with trapbase 2024-03-08 21:20:23 +01:00
irq_64.c sparc/irq: Remove on-stack cpumask var 2024-05-08 19:42:15 +02:00
irq.h
itlb_miss.S
ivec.S
jump_label.c jump_label: move 'asm goto' support test to Kconfig 2019-01-06 09:46:51 +09:00
kernel.h sparc64: Fix prototype warning for uprobe_trap 2024-04-22 15:33:06 +02:00
kgdb_32.c sparc32: Fix build with trapbase 2024-03-08 21:20:23 +01:00
kgdb_64.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
kprobes.c sparc: Fix typos 2024-02-16 16:50:25 +01:00
kstack.h
ktlb.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
ldc.c sparc: Fix typos 2024-02-16 16:50:25 +01:00
led.c proc: make the proc_create[_data]() stubs static inlines 2022-01-20 08:52:52 +02:00
leon_kernel.c sparc/leon: Remove on-stack cpumask var 2024-05-08 19:42:16 +02:00
leon_pci_grpci1.c sparc32: Fix section mismatch in leon_pci_grpci 2024-03-08 21:21:00 +01:00
leon_pci_grpci2.c sparc32: Fix section mismatch in leon_pci_grpci 2024-03-08 21:21:00 +01:00
leon_pci.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
leon_pmc.c arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled 2023-01-13 11:48:15 +01:00
leon_smp.c sparc32: Fix build with trapbase 2024-03-08 21:20:23 +01:00
Makefile arch: turn off -Werror for architectures with known warnings 2023-12-10 17:21:33 -08:00
mdesc.c sparc: avoid stringop-overread errors 2021-09-15 13:42:33 -07:00
misctrap.S
module.c arch: make execmem setup available regardless of CONFIG_MODULES 2024-05-14 00:31:44 -07:00
nmi.c sparc64: NMI watchdog: fix return value of __setup handler 2024-02-16 16:50:25 +01:00
of_device_32.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
of_device_64.c sparc/of: Remove on-stack cpumask var 2024-05-08 19:42:15 +02:00
of_device_common.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
of_device_common.h
pci_common.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
pci_fire.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
pci_impl.h sparc: Fix typos 2024-02-16 16:50:25 +01:00
pci_msi.c sparc/pci_msi: Remove on-stack cpumask var 2024-05-08 19:42:15 +02:00
pci_psycho.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
pci_sabre.c sparc: Use device_get_match_data() 2024-01-19 08:08:53 -06:00
pci_schizo.c sparc: Fix typos 2024-02-16 16:50:25 +01:00
pci_sun4v_asm.S
pci_sun4v.c sparc64: Fix prototype warning for dma_4v_iotsb_bind 2024-04-22 15:33:06 +02:00
pci_sun4v.h
pci.c sparc: Fix typos 2024-02-16 16:50:25 +01:00
pcic.c PCI: Introduce pci_dev_for_each_resource() 2023-04-04 10:43:52 -05:00
pcr.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
perf_event.c sparc: Fix typos 2024-02-16 16:50:25 +01:00
pmc.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
power.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
process_32.c arch/idle: Change arch_cpu_idle() behavior: always exit with IRQs disabled 2023-01-13 11:48:15 +01:00
process_64.c TTY/Serial driver changes for 6.6-rc1 2023-09-01 09:38:00 -07:00
process.c sparc: switch to kernel_clone() 2020-08-20 13:12:58 +02:00
prom_32.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
prom_64.c sparc64: Fix number of online CPUs 2024-04-22 15:33:07 +02:00
prom_common.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
prom_irqtrans.c sparc: Fix typos 2024-02-16 16:50:25 +01:00
prom.h
psycho_common.c sparc: Fix typos 2024-02-16 16:50:25 +01:00
psycho_common.h
ptrace_32.c sparc: ptrace: user_regset_copyin_ignore() always returns 0 2022-11-15 14:30:41 -08:00
ptrace_64.c sparc: ptrace: user_regset_copyin_ignore() always returns 0 2022-11-15 14:30:41 -08:00
reboot.c sparc: Use device_type helpers to access the node type 2018-11-18 13:35:21 -08:00
rtrap_32.S sparc32: Preserve clone syscall flags argument for restarts due to signals 2021-02-18 16:15:11 -08:00
rtrap_64.S context_tracking: Split user tracking Kconfig 2022-06-29 17:04:09 -07:00
sbus.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
setup_32.c sparc32: Fix build with trapbase 2024-03-08 21:20:23 +01:00
setup_64.c sparc64: Fix number of online CPUs 2024-04-22 15:33:07 +02:00
signal32.c x86/shstk: Add user control-protection fault handler 2023-08-02 15:01:50 -07:00
signal_32.c sparc: Fix typos 2024-02-16 16:50:25 +01:00
signal_64.c sparc: Fix typos 2024-02-16 16:50:25 +01:00
sigutil_32.c Remove 'type' argument from access_ok() function 2019-01-03 18:57:57 -08:00
sigutil_64.c
sigutil.h
smp_32.c treewide: Trace IPIs sent via smp_send_reschedule() 2023-03-24 11:01:28 +01:00
smp_64.c sparc64: Fix number of online CPUs 2024-04-22 15:33:07 +02:00
sparc_ksyms.c
spiterrs.S
sstate.c kernel.h: split out panic and oops helpers 2021-07-01 11:06:04 -07:00
stacktrace.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
starfire.c
sun4d_irq.c sparc: Use of_node_name_eq for node name comparisons 2018-11-18 13:35:21 -08:00
sun4d_smp.c sparc: Unbreak the build 2022-09-29 19:21:10 -07:00
sun4m_irq.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
sun4m_smp.c sparc: Unbreak the build 2022-09-29 19:21:10 -07:00
sun4v_ivec.S
sun4v_mcd.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 482 2019-06-19 17:09:52 +02:00
sun4v_tlb_miss.S
sys32.S sparc: fix compat recv/recvfrom syscalls 2024-06-25 15:57:25 +02:00
sys_sparc32.c sparc: remove unused header file nfs_fs.h 2020-06-02 18:41:48 -07:00
sys_sparc_32.c mm: make arch_get_unmapped_area() take vm_flags by default 2024-09-09 16:39:13 -07:00
sys_sparc_64.c mm: make arch_get_unmapped_area() take vm_flags by default 2024-09-09 16:39:13 -07:00
syscalls.S sparc64: enable HAVE_COPY_THREAD_TLS 2020-06-23 10:49:54 +02:00
sysfs.c drivers/base/node: consolidate node device subsystem initialization in node_dev_init() 2022-03-22 15:57:10 -07:00
systbls_32.S sparc: syscalls: switch to generic syscalltbl.sh 2021-05-02 00:43:34 +09:00
systbls_64.S sparc: syscalls: switch to generic syscalltbl.sh 2021-05-02 00:43:34 +09:00
systbls.h sparc: get rid of asm wrapper for nis_syscall() 2018-03-20 12:05:17 -04:00
termios.c termios: start unifying non-UAPI parts of asm/termios.h 2022-09-09 10:44:34 +02:00
time_32.c sparc: Explicitly include correct DT includes 2023-08-28 13:30:57 -05:00
time_64.c sparc64: Fix prototype warning for sched_clock 2024-04-22 15:33:06 +02:00
trampoline_32.S
trampoline_64.S mm: reorder includes after introduction of linux/pgtable.h 2020-06-09 09:39:13 -07:00
traps_32.c arch: include linux/cpu.h for trap_init() prototype 2023-11-23 11:32:31 +01:00
traps_64.c sparc64: Fix prototype warnings in traps_64.c 2024-04-22 15:33:06 +02:00
tsb.S
ttable_32.S
ttable_64.S sparc64: Add support for ADI register fields, ASIs and traps 2018-03-18 07:38:45 -07:00
una_asm_32.S
una_asm_64.S
unaligned_32.c signal/sparc: si_trapno is only used with SIGILL ILL_ILLTRP 2021-07-23 13:08:57 -05:00
unaligned_64.c
uprobes.c sparc64: Fix prototype warning for uprobe_trap 2024-04-22 15:33:06 +02:00
urtt_fill.S sparc64: Add support for ADI (Application Data Integrity) 2018-03-18 07:38:48 -07:00
utrap.S
vdso.c locking/seqlock, headers: Untangle the spaghetti monster 2020-08-06 16:13:13 +02:00
vio.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00
viohs.c sparc64: viohs: Use struct_size() helper 2020-06-22 15:43:16 -07:00
visemul.c
vmlinux.lds.S objtool/idle: Validate __cpuidle code as noinstr 2023-01-13 11:48:15 +01:00
windows.c signal: Replace force_fatal_sig with force_exit_sig when in doubt 2021-11-19 09:15:58 -06:00
winfixup.S
wof.S
wuf.S