aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2017-07-24 14:35:48 -0400
committerIngo Molnar <mingo@kernel.org>2017-07-25 05:18:09 -0400
commitaa5d1b81500e6059190f18fe25a7617682321910 (patch)
tree37210d06d8699603850aad46527f4c4f91df444b /include
parentdf3405245a8535d2f20bcbdbb615385671cd0792 (diff)
x86/asm: Add ASM_UNREACHABLE
This creates an unreachable annotation in asm for CONFIG_STACK_VALIDATION=y. While here, adjust earlier uses of \t\n into \n\t. Suggested-by: Josh Poimboeuf <jpoimboe@redhat.com> Signed-off-by: Kees Cook <keescook@chromium.org> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Christoph Hellwig <hch@infradead.org> Cc: David S. Miller <davem@davemloft.net> Cc: Davidlohr Bueso <dave@stgolabs.net> Cc: Elena Reshetova <elena.reshetova@intel.com> Cc: Eric Biggers <ebiggers3@gmail.com> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Greg KH <gregkh@linuxfoundation.org> Cc: Hans Liljestrand <ishkamiel@gmail.com> Cc: James Bottomley <James.Bottomley@hansenpartnership.com> Cc: Jann Horn <jannh@google.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Manfred Spraul <manfred@colorfullife.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Rik van Riel <riel@redhat.com> Cc: Serge E. Hallyn <serge@hallyn.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: arozansk@redhat.com Cc: axboe@kernel.dk Cc: kernel-hardening@lists.openwall.com Cc: linux-arch <linux-arch@vger.kernel.org> Link: http://lkml.kernel.org/r/1500921349-10803-3-git-send-email-keescook@chromium.org Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/compiler-gcc.h13
-rw-r--r--include/linux/compiler.h3
2 files changed, 12 insertions, 4 deletions
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index cd4bbe8242bd..179375b2d862 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -203,11 +203,16 @@
203 203
204#ifdef CONFIG_STACK_VALIDATION 204#ifdef CONFIG_STACK_VALIDATION
205#define annotate_unreachable() ({ \ 205#define annotate_unreachable() ({ \
206 asm("%c0:\t\n" \ 206 asm("%c0:\n\t" \
207 ".pushsection .discard.unreachable\t\n" \ 207 ".pushsection .discard.unreachable\n\t" \
208 ".long %c0b - .\t\n" \ 208 ".long %c0b - .\n\t" \
209 ".popsection\t\n" : : "i" (__LINE__)); \ 209 ".popsection\n\t" : : "i" (__LINE__)); \
210}) 210})
211#define ASM_UNREACHABLE \
212 "999:\n\t" \
213 ".pushsection .discard.unreachable\n\t" \
214 ".long 999b - .\n\t" \
215 ".popsection\n\t"
211#else 216#else
212#define annotate_unreachable() 217#define annotate_unreachable()
213#endif 218#endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 219f82f3ec1a..641f5912d75f 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -185,6 +185,9 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val,
185#endif 185#endif
186 186
187/* Unreachable code */ 187/* Unreachable code */
188#ifndef ASM_UNREACHABLE
189# define ASM_UNREACHABLE
190#endif
188#ifndef unreachable 191#ifndef unreachable
189# define unreachable() do { } while (1) 192# define unreachable() do { } while (1)
190#endif 193#endif