From patchwork Tue Mar 13 20:59:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10280763 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 8FFF9602C2 for ; Tue, 13 Mar 2018 21:02:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8004521327 for ; Tue, 13 Mar 2018 21:02:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72E11284AA; Tue, 13 Mar 2018 21:02:23 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_MED 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 75EFE21327 for ; Tue, 13 Mar 2018 21:02:22 +0000 (UTC) Received: (qmail 20060 invoked by uid 550); 13 Mar 2018 21:00:32 -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 19958 invoked from network); 13 Mar 2018 21:00:29 -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=LaPxxOEIYMftdT45XyC1plS51rUTXkZYDl6NTTG7gQs=; b=VRvt15wYkpeHgTyb7tTep2PgKdfEgZucljghTWEW6xG/Q6F5gQL/y5U9GYZTE71sQ9 Xkbi5Mq0z6utUr2pPgIUC7v8zN6B2ZViFW7Vpmz8BM+7jWfdgeFlGywVwf9cIc6r7RPe ow+vs2QPKdFk1XOcSDAuxSbfny++qqIiKL2SydyY1qTkDxSEj8mTTeTzYTeOIAyoWU16 whMIc2v5STo6OiWXguM+5RUGgh70h6uMhui9ifWHzGD1hb1AQbpoXsVtrdZeaUU9O7Bp nUDhnIgYmve3sWSTZp4BZKti+cWPfZ/V4Q//Is/PCAornFdw82wS3bFmF8hqqFdMVvxY q/Tw== 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=LaPxxOEIYMftdT45XyC1plS51rUTXkZYDl6NTTG7gQs=; b=e8OaWHxHKxTD76lUptbsY3PQvvt29ex+/wcIrYNTX312BHe9qx+YSqKTsBmTXM62tI 5WrdT5j+4bDjOVjGWK7CWvUxorOLS5m1Hjhr3p3rQ7Jp/y8mHyy99Ixv2DJ9P1FJzU/G B69yKkqNeG3oq8lSMw7BrVsS1XXs2pEKtjJItczI8VFWmZgNv+LaGxpe6t7+ueFNJPar F9VaY/tjC1QqFZfx+MFyD5QKpXiRyE4itttv/2tVH2mzHPb4WXvAdb3g7Rdm2cjCLtsw Y7OBRorAfyCEjdMwhfUk6NSDb18FXm/TL7rOFTObfDSj5dTaIwYKkYpLVfzOpJHP89D7 f6iQ== X-Gm-Message-State: AElRT7FxCKmVHxszEC1qmbaIgSGxjF5q9G2zpVXk9nNddyS7O+vcZjKO HY+KnR+/Tj+qq6P8VkJTtlLs1A== X-Google-Smtp-Source: AG47ELsuWhEt6B4LcwnCbfv59W+UDf5cXEogNEPvwU3kFimhVuRWTC+5mgLsFApfKn49pnCoS5TtKw== X-Received: by 2002:a17:902:ab93:: with SMTP id f19-v6mr1830305plr.180.1520974817526; Tue, 13 Mar 2018 14:00:17 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Greg Kroah-Hartman , Kate Stewart , Thomas Garnier , Arnd Bergmann , Philippe Ombredanne , Arnaldo Carvalho de Melo , Andrey Ryabinin , Matthias Kaehlcke , Kees Cook , Tom Lendacky , "Kirill A . Shutemov" , Andy Lutomirski , Dominik Brodowski , Borislav Petkov , Borislav Petkov , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Juergen Gross , Alok Kataria , Steven Rostedt , Tejun Heo , Christoph Lameter , Dennis Zhou , Boris Ostrovsky , David Woodhouse , Alexey Dobriyan , "Paul E . McKenney" , Andrew Morton , Nicolas Pitre , Randy Dunlap , "Luis R . Rodriguez" , Christopher Li , Jason Baron , Ashish Kalra , Kyle McMartin , Dou Liyang , Lukas Wunner , Petr Mladek , Sergey Senozhatsky , Masahiro Yamada , Ingo Molnar , Nicholas Piggin , Cao jin , "H . J . Lu" , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Dave Hansen , Rik van Riel , Jia Zhang , Jiri Slaby , Kyle Huey , Jonathan Corbet , Matthew Wilcox , Michal Hocko , Rob Landley , Baoquan He , Daniel Micay , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= Cc: x86@kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, virtualization@lists.linux-foundation.org, xen-devel@lists.xenproject.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, kernel-hardening@lists.openwall.com Subject: [PATCH v2 03/27] x86: Use symbol name in jump table for PIE support Date: Tue, 13 Mar 2018 13:59:21 -0700 Message-Id: <20180313205945.245105-4-thgarnie@google.com> X-Mailer: git-send-email 2.16.2.660.g709887971b-goog In-Reply-To: <20180313205945.245105-1-thgarnie@google.com> References: <20180313205945.245105-1-thgarnie@google.com> 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 8c0de4282659..dfdcdc39604a 100644 --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h @@ -37,9 +37,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: @@ -53,9 +53,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: