linux/arch/arm
Ard Biesheuvel e3cf20e5c6 ARM: 9405/1: ftrace: Don't assume stack frames are contiguous in memory
The frame pointer unwinder relies on a standard layout of the stack
frame, consisting of (in downward order)

   Calling frame:
     PC   <---------+
     LR             |
     SP             |
     FP             |
     .. locals ..   |
   Callee frame:    |
     PC             |
     LR             |
     SP             |
     FP   ----------+

where after storing its previous value on the stack, FP is made to point
at the location of PC in the callee stack frame, using the canonical
prologue:

   mov     ip, sp
   stmdb   sp!, {fp, ip, lr, pc}
   sub     fp, ip, #4

The ftrace code assumes that this activation record is pushed first, and
that any stack space for locals is allocated below this. Strict
adherence to this would imply that the caller's value of SP at the time
of the function call can always be obtained by adding 4 to FP (which
points to PC in the callee frame).

However, recent versions of GCC appear to deviate from this rule, and so
the only reliable way to obtain the caller's value of SP is to read it
from the activation record. Since this involves a read from memory
rather than simple arithmetic, we need to use the uaccess API here which
protects against inadvertent data aborts resulting from attempts to
dereference bogus FP values.

The plain uaccess API is ftrace instrumented itself, so to avoid
unbounded recursion, use the __get_kernel_nofault() primitive directly.

Closes: https://lore.kernel.org/all/alp44tukzo6mvcwl4ke4ehhmojrqnv6xfcdeuliybxfjfvgd3e@gpjvwj33cc76

