From patchwork Tue Apr 30 11:23:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot for Kobe Wu X-Patchwork-Id: 10923325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 72B2414B6 for ; Tue, 30 Apr 2019 11:32:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 605F428AAB for ; Tue, 30 Apr 2019 11:32:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5439828AAE; Tue, 30 Apr 2019 11:32:27 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 109D128AAB for ; Tue, 30 Apr 2019 11:32:25 +0000 (UTC) Received: (qmail 26609 invoked by uid 550); 30 Apr 2019 11:31:00 -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 17644 invoked from network); 30 Apr 2019 11:24:01 -0000 DKIM-Filter: OpenDKIM Filter v2.11.0 terminus.zytor.com x3UBNT3Z1347949 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2019041745; t=1556623410; bh=tmZb/ywuy5RuSOeSqOG7vwZj6rmGFHYEwUdw428e/8c=; h=Date:From:Cc:Reply-To:In-Reply-To:References:To:Subject:From; b=XeJMlENZHQHbFaWMJDB3MciBCjCAAIoX03eRjcdiOQizNlIIBARcZolUSGxSZW84N qqm1JktCBbgTIGH29WfwK+GouyWJeeq+WxGD6SWgFZ6QlU+YQ6baojEDBRqOR4bxYU oShqIPYI5ssL6NWmrrBtms3OG0xkDvWOSRJxxqvFi79IzcgfFQmIAz2ODeLZgLqjag TyIbXClTNcsmtUjqCY5lYZRl7raXnfOcvu8X+f1cQ7dw6w/vgoAPq9F5YKAAbNu3Fb md9bZBlQfNwQvROLZ9v/Y10tK7s3TdrhKELqsf9htHPslEyxDKA6eVSur6Qmc2oCMb uBJArRkcF+fBw== Date: Tue, 30 Apr 2019 04:23:28 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f Sender: tip tree robot From: tip-bot for Nadav Amit Message-ID: Cc: luto@kernel.org, bp@alien8.de, dave.hansen@intel.com, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, tglx@linutronix.de, mhiramat@kernel.org, kernel-hardening@lists.openwall.com, deneen.t.dock@intel.com, linux_dti@icloud.com, hpa@zytor.com, riel@surriel.com, mingo@kernel.org, kristen@linux.intel.com, keescook@chromium.org, namit@vmware.com, peterz@infradead.org, will.deacon@arm.com, ard.biesheuvel@linaro.org, rick.p.edgecombe@intel.com, torvalds@linux-foundation.org In-Reply-To: <20190426001143.4983-13-namit@vmware.com> References: <20190426001143.4983-13-namit@vmware.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/mm] x86/jump-label: Remove support for custom text poker Git-Commit-ID: bb0a008d6a2c543efc11313b448d2f26f91dc4f8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Disposition: inline X-Virus-Scanned: ClamAV using ClamSMTP Commit-ID: bb0a008d6a2c543efc11313b448d2f26f91dc4f8 Gitweb: https://git.kernel.org/tip/bb0a008d6a2c543efc11313b448d2f26f91dc4f8 Author: Nadav Amit AuthorDate: Thu, 25 Apr 2019 17:11:32 -0700 Committer: Ingo Molnar CommitDate: Tue, 30 Apr 2019 12:37:55 +0200 x86/jump-label: Remove support for custom text poker There are only two types of text poking: early and breakpoint based. The use of a function pointer to perform text poking complicates the code and is probably inefficient due to the use of indirect branches. Signed-off-by: Nadav Amit Signed-off-by: Rick Edgecombe Signed-off-by: Peter Zijlstra (Intel) Cc: Cc: Cc: Cc: Cc: Cc: Cc: Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Dave Hansen Cc: H. Peter Anvin Cc: Kees Cook Cc: Linus Torvalds Cc: Masami Hiramatsu Cc: Rik van Riel Cc: Thomas Gleixner Link: https://lkml.kernel.org/r/20190426001143.4983-13-namit@vmware.com Signed-off-by: Ingo Molnar --- arch/x86/kernel/jump_label.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index e7d8c636b228..e631c358f7f4 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -37,7 +37,6 @@ static void bug_at(unsigned char *ip, int line) static void __ref __jump_label_transform(struct jump_entry *entry, enum jump_label_type type, - void *(*poker)(void *, const void *, size_t), int init) { union jump_code_union jmp; @@ -50,14 +49,6 @@ static void __ref __jump_label_transform(struct jump_entry *entry, jmp.offset = jump_entry_target(entry) - (jump_entry_code(entry) + JUMP_LABEL_NOP_SIZE); - /* - * As long as only a single processor is running and the code is still - * not marked as RO, text_poke_early() can be used; Checking that - * system_state is SYSTEM_BOOTING guarantees it. - */ - if (system_state == SYSTEM_BOOTING) - poker = text_poke_early; - if (type == JUMP_LABEL_JMP) { if (init) { expect = default_nop; line = __LINE__; @@ -80,16 +71,19 @@ static void __ref __jump_label_transform(struct jump_entry *entry, bug_at((void *)jump_entry_code(entry), line); /* - * Make text_poke_bp() a default fallback poker. + * As long as only a single processor is running and the code is still + * not marked as RO, text_poke_early() can be used; Checking that + * system_state is SYSTEM_BOOTING guarantees it. It will be set to + * SYSTEM_SCHEDULING before other cores are awaken and before the + * code is write-protected. * * At the time the change is being done, just ignore whether we * are doing nop -> jump or jump -> nop transition, and assume * always nop being the 'currently valid' instruction - * */ - if (poker) { - (*poker)((void *)jump_entry_code(entry), code, - JUMP_LABEL_NOP_SIZE); + if (init || system_state == SYSTEM_BOOTING) { + text_poke_early((void *)jump_entry_code(entry), code, + JUMP_LABEL_NOP_SIZE); return; } @@ -101,7 +95,7 @@ void arch_jump_label_transform(struct jump_entry *entry, enum jump_label_type type) { mutex_lock(&text_mutex); - __jump_label_transform(entry, type, NULL, 0); + __jump_label_transform(entry, type, 0); mutex_unlock(&text_mutex); } @@ -131,5 +125,5 @@ __init_or_module void arch_jump_label_transform_static(struct jump_entry *entry, jlstate = JL_STATE_NO_UPDATE; } if (jlstate == JL_STATE_UPDATE) - __jump_label_transform(entry, type, text_poke_early, 1); + __jump_label_transform(entry, type, 1); }