Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3894503rwb; Sat, 21 Jan 2023 02:13:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXsG2r9+8qqr/N5sEFXVQryQLExpnmxj094JmASR6Ml9wOx42CXS4S59H87ejElIJ4PgsGMn X-Received: by 2002:a05:6402:174d:b0:494:eb9:54c4 with SMTP id v13-20020a056402174d00b004940eb954c4mr16786107edx.19.1674296018076; Sat, 21 Jan 2023 02:13:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674296018; cv=none; d=google.com; s=arc-20160816; b=k9GkkO4m8gE0XKYZ3/1yGOCvNFCjy1X0qE5N2ztzsOg5ti7mCsObknPoEolknOjtda plCQVP5S8Z55gRQAZdvTa8Al/gw82XzRbucRmGYqf1Qo04XC/ZrGPEy/lXf8p7yWcxS+ GeKKjL31QNqm61kwNO8qp+340NuhKpkcdFXfLflevofRXgFoni8iLQ3oq98V/qpikng3 wfSzjF3T95W7euLXdLqChMiZI1cHN6+6nlw0NstnI0ZHO5Yz0aPdRBW9NmwNII9aMYlI IL+fo1X3XvoDynDaMiXGcr3176+3vo9B3o/MEajbvvAKTZ1UnYoNNWzlNlZ18IZhEd92 p/Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=pmtBArXGsLKsmisCNbGh0SET3ImTh+pYPr5K7kZMwHY=; b=yuCBVu9f2bkxkOz2Jy1ZvB1ZHX4uL4ooXLQa87LF6LqusoVebZ/7QZehR3BIfDD81Z AUO7BtuYE3YkxJUa+KeE2C6CgIK/F36yCT8j2wxheYos3Of1k0JGqZQiyCsWnCKT4hye 3/MZJdGKX5rVAdzYLS4aZb6oemSQJ9fBYi+HySfZD17g4ZslBJQvZ4CiiB3zRP9B92+Y zrlps5DrF2Qq3F0iYD7kPWtSV6uchGdu/uapijrUQ7BQm+wgeJBFYYwAw3OEDnK2UAXC uX2EwxYSgbaxFcqTjHoBrO4u2XdkXnns+HrkopwslCIbcr1v5VmTFD77qsUihLZN/dXf oK+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Hg/rIklR"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=4KDZn+IA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb11-20020a0564020d0b00b0047866149cdasi18348959edb.388.2023.01.21.02.13.19; Sat, 21 Jan 2023 02:13:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="Hg/rIklR"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=4KDZn+IA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229587AbjAUJ53 (ORCPT + 52 others); Sat, 21 Jan 2023 04:57:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbjAUJ51 (ORCPT ); Sat, 21 Jan 2023 04:57:27 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59EE81353B; Sat, 21 Jan 2023 01:57:26 -0800 (PST) Date: Sat, 21 Jan 2023 09:57:24 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1674295045; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pmtBArXGsLKsmisCNbGh0SET3ImTh+pYPr5K7kZMwHY=; b=Hg/rIklRGW36JdCrETInvtXNarbgoLaY/lOyUy6Ak93NEddtHldMfBhO6RcB10IA66ylqH 0awaLLvDoonsItIP7g55GJ0J9tptABoqG1T4t2xPBh2owNGBpdMtjniBP0KGR0MlkZuKRm cFcf3dqM5OEqXNFiS/bKZbrekTRhnWCJt7cSdSLX7AzM2/dJ+FIf8kCq8sZcUuYCWeTDoh dytmtbGeGmRN60lEGQeiO+G2YqHSNJO47oe1NtgIikXy8Sd64rZJLCOo9lV9NhbnmRL++L FxXPSSqr5b3KQOkgvGHoLybtLU7Rou6yRDqgbaThdPmU3hQTfa0w/gDpGMqlOw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1674295045; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pmtBArXGsLKsmisCNbGh0SET3ImTh+pYPr5K7kZMwHY=; b=4KDZn+IABRzw2ZpOJRb75NFBCHriMBZyXnDEBktL1lRqedAeqHcvhKEwXBD7lVM+Z4f2Up l8GMnzHuTSQ/ufBA== From: "tip-bot2 for Michal Kubecek" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: objtool/core] objtool: Check that module init/exit function is an indirect call target Cc: Michal Kubecek , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230118105215.B9DA960514@lion.mk-sys.cz> References: <20230118105215.B9DA960514@lion.mk-sys.cz> MIME-Version: 1.0 Message-ID: <167429504442.4906.8670860752531771829.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the objtool/core branch of tip: Commit-ID: 03d7a1053cf72372be22b43faada5bca12ff183d Gitweb: https://git.kernel.org/tip/03d7a1053cf72372be22b43faada5bca12ff183d Author: Michal Kubecek AuthorDate: Wed, 18 Jan 2023 11:52:15 +01:00 Committer: Peter Zijlstra CommitterDate: Sat, 21 Jan 2023 10:50:18 +01:00 objtool: Check that module init/exit function is an indirect call target Some out-of-tree modules still do not use module_init() / module_exit() macros and simply create functions with magic names init_module() and cleanup_module() instead. As a result, these functions are not recognized as indirect call targets by objtool and such module fails to load into an IBT enabled kernel. This old way is not even documented any more but it is cleaner to issue a warning than to let the module fail on load without obvious reason. Signed-off-by: Michal Kubecek Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20230118105215.B9DA960514@lion.mk-sys.cz --- tools/objtool/Documentation/objtool.txt | 8 ++++++++ tools/objtool/check.c | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/tools/objtool/Documentation/objtool.txt b/tools/objtool/Documentation/objtool.txt index 8a67190..8e53fc6 100644 --- a/tools/objtool/Documentation/objtool.txt +++ b/tools/objtool/Documentation/objtool.txt @@ -410,6 +410,14 @@ the objtool maintainers. can remove this warning by putting the ANNOTATE_INTRA_FUNCTION_CALL directive right before the call. +12. file.o: warning: func(): not an indirect call target + + This means that objtool is running with --ibt and a function expected + to be an indirect call target is not. In particular, this happens for + init_module() or cleanup_module() if a module relies on these special + names and does not use module_init() / module_exit() macros to create + them. + If the error doesn't seem to make sense, it could be a bug in objtool. Feel free to ask the objtool maintainer for help. diff --git a/tools/objtool/check.c b/tools/objtool/check.c index cab1a16..7c40bd5 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -847,8 +847,15 @@ static int create_ibt_endbr_seal_sections(struct objtool_file *file) list_for_each_entry(insn, &file->endbr_list, call_node) { int *site = (int *)sec->data->d_buf + idx; + struct symbol *sym = insn->sym; *site = 0; + if (opts.module && sym && sym->type == STT_FUNC && + insn->offset == sym->offset && + (!strcmp(sym->name, "init_module") || + !strcmp(sym->name, "cleanup_module"))) + WARN("%s(): not an indirect call target", sym->name); + if (elf_add_reloc_to_insn(file->elf, sec, idx * sizeof(int), R_X86_64_PC32,