Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1342837imu; Wed, 16 Jan 2019 17:41:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN4BFyTmyMXfNaoX3XQzRqQUTTAUbRbs2DvG8HdCrAKzL+a+yBHcSNxY8X1y9Hug7kGplwGU X-Received: by 2002:a62:345:: with SMTP id 66mr12837168pfd.189.1547689316485; Wed, 16 Jan 2019 17:41:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547689316; cv=none; d=google.com; s=arc-20160816; b=Gf102a3ovKuUrXlGpIk1Oqu2Dx5lTfopUGOByf0jW/rF/lW87+IkjhtrelzZa+kyth 1FM8O/zhOBdFE+A0/iq6IpucRCNBB5MXP8ZqAIOSQ1dzr8t9pqRq28xBJoANJ2KCKn2m /ayl0j1m5VOc704LY/AiTr1dSsYz1C7jad0wR9+Hgh0rNF/xnJk6O1UjPFPI8Fnnh7PO CIP4VAgRwljnKZkbKCGntX2XG1DgrFT0EZJtYC5bT/OIJ99Yag8FW7Je7pW9m6icj+6C tPLKXvAAIYdm+Kt9N1tcgL6JmaxE8JhusOFheYh4+yYnJPB/YX4gIs7Wp0l7ygUKvzog lX+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=1oCH1vqwofeA+CR+BzYGyrdjwP4k7rQNDYFA/zzkTDg=; b=S1QxZUhS02p4HzO86n0hAASZtjHQnpZXuxnOxfP4VPfTpg/sGEkxWR1fLFVNzgx7BT vZjb6Y+yUndVhVqTI8rcx/Fq529WRC6DIC8uiCTm8xCECa4K+yFa2ddYxu/dC9Gq2w+p w0o04cWJ7s7vTVO+MtlAZhx3kaTizSkoI/NtClP3L+1AVJXx9jzg18UBcY3RtTWz5lIJ 92uogqfdi1AO0M1S7/6mPVA43XG1/xf6wsTaACYjvMFjwOpc8Fed4Re9D4tzxn1JIcit 2kucj08U9zEel3kv7M5S8bUg+IbLJ8D/8SRFqxwCngOSzyl1XKtxZ47mOiedinG6XWmN fUYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si100946plz.53.2019.01.16.17.41.38; Wed, 16 Jan 2019 17:41:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731479AbfAQAfT (ORCPT + 99 others); Wed, 16 Jan 2019 19:35:19 -0500 Received: from mga11.intel.com ([192.55.52.93]:47095 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729885AbfAQAdi (ORCPT ); Wed, 16 Jan 2019 19:33:38 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Jan 2019 16:33:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,488,1539673200"; d="scan'208";a="292166043" Received: from rpedgeco-desk5.jf.intel.com ([10.54.75.79]) by orsmga005.jf.intel.com with ESMTP; 16 Jan 2019 16:33:36 -0800 From: Rick Edgecombe To: Andy Lutomirski , Ingo Molnar Cc: linux-kernel@vger.kernel.org, x86@kernel.org, hpa@zytor.com, Thomas Gleixner , Borislav Petkov , Nadav Amit , Dave Hansen , Peter Zijlstra , linux_dti@icloud.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, akpm@linux-foundation.org, kernel-hardening@lists.openwall.com, linux-mm@kvack.org, will.deacon@arm.com, ard.biesheuvel@linaro.org, kristen@linux.intel.com, deneen.t.dock@intel.com, Nadav Amit , Kees Cook , Dave Hansen , Masami Hiramatsu , Rick Edgecombe Subject: [PATCH 11/17] x86/jump-label: remove support for custom poker Date: Wed, 16 Jan 2019 16:32:53 -0800 Message-Id: <20190117003259.23141-12-rick.p.edgecombe@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190117003259.23141-1-rick.p.edgecombe@intel.com> References: <20190117003259.23141-1-rick.p.edgecombe@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nadav Amit There are only two types of poking: early and breakpoint based. The use of a function pointer to perform poking complicates the code and is probably inefficient due to the use of indirect branches. Cc: Andy Lutomirski Cc: Kees Cook Cc: Peter Zijlstra Cc: Dave Hansen Cc: Masami Hiramatsu Signed-off-by: Nadav Amit Signed-off-by: Rick Edgecombe --- arch/x86/kernel/jump_label.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index e36cfec0f35e..427facef8aff 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 we're UP and not yet marked RO, we can use - * text_poke_early; SYSTEM_BOOTING guarantees both, as we switch to - * SYSTEM_SCHEDULING before going either. - */ - if (system_state == SYSTEM_BOOTING) - poker = text_poke_early; - if (type == JUMP_LABEL_JMP) { if (init) { expect = default_nop; line = __LINE__; @@ -80,16 +71,17 @@ 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 we're UP and not yet marked RO, we can use + * text_poke_early; SYSTEM_BOOTING guarantees both, as we switch to + * SYSTEM_SCHEDULING before going either. * * 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 +93,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 +123,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); } -- 2.17.1