All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/7] ARM: add vmap'ed stack support
@ 2021-11-15 11:18 Ard Biesheuvel
  2021-11-15 11:18 ` [PATCH v3 1/7] ARM: memcpy: use frame pointer as unwind anchor Ard Biesheuvel
                   ` (6 more replies)
  0 siblings, 7 replies; 36+ messages in thread
From: Ard Biesheuvel @ 2021-11-15 11:18 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Ard Biesheuvel, Russell King, Nicolas Pitre, Arnd Bergmann,
	Kees Cook, Keith Packard, Linus Walleij, Nick Desaulniers

This series enables support on ARM for vmap'ed task and IRQ stacks in
the kernel. This is an important hardening feature that terminates tasks
on inadvertent or deliberate accesses past the stack pointer, which
might otherwise go completely unnoticed.

Since having an accurate backtrace is especially important in such
cases, this series includes some enhancements to the unwinder and to
some hand rolled unwind info to increase the likelihood that a backtrace
can be generated when relying on the ARM unwinder. The frame pointer
unwinder turns out to be rather bullet proof in this context, and does
not need any such enhancements.

According to a quick survey I did, compiler generated code puts a single
stack push as the first instruction in about 2/3 of the cases, which the
unwinder can deal with after applying patch #4, even if this push
faulted because of a stack overflow. In the remaining cases, the
compiler tends to fall back to R11 or R7 as the frame pointer (on ARM
or Thumb-2, respectively), or emit partial unwind frames for the part of
the function that runs before the stack frame is set up, and the part
that runs inside the stack frame. In either case, the unwinder can deal
with such occurrences as they don't rely on the stack pointer directly.

Changes since v2:
- rebase onto v5.16-rc1
- incorporate Nico's review feedback

Changes since v1:
- handle a missed corner case in svc_entry code, and while at it,
  streamline it a bit, especially for Thumb-2, which no longer
  needs to move SP into R0 twice to do the overflow check and the
  alignment check,
- improve the memcpy patch so that we no longer need to push the frame
  pointer separately,
- add Keith's tested-by

Patches #1, #2 and #3 update the ARM asm string routines to align more
closely with the compiler's approach in terms of unwind tables,
increasing the likelihood that we can unwind them in case of a stack
overflow.

Patches #5 and #6 do some preparatory refactoring for the entry and
switch_to code, to reduce clutter in patch #7.

Patch #7 wires up the generic support, and adds the entry code to detect
and deal with stack overflows.

This series applies onto my IRQ stacks series sent out earlier:
https://lore.kernel.org/linux-arm-kernel/20211115084732.3704393-1-ardb@kernel.org/

Cc: Russell King <linux@armlinux.org.uk>
Cc: Nicolas Pitre <nico@fluxnic.net>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Kees Cook <keescook@chromium.org>
Cc: Keith Packard <keithpac@amazon.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>

Ard Biesheuvel (7):
  ARM: memcpy: use frame pointer as unwind anchor
  ARM: memmove: use frame pointer as unwind anchor
  ARM: memset: clean up unwind annotations
  ARM: unwind: disregard unwind info before stack frame is set up
  ARM: switch_to: clean up Thumb2 code path
  ARM: entry: rework stack realignment code in svc_entry
  ARM: implement support for vmap'ed stacks

 arch/arm/Kconfig                   |   1 +
 arch/arm/include/asm/page.h        |   4 +
 arch/arm/include/asm/thread_info.h |   8 ++
 arch/arm/kernel/entry-armv.S       | 121 +++++++++++++++++---
 arch/arm/kernel/entry-header.S     |  57 +++++++++
 arch/arm/kernel/irq.c              |   9 +-
 arch/arm/kernel/traps.c            |  65 ++++++++++-
 arch/arm/kernel/unwind.c           |  19 ++-
 arch/arm/kernel/vmlinux.lds.S      |   4 +-
 arch/arm/lib/copy_from_user.S      |  13 +--
 arch/arm/lib/copy_template.S       |  67 ++++-------
 arch/arm/lib/copy_to_user.S        |  13 +--
 arch/arm/lib/memcpy.S              |  13 +--
 arch/arm/lib/memmove.S             |  60 ++++------
 arch/arm/lib/memset.S              |   7 +-
 15 files changed, 324 insertions(+), 137 deletions(-)

-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2021-11-17 14:05 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-15 11:18 [PATCH v3 0/7] ARM: add vmap'ed stack support Ard Biesheuvel
2021-11-15 11:18 ` [PATCH v3 1/7] ARM: memcpy: use frame pointer as unwind anchor Ard Biesheuvel
2021-11-15 11:18 ` [PATCH v3 2/7] ARM: memmove: " Ard Biesheuvel
2021-11-15 11:18 ` [PATCH v3 3/7] ARM: memset: clean up unwind annotations Ard Biesheuvel
2021-11-15 11:18 ` [PATCH v3 4/7] ARM: unwind: disregard unwind info before stack frame is set up Ard Biesheuvel
2021-11-15 11:18 ` [PATCH v3 5/7] ARM: switch_to: clean up Thumb2 code path Ard Biesheuvel
2021-11-15 11:18 ` [PATCH v3 6/7] ARM: entry: rework stack realignment code in svc_entry Ard Biesheuvel
2021-11-15 11:18 ` [PATCH v3 7/7] ARM: implement support for vmap'ed stacks Ard Biesheuvel
2021-11-16  9:22   ` Guillaume Tucker
2021-11-16  9:22     ` Guillaume Tucker
2021-11-16 19:28     ` Ard Biesheuvel
2021-11-16 19:28       ` Ard Biesheuvel
2021-11-16 20:06       ` Russell King (Oracle)
2021-11-16 20:06         ` Russell King (Oracle)
2021-11-16 22:02         ` Ard Biesheuvel
2021-11-16 22:02           ` Ard Biesheuvel
2021-11-17  7:59           ` Tony Lindgren
2021-11-17  7:59             ` Tony Lindgren
2021-11-17  8:28             ` Ard Biesheuvel
2021-11-17  8:28               ` Ard Biesheuvel
2021-11-17  8:36               ` Tony Lindgren
2021-11-17  8:36                 ` Tony Lindgren
2021-11-17  9:03                 ` Arnd Bergmann
2021-11-17  9:03                   ` Arnd Bergmann
2021-11-17  9:07                   ` Arnd Bergmann
2021-11-17  9:07                     ` Arnd Bergmann
2021-11-17  9:08                     ` Ard Biesheuvel
2021-11-17  9:08                       ` Ard Biesheuvel
2021-11-17 10:48                       ` Ard Biesheuvel
2021-11-17 10:48                         ` Ard Biesheuvel
2021-11-17 11:12                         ` Tony Lindgren
2021-11-17 11:12                           ` Tony Lindgren
2021-11-17 11:13                           ` Ard Biesheuvel
2021-11-17 11:13                             ` Ard Biesheuvel
2021-11-17 14:03                             ` Guillaume Tucker
2021-11-17 14:03                               ` Guillaume Tucker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.