Re: [PATCH 08/11] x86: Move uaccess_err and sig_on_uaccess_err to thread_struct

From: Ingo Molnar
Date: Fri Jul 15 2016 - 04:16:01 EST



* Andy Lutomirski <luto@xxxxxxxxxx> wrote:

> 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@xxxxxxxxxx>
> ---
> arch/x86/entry/vsyscall/vsyscall_64.c | 6 +++---
> arch/x86/include/asm/processor.h | 3 +++
> arch/x86/include/asm/thread_info.h | 2 --
> arch/x86/include/asm/uaccess.h | 4 ++--
> arch/x86/mm/extable.c | 2 +-
> arch/x86/mm/fault.c | 2 +-
> 6 files changed, 10 insertions(+), 9 deletions(-)
>
> diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c
> index 174c2549939d..3aba2b043050 100644
> --- a/arch/x86/entry/vsyscall/vsyscall_64.c
> +++ b/arch/x86/entry/vsyscall/vsyscall_64.c
> @@ -221,8 +221,8 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
> * With a real vsyscall, page faults cause SIGSEGV. We want to
> * preserve that behavior to make writing exploits harder.
> */
> - prev_sig_on_uaccess_error = current_thread_info()->sig_on_uaccess_error;
> - current_thread_info()->sig_on_uaccess_error = 1;
> + prev_sig_on_uaccess_error = current->thread.sig_on_uaccess_error;
> + current->thread.sig_on_uaccess_error = 1;
>
> ret = -EFAULT;
> switch (vsyscall_nr) {
> @@ -243,7 +243,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
> break;
> }
>
> - current_thread_info()->sig_on_uaccess_error = prev_sig_on_uaccess_error;
> + current->thread.sig_on_uaccess_error = prev_sig_on_uaccess_error;
>
> check_fault:
> if (ret == -EFAULT) {
> diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
> index 62c6cc3cc5d3..f53ae57bd985 100644
> --- a/arch/x86/include/asm/processor.h
> +++ b/arch/x86/include/asm/processor.h
> @@ -419,6 +419,9 @@ struct thread_struct {
> /* Max allowed port in the bitmap, in bytes: */
> unsigned io_bitmap_max;
>
> + unsigned int sig_on_uaccess_error:1;
> + unsigned int uaccess_err:1; /* uaccess failed */

Btw., while at it I've renamed 'sig_on_uaccess_error' to 'sig_on_uaccess_err' to
make the two names consistent.

Thanks,

Ingo