From patchwork Mon Jun 25 22:38:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10488257 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 52EF7602B3 for ; Tue, 26 Jun 2018 08:39:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DE0828725 for ; Tue, 26 Jun 2018 08:39:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 323FB287E0; Tue, 26 Jun 2018 08:39:16 +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 620F128725 for ; Tue, 26 Jun 2018 08:39:15 +0000 (UTC) Received: (qmail 21647 invoked by uid 550); 26 Jun 2018 08:38:31 -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 Delivered-To: moderator for kernel-hardening@lists.openwall.com Received: (qmail 9995 invoked from network); 25 Jun 2018 22:41:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:in-reply-to:message-id:references:subject:from:to :cc; bh=k64qpDQWoxqYXhctTCfAYQx6Gdl1qzC7yPWOjOPOVJY=; b=P5qMXypdbngYS/RnDB8D4hzLx9UbIhEe1XEuRdvO6NvZEsh1HNUol+M35decdWXYrs 5gJE4ol9giVxngYsHrMT5V0BFEEJFqke6nyB6mGaU09DFT4tT9qlBgbNa6dcnq6pmjMM QSCkfWWrEtOPh6Zaj5LJma5K80VQNKN9eDIQ3lxH6j1k+SZsArFd2oWspYvlDg8Ry5Cf zg0acyOPhNa66uzPExAWK+Znqbgnu/c1YV/ySGKuHeWuOfWxkYXbm2dFaaA8UsxgVm7E zUOIgQAnLipl+ug+tBg7Pv7JF1VPdgrwn2rS1z1f+H80oEUQQ9t0sbIDcM8lERhE0DVW lnww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=k64qpDQWoxqYXhctTCfAYQx6Gdl1qzC7yPWOjOPOVJY=; b=l7yk000qAkM2farNEbR5BASJx26Z3nSD08Y+rNuA6+NGzmdr+jnsqEPWmlQazKoWxu IKPeIUH046hOQfhUft7/YCAWo/56XpGuOVnNvRYZJgEgJjsvGNegE7SpkrTFkPz0LCxw MfUyaqCgpAgm9YXjFPsyz7h8RJ1A6oyg5HanyoUMGatjJFC53i7h+ZPImIdQ05CL9Q9v FGJ5Mn9VUwxW02tMWpTFRh+8FFZwq24uedpvHdJo8WQtWzBLf4dHVFFsWhJsRBF+D0Fv Sx+SrKN6D8JIggR1exqoMCO8dQSpSBMgwLDWpcs/N5jZkKxuRPK0AvrbwaGJZucT5Vkn BHZw== X-Gm-Message-State: APt69E13JqWYmHH9AXvy5xwl9inP+QmCqQTTxKHDgyermvpm823Z208S cuZp1aYzTpNAtSTlFLESJyQx1Fw4OSMJRYASyGUSkyWEFLrY3Lb9riveMkcr/UT7G8yJSOfrRtR GrZLNsBJn7sMAkpcwtXfU0ZbAsIfKVJqnX/5zAyMlqbzvf3g3Pub7pq+Ol9W9fjy97qlGFDcnny 8x8bml3CC2 X-Google-Smtp-Source: AAOMgpfB3hq193GzaZUZSz0CnJ4gWsBK7SzjKke8rf14Sop8IgvMK1bj/2EXWel0PE8fWLPjBGw6EH77Q/Dfuw== MIME-Version: 1.0 X-Received: by 2002:a24:5dd4:: with SMTP id w203-v6mr1226821ita.27.1529966461160; Mon, 25 Jun 2018 15:41:01 -0700 (PDT) Date: Mon, 25 Jun 2018 15:38:51 -0700 In-Reply-To: <20180625224014.134829-1-thgarnie@google.com> Message-Id: <20180625224014.134829-4-thgarnie@google.com> References: <20180625224014.134829-1-thgarnie@google.com> X-Mailer: git-send-email 2.18.0.rc2.346.g013aa6912e-goog Subject: [PATCH v5 03/27] x86: Use symbol name in jump table for PIE support 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 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: