Commit c32cd419 authored by Russell King's avatar Russell King

ARM: signal: copy registers using __copy_from_user()

__get_user_error() is used as a fast accessor to make copying structure
members in the signal handling path as efficient as possible.  However,
with software PAN and the recent Spectre variant 1, the efficiency is
reduced as these are no longer fast accessors.

In the case of software PAN, it has to switch the domain register around
each access, and with Spectre variant 1, it would have to repeat the
access_ok() check for each access.

It becomes much more efficient to use __copy_from_user() instead, so
let's use this for the ARM integer registers.
Acked-by: default avatarMark Rutland <mark.rutland@arm.com>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
parent 10573ae5
...@@ -176,6 +176,7 @@ static int restore_vfp_context(char __user **auxp) ...@@ -176,6 +176,7 @@ static int restore_vfp_context(char __user **auxp)
static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf) static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
{ {
struct sigcontext context;
char __user *aux; char __user *aux;
sigset_t set; sigset_t set;
int err; int err;
...@@ -184,23 +185,26 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf) ...@@ -184,23 +185,26 @@ static int restore_sigframe(struct pt_regs *regs, struct sigframe __user *sf)
if (err == 0) if (err == 0)
set_current_blocked(&set); set_current_blocked(&set);
__get_user_error(regs->ARM_r0, &sf->uc.uc_mcontext.arm_r0, err); err |= __copy_from_user(&context, &sf->uc.uc_mcontext, sizeof(context));
__get_user_error(regs->ARM_r1, &sf->uc.uc_mcontext.arm_r1, err); if (err == 0) {
__get_user_error(regs->ARM_r2, &sf->uc.uc_mcontext.arm_r2, err); regs->ARM_r0 = context.arm_r0;
__get_user_error(regs->ARM_r3, &sf->uc.uc_mcontext.arm_r3, err); regs->ARM_r1 = context.arm_r1;
__get_user_error(regs->ARM_r4, &sf->uc.uc_mcontext.arm_r4, err); regs->ARM_r2 = context.arm_r2;
__get_user_error(regs->ARM_r5, &sf->uc.uc_mcontext.arm_r5, err); regs->ARM_r3 = context.arm_r3;
__get_user_error(regs->ARM_r6, &sf->uc.uc_mcontext.arm_r6, err); regs->ARM_r4 = context.arm_r4;
__get_user_error(regs->ARM_r7, &sf->uc.uc_mcontext.arm_r7, err); regs->ARM_r5 = context.arm_r5;
__get_user_error(regs->ARM_r8, &sf->uc.uc_mcontext.arm_r8, err); regs->ARM_r6 = context.arm_r6;
__get_user_error(regs->ARM_r9, &sf->uc.uc_mcontext.arm_r9, err); regs->ARM_r7 = context.arm_r7;
__get_user_error(regs->ARM_r10, &sf->uc.uc_mcontext.arm_r10, err); regs->ARM_r8 = context.arm_r8;
__get_user_error(regs->ARM_fp, &sf->uc.uc_mcontext.arm_fp, err); regs->ARM_r9 = context.arm_r9;
__get_user_error(regs->ARM_ip, &sf->uc.uc_mcontext.arm_ip, err); regs->ARM_r10 = context.arm_r10;
__get_user_error(regs->ARM_sp, &sf->uc.uc_mcontext.arm_sp, err); regs->ARM_fp = context.arm_fp;
__get_user_error(regs->ARM_lr, &sf->uc.uc_mcontext.arm_lr, err); regs->ARM_ip = context.arm_ip;
__get_user_error(regs->ARM_pc, &sf->uc.uc_mcontext.arm_pc, err); regs->ARM_sp = context.arm_sp;
__get_user_error(regs->ARM_cpsr, &sf->uc.uc_mcontext.arm_cpsr, err); regs->ARM_lr = context.arm_lr;
regs->ARM_pc = context.arm_pc;
regs->ARM_cpsr = context.arm_cpsr;
}
err |= !valid_user_regs(regs); err |= !valid_user_regs(regs);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment