lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5511B213.9030806@redhat.com>
Date:	Tue, 24 Mar 2015 19:50:59 +0100
From:	Denys Vlasenko <dvlasenk@...hat.com>
To:	Ingo Molnar <mingo@...nel.org>
CC:	Andy Lutomirski <luto@...capital.net>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Borislav Petkov <bp@...en8.de>,
	"H. Peter Anvin" <hpa@...or.com>, Oleg Nesterov <oleg@...hat.com>,
	Frederic Weisbecker <fweisbec@...il.com>,
	Alexei Starovoitov <ast@...mgrid.com>,
	Will Drewry <wad@...omium.org>,
	Kees Cook <keescook@...omium.org>, x86@...nel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] x86/asm/entry/64: Improve the THREAD_INFO() macro explanation

On 03/24/2015 07:43 PM, Ingo Molnar wrote:
> From 0229a184997a7d4ad4398ee3ac2f5ae78c1c1a03 Mon Sep 17 00:00:00 2001
> From: Ingo Molnar <mingo@...nel.org>
> Date: Tue, 24 Mar 2015 18:57:13 +0100
> Subject: [PATCH] x86/asm/entry/64: Improve the THREAD_INFO() macro explanation
> 
> Explain the background, and add a real example.
> 
> Cc: Alexei Starovoitov <ast@...mgrid.com>
> Cc: Andy Lutomirski <luto@...capital.net>
> Cc: Andy Lutomirski <luto@...nel.org>
> Cc: Borislav Petkov <bp@...en8.de>
> Cc: Borislav Petkov <bp@...e.de>
> Cc: Denys Vlasenko <dvlasenk@...hat.com>
> Cc: Frederic Weisbecker <fweisbec@...il.com>
> Cc: H. Peter Anvin <hpa@...or.com>
> Cc: Kees Cook <keescook@...omium.org>
> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> Cc: Oleg Nesterov <oleg@...hat.com>
> Cc: Steven Rostedt <rostedt@...dmis.org>
> Cc: Will Drewry <wad@...omium.org>
> Signed-off-by: Ingo Molnar <mingo@...nel.org>
> ---
>  arch/x86/include/asm/thread_info.h | 27 +++++++++++++++++++++++----
>  1 file changed, 23 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
> index ad0ee3423da5..813dfbb867a7 100644
> --- a/arch/x86/include/asm/thread_info.h
> +++ b/arch/x86/include/asm/thread_info.h
> @@ -206,10 +206,29 @@ static inline unsigned long current_stack_pointer(void)
>  	_ASM_SUB $(THREAD_SIZE),reg ;
>  
>  /*
> - * ASM operand which evaluates to thread_info address
> - * if it is known that "reg" is exactly "off" bytes below stack top.
> - * Example (fetch thread_info->fieldname):
> - *  mov TI_fieldname+THREAD_INFO(reg, off),%eax
> + * ASM operand which evaluates to a 'thread_info' address of
> + * the current task, if it is known that "reg" is exactly "off"
> + * bytes below the top of the stack currently.
> + *
> + * ( The kernel stack's size is known at build time, it is usually
> + *   2 or 4 pages, and the bottom  of the kernel stack contains
> + *   the thread_info structure. So to access the thread_info very
> + *   quickly from assembly code we can calculate down from the
> + *   top of the kernel stack to the bottom, using constant,
> + *   build-time calculations only. )
> + *
> + * For example, to fetch the current thread_info->flags value into %eax
> + * on x86-64 defconfig kernels, in syscall entry code where RSP is
> + * currently at exactly SIZEOF_PTREGS bytes away from the top of the
> + * stack:
> + *
> + *      mov TI_flags+THREAD_INFO(%rsp, SIZEOF_PTREGS), %eax
> + *
> + * will translate to:
> + *
> + *      8b 84 24 b8 c0 ff ff      mov    -0x3f48(%rsp), %eax
> + *
> + * which is below the current RSP by almost 16K.
>   */
>  #define THREAD_INFO(reg, off) ((off)-THREAD_SIZE)(reg)

Acked-by: Denys Vlasenko <dvlasenk@...hat.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