Closes: https://lore.kernel.org/all/d870c149-4363-43de-b0ea-7125dec5608e@broadcom.com/

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reported-by: Justin Chen <justin.chen@broadcom.com>
Tested-by: Thorsten Scherer <t.scherer@eckelmann.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
2024-06-10 12:00:27 +01:00
..
boot soc: devicetree updates for v6.10, part 2 2024-05-20 15:11:53 -07:00
common locomo: make locomo_bus_type constant and static 2024-01-04 14:38:57 +01:00
configs USB / Thunderbolt changes for 6.10-rc1 2024-05-22 11:40:09 -07:00
crypto crypto: arm/sha - fix function cast warnings 2024-02-24 08:41:19 +08:00
include - A series ("kbuild: enable more warnings by default") from Arnd 2024-05-22 18:59:29 -07:00
kernel ARM: 9405/1: ftrace: Don't assume stack frames are contiguous in memory 2024-06-10 12:00:27 +01:00
lib ARM: crypto: use CC_FLAGS_FPU for NEON CFLAGS 2024-05-19 14:36:17 -07:00
mach-actions
mach-alpine ARM: alpine: Drop unused includes 2023-08-12 10:30:59 +02:00
mach-artpec
mach-aspeed
mach-at91 ARM: at91: pm: set soc_pm.data.mode in at91_pm_secure_init() 2023-11-19 11:32:44 +02:00
mach-axxia
mach-bcm ARM: bcm: stop selecing CONFIG_TICK_ONESHOT 2024-02-28 10:32:25 -08:00
mach-berlin ARM: berlin: Drop unused includes 2023-08-12 10:30:59 +02:00
mach-clps711x
mach-davinci ARM updates for v6.8-rc1 2024-01-17 11:34:45 -08:00
mach-digicolor
mach-dove ARM: dove: Drop unused includes 2023-08-12 10:30:59 +02:00
mach-ep93xx ARM: ep93xx: Add terminator to gpiod_lookup_table 2024-02-20 17:19:49 +01:00
mach-exynos
mach-footbridge
mach-gemini
mach-highbank
mach-hisi
mach-hpe ARM: hpe: Drop unused includes 2023-08-12 10:30:59 +02:00
mach-imx ARM: imx: Assign parents for mmdc event_source devices 2024-04-22 13:41:58 +08:00
mach-ixp4xx
mach-keystone ARM: keystone: Merge PM function into main support file 2023-08-01 23:57:28 -05:00
mach-lpc18xx
mach-lpc32xx
mach-mediatek
mach-meson ARM: meson: Drop unused includes 2023-07-31 11:58:18 +02:00
mach-milbeaut
mach-mmp ARM: mmp: Drop unused includes 2023-08-12 10:31:00 +02:00
mach-mstar
mach-mv78xx0
mach-mvebu ARM: mvebu: Explicitly include correct DT includes 2023-08-12 10:31:00 +02:00
mach-mxs ARM: mxs: Do not search for "fsl,clkctrl" 2023-12-06 11:21:43 +08:00
mach-nomadik ARM: nomadik: Drop unused includes 2023-08-12 10:31:00 +02:00
mach-npcm ARM: npcm: Drop unused includes 2023-08-12 10:31:00 +02:00
mach-omap1 ARM: omap1: remove duplicated 'select ARCH_OMAP' 2024-02-28 09:27:20 +02:00
mach-omap2 GPIO regression fixes for n8x0 2024-04-09 16:17:37 +02:00
mach-orion5x ARM: orion5x: Convert TS409 board to GPIO descriptors for LEDs 2024-05-05 18:18:18 +02:00
mach-pxa gpio updates for v6.10-rc1 2024-05-14 15:07:07 -07:00
mach-qcom ARM: qcom: merge remaining subplatforms into sensible Kconfig entry 2024-02-06 15:00:02 -06:00
mach-realtek
mach-rockchip ARM: rockchip: Drop unused includes 2023-08-12 10:31:00 +02:00
mach-rpc
mach-s3c kbuild: use $(src) instead of $(srctree)/$(src) for source directory 2024-05-10 04:34:52 +09:00
mach-s5pv210 ARM: s5pv210: fix pm.c kernel-doc warning 2024-01-22 11:44:16 +01:00
mach-sa1100 ARM: sa1100: Open code gpio_request_array() 2024-04-03 13:07:29 +02:00
mach-shmobile ARM: shmobile: sh73a0: Reserve boot area when SMP is enabled 2023-09-27 11:00:27 +02:00
mach-socfpga
mach-spear ARM: spear: Explicitly include correct DT includes 2023-08-12 10:31:01 +02:00
mach-sti ARM: sti: Drop unused includes 2023-08-12 10:30:59 +02:00
mach-stm32 firewall: introduce stm32_firewall framework 2024-04-05 16:49:14 +02:00
mach-sunxi ARM: sun9i: smp: fix return code check of of_property_match_string 2024-01-02 16:45:16 +01:00
mach-tegra
mach-ux500
mach-versatile ARM: Delete ARM11MPCore (ARM11 ARMv6K SMP) support 2023-12-22 11:43:16 +00:00
mach-vt8500
mach-zynq ARM: zynq: Remove clk/zynq.h header 2024-01-22 14:22:10 +01:00
mm The usual shower of singleton fixes and minor series all over MM, 2024-05-19 09:21:03 -07:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-05-02 12:06:25 -07:00
nwfpe
plat-orion kbuild: use $(src) instead of $(srctree)/$(src) for source directory 2024-05-10 04:34:52 +09:00
probes
tools mseal: wire up mseal syscall 2024-05-23 19:40:26 -07:00
vdso Makefile: remove redundant tool coverage variables 2024-05-14 23:35:48 +09:00
vfp ARM: 9327/1: vfp: Add missing VFP instructions to neon_support_hook 2023-12-05 11:40:27 +00:00
xen arm/xen: fix xen_vcpu_info allocation alignment 2023-11-23 09:32:41 +01:00
Kbuild kbuild: use $(src) instead of $(srctree)/$(src) for source directory 2024-05-10 04:34:52 +09:00
Kconfig The usual shower of singleton fixes and minor series all over MM, 2024-05-19 09:21:03 -07:00
Kconfig-nommu
Kconfig.assembler
Kconfig.debug ARM updates for v6.9-rc1 2024-03-23 09:17:03 -07:00
Kconfig.platforms ARM: mach-nspire: Rework support and directory structure 2023-12-22 14:23:30 +00:00
Makefile ARM: implement ARCH_HAS_KERNEL_FPU_SUPPORT 2024-05-19 14:36:17 -07:00