From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932360AbbLRMkt (ORCPT ); Fri, 18 Dec 2015 07:40:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35460 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753331AbbLRMkc (ORCPT ); Fri, 18 Dec 2015 07:40:32 -0500 From: Josh Poimboeuf To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Michal Marek , Peter Zijlstra , Andy Lutomirski , Borislav Petkov , Linus Torvalds , Andi Kleen , Pedro Alves , Namhyung Kim , Bernd Petrovitsch , Chris J Arges , Andrew Morton , Jiri Slaby , Arnaldo Carvalho de Melo Subject: [PATCH v15 08/25] x86/stacktool: Add ignore macros Date: Fri, 18 Dec 2015 06:39:22 -0600 Message-Id: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add new stacktool ignore macros: STACKTOOL_IGNORE_INSN and STACKTOOL_IGNORE_FUNC. These can be used to tell stacktool to skip validation of an instruction or a function, respectively. Signed-off-by: Josh Poimboeuf --- arch/x86/include/asm/stacktool.h | 45 ++++++++++++++++++++++++++++++++++++++++ arch/x86/kernel/vmlinux.lds.S | 5 ++++- include/linux/stacktool.h | 29 ++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 arch/x86/include/asm/stacktool.h create mode 100644 include/linux/stacktool.h diff --git a/arch/x86/include/asm/stacktool.h b/arch/x86/include/asm/stacktool.h new file mode 100644 index 0000000..250a37e --- /dev/null +++ b/arch/x86/include/asm/stacktool.h @@ -0,0 +1,45 @@ +#ifndef _ASM_X86_STACKTOOL_H +#define _ASM_X86_STACKTOOL_H + +#include + +#ifdef __ASSEMBLY__ + +/* + * This asm macro tells stacktool to ignore the instruction immediately after + * the macro when doing stack metadata validation. It should only be used in + * special cases where you're 100% sure it won't affect the reliability of + * frame pointers and kernel stack traces. + * + * For more information, see tools/stacktool/Documentation/stack-validation.txt. + */ +.macro STACKTOOL_IGNORE_INSN +#ifdef CONFIG_STACK_VALIDATION + .Lstacktool_ignore_\@: + .pushsection __stacktool_ignore_insn, "a" + _ASM_ALIGN + .long .Lstacktool_ignore_\@ - . + .popsection +#endif +.endm + +#else /* !__ASSEMBLY__ */ + +#ifdef CONFIG_STACK_VALIDATION + +#define STACKTOOL_IGNORE_INSN \ + "1:\n" \ + ".pushsection __stacktool_ignore_insn, \"a\"\n" \ + _ASM_ALIGN "\n" \ + ".long 1b - .\n" \ + ".popsection\n" + +#else /* !CONFIG_STACK_VALIDATION */ + +#define STACKTOOL_IGNORE_INSN "" + +#endif /* CONFIG_STACK_VALIDATION */ + +#endif /* __ASSEMBLY__ */ + +#endif /* _ASM_X86_STACKTOOL_H */ diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 4f19942..c08c283c 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -333,7 +333,10 @@ SECTIONS /* Sections to be discarded */ DISCARDS - /DISCARD/ : { *(.eh_frame) } + /DISCARD/ : { + *(.eh_frame) + *(__stacktool_ignore_*) + } } diff --git a/include/linux/stacktool.h b/include/linux/stacktool.h new file mode 100644 index 0000000..c1e151b --- /dev/null +++ b/include/linux/stacktool.h @@ -0,0 +1,29 @@ +#ifndef _LINUX_STACKTOOL_H +#define _LINUX_STACKTOOL_H + +#include + +#ifndef __ASSEMBLY__ + +#ifdef CONFIG_STACK_VALIDATION +/* + * This C macro tells stacktool to ignore the function when doing stack + * metadata validation. It should only be used in special cases where you're + * 100% sure it won't affect the reliability of frame pointers and kernel stack + * traces. + * + * For more information, see tools/stacktool/Documentation/stack-validation.txt. + */ +#define STACKTOOL_IGNORE_FUNC(_func) \ + static void __used __section(__stacktool_ignore_func) \ + *__stacktool_ignore_func_##_func = _func + +#else /* !CONFIG_STACK_VALIDATION */ + +#define STACKTOOL_IGNORE_FUNC(_func) + +#endif /* CONFIG_STACK_VALIDATION */ + +#endif /* !__ASSEMBLY__ */ + +#endif /* _LINUX_STACKTOOL_H */ -- 2.4.3