From patchwork Wed May 23 19:53:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10422257 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 B97536032A for ; Wed, 23 May 2018 19:56:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8905291CF for ; Wed, 23 May 2018 19:56:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9BB7C291D4; Wed, 23 May 2018 19:56:58 +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 8F7DB291CF for ; Wed, 23 May 2018 19:56:57 +0000 (UTC) Received: (qmail 22138 invoked by uid 550); 23 May 2018 19:55:18 -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 21987 invoked from network); 23 May 2018 19:55:16 -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=MGmimfpPiGsp6TCy+dV7DlUswcfy+Sfb3pik7ZYx09U=; b=u+blTvqUk5q/UAqeVSaum8jBvAaAeQ8ts579HSiJ55ySGEKZ1jucykMAcZiidmA17h f40OFnnZGmUYXZFzKgwO0Ieu8SNY3X/OLu5ywniITbWOrAQGU301LN94OVXWqsi2cnJe XRhgOVlZAi0pEXdJ5fXftXkea54aj1pcCwnjoajbhrFZQWMot1uSGz40dYOX/L/4g59E 7BtsYrKJVK+usbEfUd6bl0m+of/vz/ReDcwRir6XBbB/cpzitFzxQgWJEE5c3sYUu4mm 9ST3AP+kAqMALjMzEHzCFK+qshf618Ze0V7846c1QCp0392pluSDbJztuE7w/rjYZjMp CDHg== 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=MGmimfpPiGsp6TCy+dV7DlUswcfy+Sfb3pik7ZYx09U=; b=KIxYp70s2dNh/5ARf79kTD0NGgi0iWYYtx8nM8PBYD41HGBlEoHI8rwAsiHDlxbRD9 Aa9cJK6Ht9louGlHIExC6Vnk4MWBCinhGKe8q393nDMC2YFmVkjw5Wz4S2jH21I4shG1 RRJ3e2vs5qvagkzqFsRt5x6etqK3NVCME3WXvcjmNMXkXGdGpTuMjEJdNhAoZ1M3ffEX fT1SzDe9HP7ki+dM/DLC2mpdJ3Eg08k6mzy9p/1p0vxWfEsuY7Gcbr647uo/oV+Sfuwi d5iK111eUiHaZl0hZy6TVrhzHB+UHaRrKaDNmRY1gDOhWDG6efFhE67Ta8uq5ytLs71Q 1EFQ== X-Gm-Message-State: ALKqPwfjfB0SyMrr56qfY2sC+m9BRyXQFyOfnLKNiA4q8zJ2bf/s99IA PSVgBu0SuEg7xbc28vJlh3zVfw== X-Google-Smtp-Source: AB8JxZqJuclz4Q5wvKw+jHfnp9slHkz/l9UgUugANzsHtQPWGZUG5L35PswZ7S3T5vVIif64gcevbQ== X-Received: by 2002:a65:47c8:: with SMTP id f8-v6mr3368265pgs.430.1527105304210; Wed, 23 May 2018 12:55:04 -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 , Thomas Garnier , Philippe Ombredanne , Kate Stewart , Arnaldo Carvalho de Melo , Yonghong Song , Andrey Ryabinin , 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 , Jan Kiszka , Tejun Heo , Christoph Lameter , Dennis Zhou , Boris Ostrovsky , Alexey Dobriyan , Masami Hiramatsu , Cao jin , Francis Deslauriers , "Paul E . McKenney" , Nicolas Pitre , Andrew Morton , Randy Dunlap , "Luis R . Rodriguez" , Arnd Bergmann , Christopher Li , Jason Baron , Mika Westerberg , Lukas Wunner , Dou Liyang , Sergey Senozhatsky , Petr Mladek , Masahiro Yamada , Ingo Molnar , Nicholas Piggin , "H . J . Lu" , Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= , Joerg Roedel , David Woodhouse , Dave Hansen , Rik van Riel , Jia Zhang , Ricardo Neri , Jonathan Corbet , Jan Beulich , Matthias Kaehlcke , Baoquan He , =?UTF-8?q?Jan=20H=20=2E=20Sch=C3=B6nherr?= , Daniel Micay 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 v3 03/27] x86: Use symbol name in jump table for PIE support Date: Wed, 23 May 2018 12:53:57 -0700 Message-Id: <20180523195421.180248-4-thgarnie@google.com> X-Mailer: git-send-email 2.17.0.441.gb46fe60e1d-goog In-Reply-To: <20180523195421.180248-1-thgarnie@google.com> References: <20180523195421.180248-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: