From patchwork Thu Jan 17 00:32:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgecombe, Rick P" X-Patchwork-Id: 10767287 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 10B286C2 for ; Thu, 17 Jan 2019 00:34:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 167702E1E1 for ; Thu, 17 Jan 2019 00:34:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 089E22E297; Thu, 17 Jan 2019 00:34:25 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 808FD2E2B7 for ; Thu, 17 Jan 2019 00:34:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2AC38E000B; Wed, 16 Jan 2019 19:33:41 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E27808E0015; Wed, 16 Jan 2019 19:33:41 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 995908E0012; Wed, 16 Jan 2019 19:33:41 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 496498E000E for ; Wed, 16 Jan 2019 19:33:41 -0500 (EST) Received: by mail-pg1-f197.google.com with SMTP id d71so5039695pgc.1 for ; Wed, 16 Jan 2019 16:33:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=1oCH1vqwofeA+CR+BzYGyrdjwP4k7rQNDYFA/zzkTDg=; b=H2yBR3BxIbEpSpY27XDBkLr6TGAthIe6B3ynoebJs046LM3Q0iQQGrYLG5wOXHUEVy 4O6AsQoQ0LBTVh9ZWA41CI44hb6kanuDLmHj+5A5YuZHi9piUbNNNTDT5W86+dWYzroi l3U+OIBxJbHalav9J8Y1PMiJkQn90MK+tGG8eCIOQjedX0KdW6fXaAZY5Hk/FPBNvcSk OSSzYRgAV18mQ++VNB8YAOwc36Qt3Q4r3spSYl7ruVwzU0j4c6r31acEIHdC4hqH2iml bZFsYGmBtHcrhgxTgxznJARZHGpYxJ3YGhkP8WqmMVlqd6KZze59XdrblZFZubZj688Q I6Rw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Gm-Message-State: AJcUukcWfSNKwMoNynFXPrzfIBnMd2d7XsVlkWLi2N7+zINYLZwW6PEb tUHi8GyqjR5vhvluB+P3ZZ6/AOtOlsektBtzDHdU/iHSihO7qGRdHGgDKgFJT7iXdhZ8RM4Huz8 geTOJpYaC7iL2HYSTQjFl2Qr7l0jO22TtuoyD4fuet6Czz5v7tlmSvYmjBbXlTvHabQ== X-Received: by 2002:a63:f201:: with SMTP id v1mr10826948pgh.232.1547685220470; Wed, 16 Jan 2019 16:33:40 -0800 (PST) X-Google-Smtp-Source: ALg8bN422vP6ZRjAdeXzcxhYUK/FBHmouT/KJ38p6lX95WIwqK9bMjzBtwRZtWhv2FSWEBT11NFZ X-Received: by 2002:a63:f201:: with SMTP id v1mr10826896pgh.232.1547685219711; Wed, 16 Jan 2019 16:33:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547685219; cv=none; d=google.com; s=arc-20160816; b=nxiOiIy1+bdxyV47dmUhRb4pk8JS32B/vX315fCzeFfQSyKbVjgDoxm8aks0g9gmgt JmgyB9KAKhzfVzIwapav97wseWimhBQV+v5a7uEq6dZwemm30i98Luia//qmkaeDFQmS EjMwcVTf9ueEMbZ0VNuLUrrMOIhZ5ZJN3O2xmZAmusWJds6WbTcnaEk0poMxyKv919x7 GwTXT9CbFvXS1m3+JTl95LSfgnV7oqdqZ/yimprhojK8UOmQufxOJUkGHpU1aY+KzvxG SfIusefqDZoGsQJGj8vOVNOQ/Ete3AFFRQZReDvxKmZ7baSWPr1SGXImvDjulGsMOcOG K+LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=1oCH1vqwofeA+CR+BzYGyrdjwP4k7rQNDYFA/zzkTDg=; b=X3dG/oPhpcKoB1oa2/VKcOcQvR1wcILZZzwwlAp0jrEVAmDooFfVY3uQbCIyo0tNT1 OFeK6RO9dVXslQl6pBswfFL90oDboAakLXW0SV6Eggd8G10rMB4zw9KPrwA/iuN5x2VF 7cBUDvMS7WUQbyoOT4Gr8qQqGeSIYWocn6aiS4C/ZApNSi5hSLNZfMKkFjCyQoHCRwKW /sjolCPmaEWiRuXLmFzZ7fparKOiEkoIWjzlrREHSoRJngsZDqUFInfDkt3Bhx0ZFfm9 AkgedoM0xVfQF+FK5GM7Uzu8/zDJqyrNQ4c5djv2sqRUbF883QWPRcA6rm6oWafhErvI kxgQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from mga04.intel.com (mga04.intel.com. [192.55.52.120]) by mx.google.com with ESMTPS id y10si7582915plt.406.2019.01.16.16.33.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Jan 2019 16:33:39 -0800 (PST) Received-SPF: pass (google.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.120 as permitted sender) client-ip=192.55.52.120; Authentication-Results: mx.google.com; spf=pass (google.com: domain of rick.p.edgecombe@intel.com designates 192.55.52.120 as permitted sender) smtp.mailfrom=rick.p.edgecombe@intel.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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); }