powerpc/signal64: Remove non-inline calls from setup_sigcontext()
authorChristopher M. Riedl <cmr@codefail.de>
Sat, 27 Feb 2021 01:12:52 +0000 (19:12 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 29 Mar 2021 01:49:46 +0000 (12:49 +1100)
commitc6c9645e37483444ec5182373455b2f22e4b1535
tree5492421e0b75322967faef954649c98272c95ffc
parent609355dfc88e2921bfcbd879300d482a9a33378e
powerpc/signal64: Remove non-inline calls from setup_sigcontext()

The majority of setup_sigcontext() can be refactored to execute in an
"unsafe" context assuming an open uaccess window except for some
non-inline function calls. Move these out into a separate
prepare_setup_sigcontext() function which must be called first and
before opening up a uaccess window. Non-inline function calls should be
avoided during a uaccess window for a few reasons:

- KUAP should be enabled for as much kernel code as possible.
  Opening a uaccess window disables KUAP which means any code
  executed during this time contributes to a potential attack
  surface.

- Non-inline functions default to traceable which means they are
  instrumented for ftrace. This adds more code which could run
  with KUAP disabled.

- Powerpc does not currently support the objtool UACCESS checks.
  All code running with uaccess must be audited manually which
  means: less code -> less work -> fewer problems (in theory).

A follow-up commit converts setup_sigcontext() to be "unsafe".

Signed-off-by: Christopher M. Riedl <cmr@codefail.de>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210227011259.11992-4-cmr@codefail.de
arch/powerpc/kernel/signal_64.c