Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[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: Martin Schwidefsky <schwidefsky@de.ibm.com>

+7 -10
+7 -10
arch/s390/kernel/signal.c
··· 113 113 /* Returns non-zero on fault. */ 114 114 static int save_sigregs(struct pt_regs *regs, _sigregs __user *sregs) 115 115 { 116 - unsigned long old_mask = regs->psw.mask; 117 116 _sigregs user_sregs; 118 117 119 118 save_access_regs(current->thread.acrs); 120 119 121 120 /* Copy a 'clean' PSW mask to the user to avoid leaking 122 121 information about whether PER is currently on. */ 123 - regs->psw.mask = PSW_MASK_MERGE(PSW_USER_BITS, regs->psw.mask); 124 - memcpy(&user_sregs.regs.psw, &regs->psw, sizeof(sregs->regs.psw) + 125 - sizeof(sregs->regs.gprs)); 126 - regs->psw.mask = old_mask; 122 + user_sregs.regs.psw.mask = PSW_MASK_MERGE(PSW_USER_BITS, regs->psw.mask); 123 + user_sregs.regs.psw.addr = regs->psw.addr; 124 + memcpy(&user_sregs.regs.gprs, &regs->gprs, sizeof(sregs->regs.gprs)); 127 125 memcpy(&user_sregs.regs.acrs, current->thread.acrs, 128 126 sizeof(sregs->regs.acrs)); 129 127 /* ··· 137 139 /* Returns positive number on error */ 138 140 static int restore_sigregs(struct pt_regs *regs, _sigregs __user *sregs) 139 141 { 140 - unsigned long old_mask = regs->psw.mask; 141 142 int err; 142 143 _sigregs user_sregs; 143 144 ··· 144 147 current_thread_info()->restart_block.fn = do_no_restart_syscall; 145 148 146 149 err = __copy_from_user(&user_sregs, sregs, sizeof(_sigregs)); 147 - regs->psw.mask = PSW_MASK_MERGE(old_mask, regs->psw.mask); 148 - regs->psw.addr |= PSW_ADDR_AMODE; 149 150 if (err) 150 151 return err; 151 - memcpy(&regs->psw, &user_sregs.regs.psw, sizeof(sregs->regs.psw) + 152 - sizeof(sregs->regs.gprs)); 152 + regs->psw.mask = PSW_MASK_MERGE(regs->psw.mask, 153 + user_sregs.regs.psw.mask); 154 + regs->psw.addr = PSW_ADDR_AMODE | user_sregs.regs.psw.addr; 155 + memcpy(&regs->gprs, &user_sregs.regs.gprs, sizeof(sregs->regs.gprs)); 153 156 memcpy(&current->thread.acrs, &user_sregs.regs.acrs, 154 157 sizeof(sregs->regs.acrs)); 155 158 restore_access_regs(current->thread.acrs);