Commit 9f855c08 authored by Al Viro's avatar Al Viro

x86: switch setup_sigcontext() to unsafe_put_user()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent a37d01ea
...@@ -14,9 +14,6 @@ ...@@ -14,9 +14,6 @@
X86_EFLAGS_CF | X86_EFLAGS_RF) X86_EFLAGS_CF | X86_EFLAGS_RF)
void signal_fault(struct pt_regs *regs, void __user *frame, char *where); void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
struct pt_regs *regs, unsigned long mask);
#ifdef CONFIG_X86_X32_ABI #ifdef CONFIG_X86_X32_ABI
asmlinkage long sys32_x32_rt_sigreturn(void); asmlinkage long sys32_x32_rt_sigreturn(void);
......
...@@ -140,63 +140,65 @@ static int restore_sigcontext(struct pt_regs *regs, ...@@ -140,63 +140,65 @@ static int restore_sigcontext(struct pt_regs *regs,
IS_ENABLED(CONFIG_X86_32)); IS_ENABLED(CONFIG_X86_32));
} }
int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate, static int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
struct pt_regs *regs, unsigned long mask) struct pt_regs *regs, unsigned long mask)
{ {
int err = 0; if (!user_access_begin(sc, sizeof(struct sigcontext)))
return -EFAULT;
put_user_try {
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
put_user_ex(get_user_gs(regs), (unsigned int __user *)&sc->gs); unsafe_put_user(get_user_gs(regs),
put_user_ex(regs->fs, (unsigned int __user *)&sc->fs); (unsigned int __user *)&sc->gs, Efault);
put_user_ex(regs->es, (unsigned int __user *)&sc->es); unsafe_put_user(regs->fs, (unsigned int __user *)&sc->fs, Efault);
put_user_ex(regs->ds, (unsigned int __user *)&sc->ds); unsafe_put_user(regs->es, (unsigned int __user *)&sc->es, Efault);
unsafe_put_user(regs->ds, (unsigned int __user *)&sc->ds, Efault);
#endif /* CONFIG_X86_32 */ #endif /* CONFIG_X86_32 */
put_user_ex(regs->di, &sc->di); unsafe_put_user(regs->di, &sc->di, Efault);
put_user_ex(regs->si, &sc->si); unsafe_put_user(regs->si, &sc->si, Efault);
put_user_ex(regs->bp, &sc->bp); unsafe_put_user(regs->bp, &sc->bp, Efault);
put_user_ex(regs->sp, &sc->sp); unsafe_put_user(regs->sp, &sc->sp, Efault);
put_user_ex(regs->bx, &sc->bx); unsafe_put_user(regs->bx, &sc->bx, Efault);
put_user_ex(regs->dx, &sc->dx); unsafe_put_user(regs->dx, &sc->dx, Efault);
put_user_ex(regs->cx, &sc->cx); unsafe_put_user(regs->cx, &sc->cx, Efault);
put_user_ex(regs->ax, &sc->ax); unsafe_put_user(regs->ax, &sc->ax, Efault);
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
put_user_ex(regs->r8, &sc->r8); unsafe_put_user(regs->r8, &sc->r8, Efault);
put_user_ex(regs->r9, &sc->r9); unsafe_put_user(regs->r9, &sc->r9, Efault);
put_user_ex(regs->r10, &sc->r10); unsafe_put_user(regs->r10, &sc->r10, Efault);
put_user_ex(regs->r11, &sc->r11); unsafe_put_user(regs->r11, &sc->r11, Efault);
put_user_ex(regs->r12, &sc->r12); unsafe_put_user(regs->r12, &sc->r12, Efault);
put_user_ex(regs->r13, &sc->r13); unsafe_put_user(regs->r13, &sc->r13, Efault);
put_user_ex(regs->r14, &sc->r14); unsafe_put_user(regs->r14, &sc->r14, Efault);
put_user_ex(regs->r15, &sc->r15); unsafe_put_user(regs->r15, &sc->r15, Efault);
#endif /* CONFIG_X86_64 */ #endif /* CONFIG_X86_64 */
put_user_ex(current->thread.trap_nr, &sc->trapno); unsafe_put_user(current->thread.trap_nr, &sc->trapno, Efault);
put_user_ex(current->thread.error_code, &sc->err); unsafe_put_user(current->thread.error_code, &sc->err, Efault);
put_user_ex(regs->ip, &sc->ip); unsafe_put_user(regs->ip, &sc->ip, Efault);
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
put_user_ex(regs->cs, (unsigned int __user *)&sc->cs); unsafe_put_user(regs->cs, (unsigned int __user *)&sc->cs, Efault);
put_user_ex(regs->flags, &sc->flags); unsafe_put_user(regs->flags, &sc->flags, Efault);
put_user_ex(regs->sp, &sc->sp_at_signal); unsafe_put_user(regs->sp, &sc->sp_at_signal, Efault);
put_user_ex(regs->ss, (unsigned int __user *)&sc->ss); unsafe_put_user(regs->ss, (unsigned int __user *)&sc->ss, Efault);
#else /* !CONFIG_X86_32 */ #else /* !CONFIG_X86_32 */
put_user_ex(regs->flags, &sc->flags); unsafe_put_user(regs->flags, &sc->flags, Efault);
put_user_ex(regs->cs, &sc->cs); unsafe_put_user(regs->cs, &sc->cs, Efault);
put_user_ex(0, &sc->gs); unsafe_put_user(0, &sc->gs, Efault);
put_user_ex(0, &sc->fs); unsafe_put_user(0, &sc->fs, Efault);
put_user_ex(regs->ss, &sc->ss); unsafe_put_user(regs->ss, &sc->ss, Efault);
#endif /* CONFIG_X86_32 */ #endif /* CONFIG_X86_32 */
put_user_ex(fpstate, (unsigned long __user *)&sc->fpstate); unsafe_put_user(fpstate, (unsigned long __user *)&sc->fpstate, Efault);
/* non-iBCS2 extensions.. */ /* non-iBCS2 extensions.. */
put_user_ex(mask, &sc->oldmask); unsafe_put_user(mask, &sc->oldmask, Efault);
put_user_ex(current->thread.cr2, &sc->cr2); unsafe_put_user(current->thread.cr2, &sc->cr2, Efault);
} put_user_catch(err); user_access_end();
return 0;
return err; Efault:
user_access_end();
return -EFAULT;
} }
/* /*
......
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