From patchwork Tue Jul 18 22:33:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 9850025 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 EAAF560392 for ; Tue, 18 Jul 2017 22:35:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D619B1FF15 for ; Tue, 18 Jul 2017 22:35:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CA17228433; Tue, 18 Jul 2017 22:35:17 +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 D7A781FF15 for ; Tue, 18 Jul 2017 22:35:16 +0000 (UTC) Received: (qmail 26211 invoked by uid 550); 18 Jul 2017 22:34:29 -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 25886 invoked from network); 18 Jul 2017 22:34:25 -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=Vpbco9N4XDcCjE6iCZkupT8vWcmkCU5OcV2fZrvcLeU=; b=SBgLV5hcPfe5iF7nr9etY2Sy6y+OAsju7O/1onwqlARmWzXbCXDT6PERm1B1Q9tUZF HvgXF5ZVkys/lMNhRCVFQHWeJf38rw3pCAG90hW+aGVaSp7l1yWBM7Dil7G+O1fSyJLV yHTBrVpWkS1ovUP71qHmjQYpABoBzeLSz4ak59zt7NPsHJzbvHc1TtsHatpAiIAN31RJ Ot3YIbkbH32OH7uP3c7w7rXg6iye1Tv1tNErv5Zx40Yr/Anju8Xh/ZrAv1Rxnp+sWJdF WQTIp4M79IAWJYJylkfLVrRIqLDhnvUM7paBeX/zpYd9iGtsrFD6fxs9NT9gF2bQ2zmV Pr/w== 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=Vpbco9N4XDcCjE6iCZkupT8vWcmkCU5OcV2fZrvcLeU=; b=UlNW8S7UJnjDTV1/sID3hpTAgJCRBWLA02B7Rfzi7vyba0k5hoJ8lnGRtZEQzT7oXm Hy0l8Q8jM6L+CzyNRBdr5tYCNfCXcI4AHK5jpLJAZEVwcgL10Esy5hnuI9Zix0piyVvn t+qFhrZ4g+JyRW0j+OztfQC1+A3S7MzJQ6cvqY/85QPs4Z8W537SNhPsxIFgsMfSsowr CwzqB8VAEE4G9oLDt9YFj+NDe3vAxCL8HUzceeXuqxlgpjiqUAp9iJq1gfF6Hk8vrjW1 grrM50VJ2W+GyiIKxInw/eW5a9h5pJkd7BYIO4wnH6APi0ekK6bOPmLwaAGCq4iWDqnm cKRw== X-Gm-Message-State: AIVw1137eRP7Dt6YknT2s4XG1gTqRuIlfw1/H3gj2Rh5GRD5uX/BTFSM 9IY/266OgjTIO/C+ X-Received: by 10.98.99.198 with SMTP id x189mr3987595pfb.180.1500417253206; Tue, 18 Jul 2017 15:34:13 -0700 (PDT) From: Thomas Garnier To: Herbert Xu , "David S . Miller" , Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Peter Zijlstra , Josh Poimboeuf , Thomas Garnier , Arnd Bergmann , Matthias Kaehlcke , Boris Ostrovsky , Juergen Gross , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , Andy Lutomirski , Borislav Petkov , "Kirill A . Shutemov" , Brian Gerst , Borislav Petkov , Christian Borntraeger , "Rafael J . Wysocki" , Len Brown , Pavel Machek , Tejun Heo , Christoph Lameter , Kees Cook , Paul Gortmaker , Chris Metcalf , "Paul E . McKenney" , Andrew Morton , Christopher Li , Dou Liyang , Masahiro Yamada , Daniel Borkmann , Markus Trippelsdorf , Peter Foley , Steven Rostedt , Tim Chen , Ard Biesheuvel , Catalin Marinas , Matthew Wilcox , Michal Hocko , Rob Landley , Jiri Kosina , "H . J . Lu" , Paul Bolle , 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: Tue, 18 Jul 2017 15:33:14 -0700 Message-Id: <20170718223333.110371-4-thgarnie@google.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog In-Reply-To: <20170718223333.110371-1-thgarnie@google.com> References: <20170718223333.110371-1-thgarnie@google.com> Subject: [kernel-hardening] [RFC 03/22] 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: