From patchwork Tue May 29 22:15:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10437271 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 72AFD601C7 for ; Tue, 29 May 2018 22:18:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C4C72890F for ; Tue, 29 May 2018 22:18:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EE152891B; Tue, 29 May 2018 22:18:51 +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=-12.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, USER_IN_DEF_DKIM_WL 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 7B8902890F for ; Tue, 29 May 2018 22:18:50 +0000 (UTC) Received: (qmail 16303 invoked by uid 550); 29 May 2018 22:17: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 16102 invoked from network); 29 May 2018 22:16:56 -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=Z36536B1Q8Gpz0m8wnNnSO5619LQqKEpGoNmKhvORiI=; b=p1bSMKcjQvA2g+6P9YDVD33AK+VkBtKCF/vJl4EoEGehF693m73Jr9CM1zpbZFXjJ7 GkOjy74v7iPqhUySR5eHztIGRsa6yQ/CeaRxjwFIJmFU0UrKzAR7zG/X4XmtdkiSokUK z6StS5r9ZEbJJNeyuovr1MvraImJpZezhyEGFka5Bpvmbaf2RLba8BUNA0BcupazF1VK TvxL+z9AOhi156ScBrxMVVaqYkcYB8nKevJiM1Rc3hTLVYUWTfUmE+dE/lGcRDoLIoWG YVcUS/Ql+1MyPSHy8SvguSxsY0uhBoEdO4echnxXrlVa1DF0ogskmn7cAzH1TZ/WxYds NHKg== 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=Z36536B1Q8Gpz0m8wnNnSO5619LQqKEpGoNmKhvORiI=; b=owVezplCAxfyqx5azdTmzapY4CP9El8QhHne6jfaprEh8XU7NZM6U8Ny5yZ3WIlne2 lp4h7M5m/Nxp5o1Q+7bKi/TXG4NAslAWqSNAOwMWSA5YqRLARcrMfQGspoqJnV+eJpeb orB2Kp5g85UTn2zPzS2jZxtLcqAN9pdo0+jqPrRdX/uoZagYYK0HaVp7j5E8VjLf3gjZ rxDADGZCLPdMRdW5pVIcddpoXsnJfKDQxSPVaZW4UsMewpHfoWZxgX/Qihe6ugXbGpBW 1qlZOYOA0pf/C/zRDcNp92AZ+1UE1YHAE8U+0HAOOUq5jBGMMgEITPayCSsar6F7zXfw aJ5Q== X-Gm-Message-State: ALKqPwdDqdAHOnGBy7N6gm5/X5Lc0Gn4rC6SyR1572Fd9HktUs/BX4PK D1hHZJXQUqCY3w83e7Y4ew0q5Egrn70= X-Google-Smtp-Source: ADUXVKJ+xHvtb2UfGYj/Qm8yagmYDw6VL8cLgrarcmEy4Dyp8gh9RJSTbL/07ucRLArPmO4dQPX0eA== X-Received: by 2002:a62:e710:: with SMTP id s16-v6mr183298pfh.227.1527632204140; Tue, 29 May 2018 15:16:44 -0700 (PDT) From: Thomas Garnier To: kernel-hardening@lists.openwall.com Cc: Thomas Garnier , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Kate Stewart , Philippe Ombredanne , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH v4 03/27] x86: Use symbol name in jump table for PIE support Date: Tue, 29 May 2018 15:15:04 -0700 Message-Id: <20180529221625.33541-4-thgarnie@google.com> X-Mailer: git-send-email 2.17.0.921.gf22659ad46-goog In-Reply-To: <20180529221625.33541-1-thgarnie@google.com> References: <20180529221625.33541-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 extend the KASLR randomization range 0xffffffff80000000. 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: