HACK: arm64: switch task keys per kernel task

This is a hack to demonstrate that in-kernel pointer authentication is
possible.

This does not account for:
* ftrace
* jprobes
* kprobes

... and potentially other places where we may mess with function returns
stack.

This also does not account for KVM, where we probably have to switch the
keys in hyp (or in an assembly shim for VHE).

We should be able to store per-task kernel keys in the thread_info, but
initialising this early on in the boot process is painful as we don't
have a good source of entropy. For demonstration purposes, I just use
the current task pointer as the key value, as this is unique per-task.
We probably have to give init_task some key generated at compile time,
and generate keys for the other tasks as they're forked off.

Note that none of the setup or context switch is patched, and so on
systems without pointer authentication, or where this is mismatched,
this *WILL NOT WORK*. Somehow, we'll have to patch this from the boot
CPU early, *before* we can possibly context-switch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
4 files changed