From patchwork Thu Aug 10 17:25:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9894299 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 748EA60236 for ; Thu, 10 Aug 2017 17:28:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B2A3286CF for ; Thu, 10 Aug 2017 17:28:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F3B3288A7; Thu, 10 Aug 2017 17:28:03 +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_ADSP_CUSTOM_MED, 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 6D2A3286CF for ; Thu, 10 Aug 2017 17:28:02 +0000 (UTC) Received: (qmail 32325 invoked by uid 550); 10 Aug 2017 17:27:01 -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 32232 invoked from network); 10 Aug 2017 17:26:59 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XP0AHvNJXIQ0dh1yFRKn4+yVNx0GtzCOb/CGU2mpPZw=; b=p7L0HFtPCokUe2yX38XNd3IeViEn9dPItBUSUOvAsBKjseOHd0sp62EqhTW9gKt5HX GATvK0KKa1cHyyuucqBw5Vp9yj+wSud9NvekSbYYPmgy+PnEYPDBV8OhUijUpFmkM5T+ mjeU/ij7LJb35daZycihwsERWqR+5qNVBOmP/rPdZoYz5MSZZ3l61IC9VEcNSdKYA5JP ZQFJcZDkrYsiYowgIUKF6SVNQxI5kUIrMhTvz2ApqHyFYf8Qeo69GugBy+cB/vbhcQAD ZHBwhzp7v/NjWTSHinpgU56yW5F0oir9UrjExdUQpyw6YrcJLHuzJG+MsrNOzjb8BMrq YLvA== 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=XP0AHvNJXIQ0dh1yFRKn4+yVNx0GtzCOb/CGU2mpPZw=; b=ufttFbJHvWY/1Q3ynyIBu+wQbehIDHQolXVFwj9qGYA7EhHveZBot5e7IYfYi8VCgQ k+Y6FmAuVMH2ePwIaf1raBDv7F3keBr770XMGOB9sS/qsGa/rsqbHK+/Pq28AsG9rS4t KO+a4gOw47Pk+uOeQG9nKYTLakD1D8IP0pmmFHB45uv5lOSGQfamA76cWOTv9NJp6kC8 W0qXT7vBdWVf6uYe31k9zyuJnCzFT/VBObT7+NuKD0UiKzDwYl+dfYSqaosaCvF7+LGV tSgVCBC311H0VodvZJFKFJc5cbaP7kwucLV9ZwjihmUxbLjjv7S3x0yk2rqdGcf/zkbb vyww== X-Gm-Message-State: AHYfb5imqR0qRdN+XEfD5frN533dd4q2m6jxeD0BT8OotiAyA8AnC1rl HTArzysnaOH30WKV X-Received: by 10.84.241.70 with SMTP id u6mr13972744plm.96.1502386007817; Thu, 10 Aug 2017 10:26:47 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Arnd Bergmann , Thomas Garnier , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Tom Lendacky , Andy Lutomirski , Borislav Petkov , Brian Gerst , "Kirill A . Shutemov" , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Paul Gortmaker , Chris Metcalf , Andrew Morton , "Paul E . McKenney" , Nicolas Pitre , Christopher Li , "Rafael J . Wysocki" , Lukas Wunner , Mika Westerberg , Dou Liyang , Daniel Borkmann , Alexei Starovoitov , Masahiro Yamada , Markus Trippelsdorf , Steven Rostedt , Kees Cook , Rik van Riel , David Howells , Waiman Long , Kyle Huey , Peter Foley , Tim Chen , Catalin Marinas , Ard Biesheuvel , Michal Hocko , Matthew Wilcox , "H . J . Lu" , Paul Bolle , Rob Landley , Baoquan He , Daniel Micay Cc: x86@kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, linux-pm@vger.kernel.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, kernel-hardening@lists.openwall.com Date: Thu, 10 Aug 2017 10:25:55 -0700 Message-Id: <20170810172615.51965-4-thgarnie@google.com> X-Mailer: git-send-email 2.14.0.434.g98096fd7a8-goog In-Reply-To: <20170810172615.51965-1-thgarnie@google.com> References: <20170810172615.51965-1-thgarnie@google.com> Subject: [kernel-hardening] [RFC v2 03/23] x86: Use symbol name in jump table for PIE support X-Virus-Scanned: ClamAV using ClamSMTP Replace the %c constraint with %P. The %c is incompatible with PIE because it implies an immediate value whereas %P reference a symbol. Position Independent Executable (PIE) support will allow to extended the KASLR randomization range below the -2G memory limit. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/jump_label.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h index adc54c12cbd1..6e558e4524dc 100644 --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h @@ -36,9 +36,9 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" ".pushsection __jump_table, \"aw\" \n\t" _ASM_ALIGN "\n\t" - _ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t" + _ASM_PTR "1b, %l[l_yes], %P0 \n\t" ".popsection \n\t" - : : "i" (key), "i" (branch) : : l_yes); + : : "X" (&((char *)key)[branch]) : : l_yes); return false; l_yes: @@ -52,9 +52,9 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool "2:\n\t" ".pushsection __jump_table, \"aw\" \n\t" _ASM_ALIGN "\n\t" - _ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t" + _ASM_PTR "1b, %l[l_yes], %P0 \n\t" ".popsection \n\t" - : : "i" (key), "i" (branch) : : l_yes); + : : "X" (&((char *)key)[branch]) : : l_yes); return false; l_yes: