Commit b05e3703 authored by Martin Schwidefsky's avatar Martin Schwidefsky

[S390] user-copy optimization fallout.

Fix new restore_sigregs function. It copies the user space copy of the
old psw without correcting the psw.mask and the psw.addr high order bit.
While we are at it, simplify save_sigregs a bit.
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent aa97b102
...@@ -113,17 +113,15 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss, ...@@ -113,17 +113,15 @@ sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
/* Returns non-zero on fault. */ /* Returns non-zero on fault. */
static int save_sigregs(struct pt_regs *regs, _sigregs __user *sregs) static int save_sigregs(struct pt_regs *regs, _sigregs __user *sregs)
{ {
unsigned long old_mask = regs->psw.mask;
_sigregs user_sregs; _sigregs user_sregs;
save_access_regs(current->thread.acrs); save_access_regs(current->thread.acrs);
/* Copy a 'clean' PSW mask to the user to avoid leaking /* Copy a 'clean' PSW mask to the user to avoid leaking
information about whether PER is currently on. */ information about whether PER is currently on. */
regs->psw.mask = PSW_MASK_MERGE(PSW_USER_BITS, regs->psw.mask); user_sregs.regs.psw.mask = PSW_MASK_MERGE(PSW_USER_BITS, regs->psw.mask);
memcpy(&user_sregs.regs.psw, &regs->psw, sizeof(sregs->regs.psw) + user_sregs.regs.psw.addr = regs->psw.addr;
sizeof(sregs->regs.gprs)); memcpy(&user_sregs.regs.gprs, &regs->gprs, sizeof(sregs->regs.gprs));
regs->psw.mask = old_mask;
memcpy(&user_sregs.regs.acrs, current->thread.acrs, memcpy(&user_sregs.regs.acrs, current->thread.acrs,
sizeof(sregs->regs.acrs)); sizeof(sregs->regs.acrs));
/* /*
...@@ -139,7 +137,6 @@ static int save_sigregs(struct pt_regs *regs, _sigregs __user *sregs) ...@@ -139,7 +137,6 @@ static int save_sigregs(struct pt_regs *regs, _sigregs __user *sregs)
/* Returns positive number on error */ /* Returns positive number on error */
static int restore_sigregs(struct pt_regs *regs, _sigregs __user *sregs) static int restore_sigregs(struct pt_regs *regs, _sigregs __user *sregs)
{ {
unsigned long old_mask = regs->psw.mask;
int err; int err;
_sigregs user_sregs; _sigregs user_sregs;
...@@ -147,12 +144,12 @@ static int restore_sigregs(struct pt_regs *regs, _sigregs __user *sregs) ...@@ -147,12 +144,12 @@ static int restore_sigregs(struct pt_regs *regs, _sigregs __user *sregs)
current_thread_info()->restart_block.fn = do_no_restart_syscall; current_thread_info()->restart_block.fn = do_no_restart_syscall;
err = __copy_from_user(&user_sregs, sregs, sizeof(_sigregs)); err = __copy_from_user(&user_sregs, sregs, sizeof(_sigregs));
regs->psw.mask = PSW_MASK_MERGE(old_mask, regs->psw.mask);
regs->psw.addr |= PSW_ADDR_AMODE;
if (err) if (err)
return err; return err;
memcpy(&regs->psw, &user_sregs.regs.psw, sizeof(sregs->regs.psw) + regs->psw.mask = PSW_MASK_MERGE(regs->psw.mask,
sizeof(sregs->regs.gprs)); user_sregs.regs.psw.mask);
regs->psw.addr = PSW_ADDR_AMODE | user_sregs.regs.psw.addr;
memcpy(&regs->gprs, &user_sregs.regs.gprs, sizeof(sregs->regs.gprs));
memcpy(&current->thread.acrs, &user_sregs.regs.acrs, memcpy(&current->thread.acrs, &user_sregs.regs.acrs,
sizeof(sregs->regs.acrs)); sizeof(sregs->regs.acrs));
restore_access_regs(current->thread.acrs); restore_access_regs(current->thread.acrs);
......
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