Skip to content

Commit 2b10906

Browse files
Brian Gerstsuryasaimadhu
authored andcommitted
x86: Remove force_iret()
force_iret() was originally intended to prevent the return to user mode with the SYSRET or SYSEXIT instructions, in cases where the register state could have been changed to be incompatible with those instructions. The entry code has been significantly reworked since then, and register state is validated before SYSRET or SYSEXIT are used. force_iret() no longer serves its original purpose and can be eliminated. Signed-off-by: Brian Gerst <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Oleg Nesterov <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent f444a5f commit 2b10906

File tree

7 files changed

+0
-32
lines changed

7 files changed

+0
-32
lines changed

arch/x86/ia32/ia32_signal.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ static int ia32_restore_sigcontext(struct pt_regs *regs,
114114

115115
err |= fpu__restore_sig(buf, 1);
116116

117-
force_iret();
118-
119117
return err;
120118
}
121119

arch/x86/include/asm/ptrace.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -339,22 +339,6 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,
339339

340340
#define ARCH_HAS_USER_SINGLE_STEP_REPORT
341341

342-
/*
343-
* When hitting ptrace_stop(), we cannot return using SYSRET because
344-
* that does not restore the full CPU state, only a minimal set. The
345-
* ptracer can change arbitrary register values, which is usually okay
346-
* because the usual ptrace stops run off the signal delivery path which
347-
* forces IRET; however, ptrace_event() stops happen in arbitrary places
348-
* in the kernel and don't force IRET path.
349-
*
350-
* So force IRET path after a ptrace stop.
351-
*/
352-
#define arch_ptrace_stop_needed(code, info) \
353-
({ \
354-
force_iret(); \
355-
false; \
356-
})
357-
358342
struct user_desc;
359343
extern int do_get_thread_area(struct task_struct *p, int idx,
360344
struct user_desc __user *info);

arch/x86/include/asm/thread_info.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,6 @@ static inline int arch_within_stack_frames(const void * const stack,
239239
current_thread_info()->status & TS_COMPAT)
240240
#endif
241241

242-
/*
243-
* Force syscall return via IRET by making it look as if there was
244-
* some work pending. IRET is our most capable (but slowest) syscall
245-
* return path, which is able to restore modified SS, CS and certain
246-
* EFLAGS values that other (fast) syscall return instructions
247-
* are not able to restore properly.
248-
*/
249-
#define force_iret() set_thread_flag(TIF_NOTIFY_RESUME)
250-
251242
extern void arch_task_cache_init(void);
252243
extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
253244
extern void arch_release_task_struct(struct task_struct *tsk);

arch/x86/kernel/process_32.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp)
124124
regs->ip = new_ip;
125125
regs->sp = new_sp;
126126
regs->flags = X86_EFLAGS_IF;
127-
force_iret();
128127
}
129128
EXPORT_SYMBOL_GPL(start_thread);
130129

arch/x86/kernel/process_64.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ start_thread_common(struct pt_regs *regs, unsigned long new_ip,
394394
regs->cs = _cs;
395395
regs->ss = _ss;
396396
regs->flags = X86_EFLAGS_IF;
397-
force_iret();
398397
}
399398

400399
void

arch/x86/kernel/signal.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,6 @@ static int restore_sigcontext(struct pt_regs *regs,
151151

152152
err |= fpu__restore_sig(buf, IS_ENABLED(CONFIG_X86_32));
153153

154-
force_iret();
155-
156154
return err;
157155
}
158156

arch/x86/kernel/vm86_32.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,6 @@ static long do_sys_vm86(struct vm86plus_struct __user *user_vm86, bool plus)
381381
mark_screen_rdonly(tsk->mm);
382382

383383
memcpy((struct kernel_vm86_regs *)regs, &vm86regs, sizeof(vm86regs));
384-
force_iret();
385384
return regs->ax;
386385
}
387386

0 commit comments

Comments
 (0)