x86/ia32: Fix ia32_restore_sigcontext() AC leak
[ Upstream commit 67a0514afdbb8b2fc70b771b8c77661a9cb9d3a9 ] Objtool spotted that we call native_load_gs_index() with AC set. Re-arrange the code to avoid that. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
4614b0bb8f
commit
5007453c71
1 changed files with 17 additions and 12 deletions
|
@ -61,9 +61,8 @@
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define RELOAD_SEG(seg) { \
|
#define RELOAD_SEG(seg) { \
|
||||||
unsigned int pre = GET_SEG(seg); \
|
unsigned int pre = (seg) | 3; \
|
||||||
unsigned int cur = get_user_seg(seg); \
|
unsigned int cur = get_user_seg(seg); \
|
||||||
pre |= 3; \
|
|
||||||
if (pre != cur) \
|
if (pre != cur) \
|
||||||
set_user_seg(seg, pre); \
|
set_user_seg(seg, pre); \
|
||||||
}
|
}
|
||||||
|
@ -72,6 +71,7 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
|
||||||
struct sigcontext_32 __user *sc)
|
struct sigcontext_32 __user *sc)
|
||||||
{
|
{
|
||||||
unsigned int tmpflags, err = 0;
|
unsigned int tmpflags, err = 0;
|
||||||
|
u16 gs, fs, es, ds;
|
||||||
void __user *buf;
|
void __user *buf;
|
||||||
u32 tmp;
|
u32 tmp;
|
||||||
|
|
||||||
|
@ -79,16 +79,10 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
|
||||||
current->restart_block.fn = do_no_restart_syscall;
|
current->restart_block.fn = do_no_restart_syscall;
|
||||||
|
|
||||||
get_user_try {
|
get_user_try {
|
||||||
/*
|
gs = GET_SEG(gs);
|
||||||
* Reload fs and gs if they have changed in the signal
|
fs = GET_SEG(fs);
|
||||||
* handler. This does not handle long fs/gs base changes in
|
ds = GET_SEG(ds);
|
||||||
* the handler, but does not clobber them at least in the
|
es = GET_SEG(es);
|
||||||
* normal case.
|
|
||||||
*/
|
|
||||||
RELOAD_SEG(gs);
|
|
||||||
RELOAD_SEG(fs);
|
|
||||||
RELOAD_SEG(ds);
|
|
||||||
RELOAD_SEG(es);
|
|
||||||
|
|
||||||
COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
|
COPY(di); COPY(si); COPY(bp); COPY(sp); COPY(bx);
|
||||||
COPY(dx); COPY(cx); COPY(ip); COPY(ax);
|
COPY(dx); COPY(cx); COPY(ip); COPY(ax);
|
||||||
|
@ -106,6 +100,17 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
|
||||||
buf = compat_ptr(tmp);
|
buf = compat_ptr(tmp);
|
||||||
} get_user_catch(err);
|
} get_user_catch(err);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reload fs and gs if they have changed in the signal
|
||||||
|
* handler. This does not handle long fs/gs base changes in
|
||||||
|
* the handler, but does not clobber them at least in the
|
||||||
|
* normal case.
|
||||||
|
*/
|
||||||
|
RELOAD_SEG(gs);
|
||||||
|
RELOAD_SEG(fs);
|
||||||
|
RELOAD_SEG(ds);
|
||||||
|
RELOAD_SEG(es);
|
||||||
|
|
||||||
err |= fpu__restore_sig(buf, 1);
|
err |= fpu__restore_sig(buf, 1);
|
||||||
|
|
||||||
force_iret();
|
force_iret();
|
||||||
|
|
Loading…
Reference in a new issue