Commit 3add42c2 authored by Al Viro's avatar Al Viro

x86: get rid of get_user_ex() in restore_sigcontext()

Just do copyin into a local struct and be done with that - we are
on a shallow stack here.

[reworked by tglx, removing the macro horrors while we are touching that]
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 978727ca
...@@ -47,24 +47,6 @@ ...@@ -47,24 +47,6 @@
#include <asm/sigframe.h> #include <asm/sigframe.h>
#include <asm/signal.h> #include <asm/signal.h>
#define COPY(x) do { \
get_user_ex(regs->x, &sc->x); \
} while (0)
#define GET_SEG(seg) ({ \
unsigned short tmp; \
get_user_ex(tmp, &sc->seg); \
tmp; \
})
#define COPY_SEG(seg) do { \
regs->seg = GET_SEG(seg); \
} while (0)
#define COPY_SEG_CPL3(seg) do { \
regs->seg = GET_SEG(seg) | 3; \
} while (0)
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
/* /*
* If regs->ss will cause an IRET fault, change it. Otherwise leave it * If regs->ss will cause an IRET fault, change it. Otherwise leave it
...@@ -92,53 +74,58 @@ static void force_valid_ss(struct pt_regs *regs) ...@@ -92,53 +74,58 @@ static void force_valid_ss(struct pt_regs *regs)
ar != (AR_DPL3 | AR_S | AR_P | AR_TYPE_RWDATA_EXPDOWN)) ar != (AR_DPL3 | AR_S | AR_P | AR_TYPE_RWDATA_EXPDOWN))
regs->ss = __USER_DS; regs->ss = __USER_DS;
} }
# define CONTEXT_COPY_SIZE offsetof(struct sigcontext, reserved1)
#else
# define CONTEXT_COPY_SIZE sizeof(struct sigcontext)
#endif #endif
static int restore_sigcontext(struct pt_regs *regs, static int restore_sigcontext(struct pt_regs *regs,
struct sigcontext __user *sc, struct sigcontext __user *usc,
unsigned long uc_flags) unsigned long uc_flags)
{ {
unsigned long buf_val; struct sigcontext sc;
void __user *buf;
unsigned int tmpflags;
unsigned int err = 0;
/* Always make any pending restarted system calls return -EINTR */ /* Always make any pending restarted system calls return -EINTR */
current->restart_block.fn = do_no_restart_syscall; current->restart_block.fn = do_no_restart_syscall;
get_user_try { if (copy_from_user(&sc, usc, CONTEXT_COPY_SIZE))
return -EFAULT;
#ifdef CONFIG_X86_32 #ifdef CONFIG_X86_32
set_user_gs(regs, GET_SEG(gs)); set_user_gs(regs, sc.gs);
COPY_SEG(fs); regs->fs = sc.fs;
COPY_SEG(es); regs->es = sc.es;
COPY_SEG(ds); regs->ds = sc.ds;
#endif /* CONFIG_X86_32 */ #endif /* CONFIG_X86_32 */
COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx); regs->bx = sc.bx;
COPY(dx); COPY(cx); COPY(ip); COPY(ax); regs->cx = sc.cx;
regs->dx = sc.dx;
regs->si = sc.si;
regs->di = sc.di;
regs->bp = sc.bp;
regs->ax = sc.ax;
regs->sp = sc.sp;
regs->ip = sc.ip;
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
COPY(r8); regs->r8 = sc.r8;
COPY(r9); regs->r9 = sc.r9;
COPY(r10); regs->r10 = sc.r10;
COPY(r11); regs->r11 = sc.r11;
COPY(r12); regs->r12 = sc.r12;
COPY(r13); regs->r13 = sc.r13;
COPY(r14); regs->r14 = sc.r14;
COPY(r15); regs->r15 = sc.r15;
#endif /* CONFIG_X86_64 */ #endif /* CONFIG_X86_64 */
COPY_SEG_CPL3(cs); /* Get CS/SS and force CPL3 */
COPY_SEG_CPL3(ss); regs->cs = sc.cs | 0x03;
regs->ss = sc.ss | 0x03;
get_user_ex(tmpflags, &sc->flags);
regs->flags = (regs->flags & ~FIX_EFLAGS) | (tmpflags & FIX_EFLAGS);
regs->orig_ax = -1; /* disable syscall checks */
get_user_ex(buf_val, &sc->fpstate); regs->flags = (regs->flags & ~FIX_EFLAGS) | (sc.flags & FIX_EFLAGS);
buf = (void __user *)buf_val; /* disable syscall checks */
} get_user_catch(err); regs->orig_ax = -1;
#ifdef CONFIG_X86_64 #ifdef CONFIG_X86_64
/* /*
...@@ -149,9 +136,8 @@ static int restore_sigcontext(struct pt_regs *regs, ...@@ -149,9 +136,8 @@ static int restore_sigcontext(struct pt_regs *regs,
force_valid_ss(regs); force_valid_ss(regs);
#endif #endif
err |= fpu__restore_sig(buf, IS_ENABLED(CONFIG_X86_32)); return fpu__restore_sig((void __user *)sc.fpstate,
IS_ENABLED(CONFIG_X86_32));
return err;
} }
int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate, int setup_sigcontext(struct sigcontext __user *sc, void __user *fpstate,
......
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