From patchwork Fri Mar 31 09:15:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 77676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp436688vqo; Fri, 31 Mar 2023 02:42:38 -0700 (PDT) X-Google-Smtp-Source: AKy350YpWLyK4tt6Tsd5qzRhHCfBvAsDtPfghM36G/sZj+p3+ZwM3k3jfTpCHHiJq9+iS2cG1ez2 X-Received: by 2002:a05:6402:2788:b0:500:2cc6:36d5 with SMTP id b8-20020a056402278800b005002cc636d5mr9008614ede.8.1680255758189; Fri, 31 Mar 2023 02:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680255758; cv=none; d=google.com; s=arc-20160816; b=dcoTrZGwKsNragdQPrwO8iMFLGELXV/FABVm9J/kv6cDUQjPwVbastT6TaMkyJzXLE U+Yvtmvn+0cy48YSgOWVJ1DRk2KWjXiaDpi5Ud+c4KTGbdFAJ3rzITwoLvsD+5BJ5bqo hzVxE3J5J1r64TYrwjYuzS4tnyLMFBo3Gy+jNSOpzt56fRZ0KQiPQHhWP5/BclvRSvBj K8cMwSwEWwgQKz+OF0uWhkAo22pnaODonTHM5VRVj4KlIp++L/IIuEQZbIL2UdkzaUMC rFdvWNttLBpY6XpFchHPxDfEGXr2I6X6AWttBkz1/FV0s1uMswQrBQqggi0MUrg8bYfQ GJGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=5G5k7U3Kz7t2029veOnxBC6PVEl4xZjLFeVzGs5ZXt4=; b=pEuWI7rHzoI6kgZtEP4162NCsAoByZSOaiCZe0BFkv0+ouWF+42rdmU8aPdOGeAWER 7ify7VveN+9LPHMRHnx0Gctd9qiD9t4uELffSMrKjb2gjiV7+HCod6ETW+amq2tRUTIZ rEcEJH0BIml1lyP2Bwq5vmDQo4PrAnRjn+I2Kyb3BC42Kk1OA7Bc1lZxH5xGnd+ja8At wxBa5ImDZVSBFVVmNA2s6AxEqlc62/HwRO9u1rDO2kpURRyCS7KqijyDzMqNs6eDsULR Y69dQyKCakFXIqykFa93cpAWCjFm85L9P/R4X7S/VQ0jObireFsb6+w4UeVVGYNegcA0 YZ1A== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x26-20020aa7dada000000b004af7e6911b7si1346788eds.91.2023.03.31.02.42.15; Fri, 31 Mar 2023 02:42:38 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231384AbjCaJQd (ORCPT + 99 others); Fri, 31 Mar 2023 05:16:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231255AbjCaJQO (ORCPT ); Fri, 31 Mar 2023 05:16:14 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 31B249754; Fri, 31 Mar 2023 02:16:03 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8BxONnSpCZkvOQUAA--.32103S3; Fri, 31 Mar 2023 17:16:02 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxC77OpCZkVfMRAA--.14538S3; Fri, 31 Mar 2023 17:16:01 +0800 (CST) From: Tiezhu Yang To: Luis Chamberlain Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH 1/3] module: Sync code of is_arm_mapping_symbol() Date: Fri, 31 Mar 2023 17:15:51 +0800 Message-Id: <1680254153-14582-2-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1680254153-14582-1-git-send-email-yangtiezhu@loongson.cn> References: <1680254153-14582-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8DxC77OpCZkVfMRAA--.14538S3 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoW7WF1ktFy3GFWftrWDKF45KFg_yoW8WF4Upr 1DG3y5Gw4Fyr1DGayfWF1kWryUua4vqw4kA3sxKryfZFnxXFW0qr47t3W3uw1IvFy5GFsY gr1rAa45Aa4fCF7anT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWUCVW8JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAFwI0_Gr0_Cr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8P5r7UUUUU== X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761875861902201882?= X-GMAIL-MSGID: =?utf-8?q?1761875861902201882?= After commit 2e3a10a1551d ("ARM: avoid ARM binutils leaking ELF local symbols") and commit d6b732666a1b ("modpost: fix undefined behavior of is_arm_mapping_symbol()"), many differences of is_arm_mapping_symbol() exist in kernel/module/kallsyms.c and scripts/mod/modpost.c, just sync the code to keep consistent. Signed-off-by: Tiezhu Yang --- kernel/module/kallsyms.c | 5 +++-- scripts/mod/modpost.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index 3320586..a9045fe 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -251,8 +251,9 @@ static inline int is_arm_mapping_symbol(const char *str) { if (str[0] == '.' && str[1] == 'L') return true; - return str[0] == '$' && strchr("axtd", str[1]) && - (str[2] == '\0' || str[2] == '.'); + return str[0] == '$' && + (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') + && (str[2] == '\0' || str[2] == '.'); } static const char *kallsyms_symbol_name(struct mod_kallsyms *kallsyms, unsigned int symnum) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index efff807..79a27cc 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1114,6 +1114,8 @@ static int secref_whitelist(const struct sectioncheck *mismatch, static inline int is_arm_mapping_symbol(const char *str) { + if (str[0] == '.' && str[1] == 'L') + return true; return str[0] == '$' && (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') && (str[2] == '\0' || str[2] == '.'); From patchwork Fri Mar 31 09:15:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 77678 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp437075vqo; Fri, 31 Mar 2023 02:43:40 -0700 (PDT) X-Google-Smtp-Source: AKy350b4zxSi8SsTdF5sFVHL9Oj1CPtSPknwpvq7dVxFKvgYhBSempHob49mml+kQLxQ11xtICy0 X-Received: by 2002:a17:906:eda4:b0:947:a3ed:df91 with SMTP id sa4-20020a170906eda400b00947a3eddf91mr1752829ejb.70.1680255819896; Fri, 31 Mar 2023 02:43:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680255819; cv=none; d=google.com; s=arc-20160816; b=f/cTc6rjRybb7EnulvAok2qUOYkDbWu9Hpzv6w8vGNa+jDwecSPc31M68H7eSr0MHJ bFathUxtF0eR4yykLPWksJ3/b6OC4NYony7Tsq2HKjBbL3LadhUKzFXKiyrxyIUzUChS UVJo4EBxhtEL7I81XJQgHMNyB41RMk6UNWOdDJAmAYXdJClsO58dp4Iu2oc6Q6Y4wjJ2 z5QMqewW6MQi5SSp44pdAAk9VXJkkmI5EhcoXmnmTVhz6SICM+PjjRAWjT7eF7URFU+U LBE3WjbmwRY5r/AipWU/1mj5NozRELExXnL5BnFNJdH0iUbiUsqAQfgPwjOW9hY1zkNJ JYFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=hriaiYyqJf+L3ROtnONYx1hi35PN+XcbvnB6Mqs3Tqw=; b=hVwmBroKlrMuk4l3lg2MGrCiIHMnVP3XoJbnndqVFitAVm8d7wefiFXsV9KQYC1Kq2 Hdn9iTGHgEnz8kMkzV9aPy+8V5K5Lj2/OW99wtGu7HxgMsIKywb1sFwk8U4pazcCpbVA ky2AOsGXYEzcJAfrsNfqfsW1k1iO4f5JRrUcCmd+ZsNHigpFLZJN2gbGKTrWmD3TEijA Yeu35DBI4SAi+QovSlo9JSo9oHZRDgd8CWj49jHQewKF0D1RcQGwQyjQoTk42bPUvaeq tADa0/SMhY6Nn6LIUnuVAFLxxZettDDZRytgiN8sfKwze8uxXmSGmcGuQ2rtiGH0CRRP bQXA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lo1-20020a170906fa0100b00933314f56fdsi1489930ejb.737.2023.03.31.02.43.15; Fri, 31 Mar 2023 02:43:39 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231703AbjCaJQf (ORCPT + 99 others); Fri, 31 Mar 2023 05:16:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231268AbjCaJQO (ORCPT ); Fri, 31 Mar 2023 05:16:14 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 69655C173; Fri, 31 Mar 2023 02:16:04 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8DxUOXTpCZkv+QUAA--.32142S3; Fri, 31 Mar 2023 17:16:03 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxC77OpCZkVfMRAA--.14538S4; Fri, 31 Mar 2023 17:16:02 +0800 (CST) From: Tiezhu Yang To: Luis Chamberlain Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH 2/3] module: Move is_arm_mapping_symbol() to module_symbol.h Date: Fri, 31 Mar 2023 17:15:52 +0800 Message-Id: <1680254153-14582-3-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1680254153-14582-1-git-send-email-yangtiezhu@loongson.cn> References: <1680254153-14582-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8DxC77OpCZkVfMRAA--.14538S4 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxAr18Gr1UWw1DCF47ArWfGrg_yoW5Cr1xpF n8Cw4rJr4rAr1UGa4fuw1vyr13uw4vgr4jyr9xKryxZrnIqF1vqrZrKr1Yvw1xXrZrGF40 9r4fZFW3CFWfZaUanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8QJ57UUUUU== X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761875926677734227?= X-GMAIL-MSGID: =?utf-8?q?1761875926677734227?= In order to avoid duplicated code, move is_arm_mapping_symbol() to include/linux/module_symbol.h, then remove is_arm_mapping_symbol() in the other places. Signed-off-by: Tiezhu Yang --- include/linux/module_symbol.h | 15 +++++++++++++++ kernel/module/kallsyms.c | 14 +------------- scripts/mod/modpost.c | 10 +--------- 3 files changed, 17 insertions(+), 22 deletions(-) create mode 100644 include/linux/module_symbol.h diff --git a/include/linux/module_symbol.h b/include/linux/module_symbol.h new file mode 100644 index 0000000..9fa4173 --- /dev/null +++ b/include/linux/module_symbol.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _LINUX_MODULE_SYMBOL_H +#define _LINUX_MODULE_SYMBOL_H + +/* This ignores the intensely annoying "mapping symbols" found in ELF files. */ +static inline int is_arm_mapping_symbol(const char *str) +{ + if (str[0] == '.' && str[1] == 'L') + return true; + return str[0] == '$' && + (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') + && (str[2] == '\0' || str[2] == '.'); +} + +#endif /* _LINUX_MODULE_SYMBOL_H */ diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index a9045fe..5de3207 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -243,19 +244,6 @@ void init_build_id(struct module *mod, const struct load_info *info) } #endif -/* - * This ignores the intensely annoying "mapping symbols" found - * in ARM ELF files: $a, $t and $d. - */ -static inline int is_arm_mapping_symbol(const char *str) -{ - if (str[0] == '.' && str[1] == 'L') - return true; - return str[0] == '$' && - (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') - && (str[2] == '\0' || str[2] == '.'); -} - static const char *kallsyms_symbol_name(struct mod_kallsyms *kallsyms, unsigned int symnum) { return kallsyms->strtab + kallsyms->symtab[symnum].st_name; diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 79a27cc..7241db8 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -22,6 +22,7 @@ #include #include "modpost.h" #include "../../include/linux/license.h" +#include "../../include/linux/module_symbol.h" /* Are we using CONFIG_MODVERSIONS? */ static bool modversions; @@ -1112,15 +1113,6 @@ static int secref_whitelist(const struct sectioncheck *mismatch, return 1; } -static inline int is_arm_mapping_symbol(const char *str) -{ - if (str[0] == '.' && str[1] == 'L') - return true; - return str[0] == '$' && - (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') - && (str[2] == '\0' || str[2] == '.'); -} - /* * If there's no name there, ignore it; likewise, ignore it if it's * one of the magic symbols emitted used by current ARM tools. From patchwork Fri Mar 31 09:15:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 77672 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp436579vqo; Fri, 31 Mar 2023 02:42:23 -0700 (PDT) X-Google-Smtp-Source: AKy350bA5XRsJk/5VHAqP6sVE+1oBaF6JCGRG+Xivfi6XcWLejM2n5kVloyzuefLMeiE5DBM2F9N X-Received: by 2002:a05:6402:483:b0:502:4c82:9b4d with SMTP id k3-20020a056402048300b005024c829b4dmr15425528edv.15.1680255743020; Fri, 31 Mar 2023 02:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680255743; cv=none; d=google.com; s=arc-20160816; b=0b4nNmYOL4ue+XQ2SUxGBKtRj6HGhJCeTPocs5/YNC0LvR51ZS+eBazXWAC+lI3Uea 84siJ57DpCw5qisuhpfYGlvjQzCWlcj9/c1e8kH+kuAJ2oUh5TKkQf9wee/DB7lFcfru F1PaNkLhG59bDPuZsoQFZM9r33/afAVw96oifOXk1GIrUjkFlnrBoaN9wO4sW/rP2W0n IGxZ5BizLtXKhoB+C8A8tFTsY/xvb1V6OyHk5ppTIrhlFF4+Hocw/akTNRq3gwPOxMp6 oE6N237S03bfgv4nyQ2djCypeAs1Gx+pXzOqHIOhTl0rXCTIVFPw0k4B+SKCtihcqUFL iJ5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Pfj+scP2SWKT7QCeYhFefAjTj332R55AnJEPJ470Kjs=; b=nF4k5bKGK3HWwX/9qU4tuanEpJHrFoX4nMQn+Y1wKbGPIspV+KSgKR89i2UibCmeMF MUBOEYTFXTLVFx+uig2DL7yU9Sl3ualwQuHzRYoJwv7fW8wGnjLKk23aL3j9nb9Hl3gv h2I40mvr3z8vm+3XkMGp2ErSGEGCgcdpZ7SDcUVShce0hMbhgkv3jO39e6v63gAjmLgM N6K9EavJOYFnGFix1LkrKqXlTzz8gsUCrga1OWMm+Y44CP4K9J7BphWSA3PQJWhijRZw bMBL08poJF3EoeqqTQGcE7urwNt6nI2cVdyuZ+8xAh8u7xWXGVhyyD0pBsrJSbl6IaKP 7Mrw== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q21-20020a056402041500b004ff8ffb32eesi892407edv.572.2023.03.31.02.41.59; Fri, 31 Mar 2023 02:42:22 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231968AbjCaJQi (ORCPT + 99 others); Fri, 31 Mar 2023 05:16:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231284AbjCaJQP (ORCPT ); Fri, 31 Mar 2023 05:16:15 -0400 Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BDAC812BCE; Fri, 31 Mar 2023 02:16:05 -0700 (PDT) Received: from loongson.cn (unknown [113.200.148.30]) by gateway (Coremail) with SMTP id _____8AxrtrUpCZkwuQUAA--.20587S3; Fri, 31 Mar 2023 17:16:04 +0800 (CST) Received: from linux.localdomain (unknown [113.200.148.30]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxC77OpCZkVfMRAA--.14538S5; Fri, 31 Mar 2023 17:16:03 +0800 (CST) From: Tiezhu Yang To: Luis Chamberlain Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: [PATCH 3/3] module: Ignore L0 and rename is_arm_mapping_symbol() Date: Fri, 31 Mar 2023 17:15:53 +0800 Message-Id: <1680254153-14582-4-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1680254153-14582-1-git-send-email-yangtiezhu@loongson.cn> References: <1680254153-14582-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf8DxC77OpCZkVfMRAA--.14538S5 X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ X-Coremail-Antispam: 1Uk129KBjvJXoWxJw4kWw48Ar4fXFWxZFyrWFg_yoW7JrW8pr y5Cr45GF48Ar1DGay7Wa4Dtr15W3s7uFs7Cry5K3s7Crn0qr1Ivw4DK3W3uwnrAr45Gay8 uFsayFyakFy5JaDanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b7AYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJVW0owAS 0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc02F40EFcxC0V AKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAFwI0_Gr0_Cr1l Ox8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7VAKI48JMxC20s 026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_ JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14 v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xva j40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x0267AKxVW8JV W8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8l38UUUUUU== X-Spam-Status: No, score=-0.0 required=5.0 tests=SPF_HELO_PASS,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761875846095103589?= X-GMAIL-MSGID: =?utf-8?q?1761875846095103589?= The L0 symbol is generated when build module on LoongArch, ignore it in modpost and when looking at module symbols, otherwise we can not see the expected call trace. Now is_arm_mapping_symbol() is not only for ARM, in order to reflect the reality, rename is_arm_mapping_symbol() to is_mapping_symbol(). This is related with commit c17a2538704f ("mksysmap: Fix the mismatch of 'L0' symbols in System.map"). (1) Simple test case [loongson@linux hello]$ cat hello.c #include #include #include static void test_func(void) { pr_info("This is a test\n"); dump_stack(); } static int __init hello_init(void) { pr_warn("Hello, world\n"); test_func(); return 0; } static void __exit hello_exit(void) { pr_warn("Goodbye\n"); } module_init(hello_init); module_exit(hello_exit); MODULE_LICENSE("GPL"); [loongson@linux hello]$ cat Makefile obj-m:=hello.o ccflags-y += -g -Og all: make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build/ M=$(PWD) clean (2) Test environment system: LoongArch CLFS 5.5 https://github.com/sunhaiyong1978/CLFS-for-LoongArch/releases/tag/5.0 It needs to update grub to avoid booting error "invalid magic number". kernel: 6.3-rc1 with loongson3_defconfig + CONFIG_DYNAMIC_FTRACE=y (3) Test result Without this patch: [root@linux hello]# insmod hello.ko [root@linux hello]# dmesg ... Hello, world This is a test ... Call Trace: [<9000000000223728>] show_stack+0x68/0x18c [<90000000013374cc>] dump_stack_lvl+0x60/0x88 [] L0\x01+0x20/0x2c [hello] [] L0\x01+0x20/0x30 [hello] [<900000000022097c>] do_one_initcall+0x88/0x288 [<90000000002df890>] do_init_module+0x54/0x200 [<90000000002e1e18>] __do_sys_finit_module+0xc4/0x114 [<90000000013382e8>] do_syscall+0x7c/0x94 [<9000000000221e3c>] handle_syscall+0xbc/0x158 With this patch: [root@linux hello]# insmod hello.ko [root@linux hello]# dmesg ... Hello, world This is a test ... Call Trace: [<9000000000223728>] show_stack+0x68/0x18c [<90000000013374cc>] dump_stack_lvl+0x60/0x88 [] test_func+0x28/0x34 [hello] [] hello_init+0x28/0x38 [hello] [<900000000022097c>] do_one_initcall+0x88/0x288 [<90000000002df890>] do_init_module+0x54/0x200 [<90000000002e1e18>] __do_sys_finit_module+0xc4/0x114 [<90000000013382e8>] do_syscall+0x7c/0x94 [<9000000000221e3c>] handle_syscall+0xbc/0x158 Signed-off-by: Tiezhu Yang Tested-by: Youling Tang # for LoongArch --- include/linux/module_symbol.h | 4 +++- kernel/module/kallsyms.c | 2 +- scripts/mod/modpost.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/linux/module_symbol.h b/include/linux/module_symbol.h index 9fa4173..7ace7ba 100644 --- a/include/linux/module_symbol.h +++ b/include/linux/module_symbol.h @@ -3,10 +3,12 @@ #define _LINUX_MODULE_SYMBOL_H /* This ignores the intensely annoying "mapping symbols" found in ELF files. */ -static inline int is_arm_mapping_symbol(const char *str) +static inline int is_mapping_symbol(const char *str) { if (str[0] == '.' && str[1] == 'L') return true; + if (str[0] == 'L' && str[1] == '0') + return true; return str[0] == '$' && (str[1] == 'a' || str[1] == 'd' || str[1] == 't' || str[1] == 'x') && (str[2] == '\0' || str[2] == '.'); diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index 5de3207..d8e426a 100644 --- a/kernel/module/kallsyms.c +++ b/kernel/module/kallsyms.c @@ -289,7 +289,7 @@ static const char *find_kallsyms_symbol(struct module *mod, * and inserted at a whim. */ if (*kallsyms_symbol_name(kallsyms, i) == '\0' || - is_arm_mapping_symbol(kallsyms_symbol_name(kallsyms, i))) + is_mapping_symbol(kallsyms_symbol_name(kallsyms, i))) continue; if (thisval <= addr && thisval > bestval) { diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 7241db8..5cddf76 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1115,7 +1115,7 @@ static int secref_whitelist(const struct sectioncheck *mismatch, /* * If there's no name there, ignore it; likewise, ignore it if it's - * one of the magic symbols emitted used by current ARM tools. + * one of the magic symbols emitted used by current tools. * * Otherwise if find_symbols_between() returns those symbols, they'll * fail the whitelist tests and cause lots of false alarms ... fixable @@ -1128,7 +1128,7 @@ static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym) if (!name || !strlen(name)) return 0; - return !is_arm_mapping_symbol(name); + return !is_mapping_symbol(name); } /**