]> git.itanic.dy.fi Git - linux-stable/commit
arm64: Stash shadow stack pointer in the task struct on interrupt
authorArd Biesheuvel <ardb@kernel.org>
Mon, 9 Jan 2023 17:48:00 +0000 (18:48 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 20 Jan 2023 14:26:18 +0000 (14:26 +0000)
commit59b37fe52f49955791a460752c37145f1afdcad1
treeb9562f0a3510203133339c73ac3baef2e0b3c51d
parent2198d07c509f1db4a1185d1f65aaada794c6ea59
arm64: Stash shadow stack pointer in the task struct on interrupt

Instead of reloading the shadow call stack pointer from the ordinary
stack, which may be vulnerable to the kind of gadget based attacks
shadow call stacks were designed to prevent, let's store a task's shadow
call stack pointer in the task struct when switching to the shadow IRQ
stack.

Given that currently, the task_struct::scs_sp field is only used to
preserve the shadow call stack pointer while a task is scheduled out or
running in user space, reusing this field to preserve and restore it
while running off the IRQ stack must be safe, as those occurrences are
guaranteed to never overlap. (The stack switching logic only switches
stacks when running from the task stack, and so the value being saved
here always corresponds to the task mode shadow stack)

While at it, fold a mov/add/mov sequence into a single add.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20230109174800.3286265-3-ardb@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/entry.S