From patchwork Mon Jul 24 00:20:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9858657 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E9D9B600F5 for ; Mon, 24 Jul 2017 00:20:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB13728449 for ; Mon, 24 Jul 2017 00:20:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF6F72846D; Mon, 24 Jul 2017 00:20:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 098A028449 for ; Mon, 24 Jul 2017 00:20:58 +0000 (UTC) Received: (qmail 15968 invoked by uid 550); 24 Jul 2017 00:20:39 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 15860 invoked from network); 24 Jul 2017 00:20:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KSl9dGRTQ+1zliFdID/CXFZrcs2p2kcW9AFZKSoRyMo=; b=Pf3qUkVJ27BVOUWHu+eacCHZahNSb6c4ZE7/M0ZcUc7FEHfgXVGzfJxBoblYcetjHF hYzZ4yrI80egBJV5LF+JbRvletFAc59jBR8KDkqkD6urCWkqyKUocPQHMDTTnftmyGva BicR1T0dxkGzuqWAzgqVhPd+6pjQSnY+6DVDE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KSl9dGRTQ+1zliFdID/CXFZrcs2p2kcW9AFZKSoRyMo=; b=TSHpyYFaa+Rg7cPvbEIZCXvf5l3d323BG/70TzMKfTPubwNgBwtEfW9SSloohZ5U/w CzuHkSMoLeCm1+VwjMu5X7UCFVt5mPe9j7h2AQiAOAn2+uS9E5Kf5Wh+v6bcKSxgfhYR WI7NOkHEHUbZc8v8bhV/s7XFEXhUVfXHth4rKqNnDPcqKpYOuVULIzqcuGvysOfb7aQh dGXQtcpxfM3zQEslfHsARCnuwzu7EE57tFOwO2Dwj/O+kdtaV3JLEEYhB0yg+urZLxGh mXRkNQZl81bo+i+d0kfnvOEqbXYrFUGmbG0WX7XWl0SXlF487Yu5RQSOoBDIHAba1Ncq B/fQ== X-Gm-Message-State: AIVw111u/deBHyJ5New60/6T+TZx4vmjwoN/XjeiybXZ3WNx7DyehR0x fmw232Ex3/PZdKZv X-Received: by 10.84.215.147 with SMTP id l19mr10629196pli.479.1500855624228; Sun, 23 Jul 2017 17:20:24 -0700 (PDT) From: Kees Cook To: Ingo Molnar Cc: Kees Cook , Peter Zijlstra , Josh Poimboeuf , Christoph Hellwig , "Eric W. Biederman" , Andrew Morton , Jann Horn , Eric Biggers , Elena Reshetova , Hans Liljestrand , Greg KH , Alexey Dobriyan , "Serge E. Hallyn" , arozansk@redhat.com, Davidlohr Bueso , Manfred Spraul , "axboe@kernel.dk" , James Bottomley , "x86@kernel.org" , Arnd Bergmann , "David S. Miller" , Rik van Riel , linux-kernel@vger.kernel.org, linux-arch , "kernel-hardening@lists.openwall.com" Date: Sun, 23 Jul 2017 17:20:19 -0700 Message-Id: <1500855620-73004-3-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500855620-73004-1-git-send-email-keescook@chromium.org> References: <1500855620-73004-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH v7 2/3] x86/asm: add ASM_UNREACHABLE X-Virus-Scanned: ClamAV using ClamSMTP This creates an unreachable annotation in asm for CONFIG_STACK_VALIDATION. While here, adjust earlier uses of \t\n into \n\t. Suggested-by: Josh Poimboeuf Signed-off-by: Kees Cook --- include/linux/compiler-gcc.h | 13 +++++++++---- include/linux/compiler.h | 3 +++ 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 @@ #ifdef CONFIG_STACK_VALIDATION #define annotate_unreachable() ({ \ - asm("%c0:\t\n" \ - ".pushsection .discard.unreachable\t\n" \ - ".long %c0b - .\t\n" \ - ".popsection\t\n" : : "i" (__LINE__)); \ + asm("%c0:\n\t" \ + ".pushsection .discard.unreachable\n\t" \ + ".long %c0b - .\n\t" \ + ".popsection\n\t" : : "i" (__LINE__)); \ }) +#define ASM_UNREACHABLE \ + "999:\n\t" \ + ".pushsection .discard.unreachable\n\t" \ + ".long 999b - .\n\t" \ + ".popsection\n\t" #else #define annotate_unreachable() #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, #endif /* Unreachable code */ +#ifndef ASM_UNREACHABLE +# define ASM_UNREACHABLE +#endif #ifndef unreachable # define unreachable() do { } while (1) #endif