All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sami Tolvanen <samitolvanen@google.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com,
	will@kernel.org, mark.rutland@arm.com, maz@kernel.org
Subject: Re: [PATCH v4 0/3] arm64: dynamic shadow call stack support
Date: Thu, 7 Jul 2022 12:35:58 -0700	[thread overview]
Message-ID: <Ysc1W6q8FZkvx3hA@google.com> (raw)
In-Reply-To: <20220701152724.3343599-1-ardb@kernel.org>

Hi Ard,

On Fri, Jul 01, 2022 at 05:27:21PM +0200, Ard Biesheuvel wrote:
> Generic kernel images such as Android's GKI usually enable all available
> security features, which are typically implemented in such a way that
> they only take effect if the underlying hardware can support it, but
> don't interfere with correct and efficient operation otherwise.
> 
> For shadow call stack support, which is always supported by the
> hardware, it means it will be enabled even if pointer authentication is
> also supported, and enabled for signing return addresses stored on the
> stack. The additional security provided by shadow call stack is only
> marginal in this case, whereas the performance overhead is not.
> 
> Given that return address signing is based on PACIASP/AUTIASP
> instructions that implicitly operate on the return address register
> (X30) and are not idempotent (i.e., each needs to be emitted exactly
> once before the return address is stored on the ordinary stack and after
> it has been retrieved from it), we can convert these instruction 1:1
> into shadow call stack pushes and pops involving the register X30.
> As this is something that can be done at runtime rather than build time,
> we can do this conditionally based on whether or not return address
> signing is supported on the underlying hardware.
> 
> In order to be able to unwind call stacks that involve return address
> signing, whether or not the return address is currently signed is
> tracked by DWARF CFI directives in the unwinding metadata. This means we
> can use this information to locate all PACIASP/AUTIASP instructions in
> the binary, instead of having to use brute force and go over all
> instructions in the entire program.
> 
> This series implements this approach for Clang, which has recently been
> fixed to emit all these CFI directives correctly. This series is based
> on an older PoC sent out last year [0] that targeted GCC only (due to
> this issue). This v3 targets Clang only, as GCC has its own issues with
> CFI accuracy.
> 
> Changes since v3 [1]:
> - rebase onto arm64/for-next/core

Btw, this no longer seems to apply cleanly to for-next/core. I've found
using git format-patch --base=auto helpful when sending patches against
trees that change more frequently.

> - fix init value of dynamic_scs_enabled static key
> - don't discard .eh_frame sections (to work around a bug in an older
>   Clang version if we are keeping them for dynamic SCS patching,
> - print a diagnostic if dynamic SCS patching is enabled,
> - apply build fix suggested by Sami and add his ack to patch #2

Nevertheless, the patches look good to me, and SCS was correctly enabled
on CPUs without PAC support in my testing. For the series:

Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Sami Tolvanen <samitolvanen@google.com>

Sami

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

      parent reply	other threads:[~2022-07-07 19:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01 15:27 [PATCH v4 0/3] arm64: dynamic shadow call stack support Ard Biesheuvel
2022-07-01 15:27 ` [PATCH v4 1/3] arm64: unwind: add asynchronous unwind tables to kernel and modules Ard Biesheuvel
2022-07-01 15:27 ` [PATCH v4 2/3] scs: add support for dynamic shadow call stacks Ard Biesheuvel
2022-07-01 15:27 ` [PATCH v4 3/3] arm64: implement dynamic shadow call stack for Clang Ard Biesheuvel
2022-07-07 19:35 ` Sami Tolvanen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ysc1W6q8FZkvx3hA@google.com \
    --to=samitolvanen@google.com \
    --cc=ardb@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.