Skip to content

Commit dfa9a94

Browse files
amlutoingomolnar
authored andcommitted
x86/uaccess: Move thread_info::uaccess_err and thread_info::sig_on_uaccess_err to thread_struct
struct thread_info is a legacy mess. To prepare for its partial removal, move the uaccess control fields out -- they're straightforward. Signed-off-by: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> 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> Link: http://lkml.kernel.org/r/d0ac4d01c8e4d4d756264604e47445d5acc7900e.1468527351.git.luto@kernel.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 2deb4be commit dfa9a94

6 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎arch/x86/entry/vsyscall/vsyscall_64.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,8 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
221221
* With a real vsyscall, page faults cause SIGSEGV. We want to
222222
* preserve that behavior to make writing exploits harder.
223223
*/
224-
prev_sig_on_uaccess_error = current_thread_info()->sig_on_uaccess_error;
225-
current_thread_info()->sig_on_uaccess_error = 1;
224+
prev_sig_on_uaccess_error = current->thread.sig_on_uaccess_error;
225+
current->thread.sig_on_uaccess_error = 1;
226226

227227
ret = -EFAULT;
228228
switch (vsyscall_nr) {
@@ -243,7 +243,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
243243
break;
244244
}
245245

246-
current_thread_info()->sig_on_uaccess_error = prev_sig_on_uaccess_error;
246+
current->thread.sig_on_uaccess_error = prev_sig_on_uaccess_error;
247247

248248
check_fault:
249249
if (ret == -EFAULT) {

‎arch/x86/include/asm/processor.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@ struct thread_struct {
419419
/* Max allowed port in the bitmap, in bytes: */
420420
unsigned io_bitmap_max;
421421

422+
unsigned int sig_on_uaccess_error:1;
423+
unsigned int uaccess_err:1; /* uaccess failed */
424+
422425
/* Floating point and extended processor state */
423426
struct fpu fpu;
424427
/*

‎arch/x86/include/asm/thread_info.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ struct thread_info {
5858
__u32 status; /* thread synchronous flags */
5959
__u32 cpu; /* current CPU */
6060
mm_segment_t addr_limit;
61-
unsigned int sig_on_uaccess_error:1;
62-
unsigned int uaccess_err:1; /* uaccess failed */
6361
};
6462

6563
#define INIT_THREAD_INFO(tsk) \

‎arch/x86/include/asm/uaccess.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,13 +487,13 @@ struct __large_struct { unsigned long buf[100]; };
487487
* uaccess_try and catch
488488
*/
489489
#define uaccess_try do { \
490-
current_thread_info()->uaccess_err = 0; \
490+
current->thread.uaccess_err = 0; \
491491
__uaccess_begin(); \
492492
barrier();
493493

494494
#define uaccess_catch(err) \
495495
__uaccess_end(); \
496-
(err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
496+
(err) |= (current->thread.uaccess_err ? -EFAULT : 0); \
497497
} while (0)
498498

499499
/**

‎arch/x86/mm/extable.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ bool ex_handler_ext(const struct exception_table_entry *fixup,
3737
struct pt_regs *regs, int trapnr)
3838
{
3939
/* Special hack for uaccess_err */
40-
current_thread_info()->uaccess_err = 1;
40+
current->thread.uaccess_err = 1;
4141
regs->ip = ex_fixup_addr(fixup);
4242
return true;
4343
}

‎arch/x86/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ no_context(struct pt_regs *regs, unsigned long error_code,
737737
* In this case we need to make sure we're not recursively
738738
* faulting through the emulate_vsyscall() logic.
739739
*/
740-
if (current_thread_info()->sig_on_uaccess_error && signal) {
740+
if (current->thread.sig_on_uaccess_error && signal) {
741741
tsk->thread.trap_nr = X86_TRAP_PF;
742742
tsk->thread.error_code = error_code | PF_USER;
743743
tsk->thread.cr2 = address;

0 commit comments

Comments
 (0)