From patchwork Fri Mar 17 09:56:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viktor Malik X-Patchwork-Id: 71224 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp252484wrt; Fri, 17 Mar 2023 03:17:03 -0700 (PDT) X-Google-Smtp-Source: AK7set86GFR8QfTIYE05EZLjFXTf9ONUf7gf/tW9qpjc7TRg5oxQA5K2QHcWLW368qiGbF8BiPYA X-Received: by 2002:a05:6a00:32c7:b0:5db:aa2d:9ea0 with SMTP id cl7-20020a056a0032c700b005dbaa2d9ea0mr7147785pfb.2.1679048222849; Fri, 17 Mar 2023 03:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679048222; cv=none; d=google.com; s=arc-20160816; b=e6nv53NrLe7A/3b6a4rh3ucdVuXDiUeVowUnACh9s+m0rxdJaO9rBloJI1GMseyXIU pPgTeL+tiZ2RW2uFlbbmvgWLyc+4FcYF6nHkHF3Mh5Id/du1J0yQkoXc/m5QrbRHS2ZQ RLJ4N8gN+/vgSVpWhu+8Tay/2Zpv5tEHVdVIxPzAv4nAzK/9OmO+V7ww1AqtxwmtETbZ bX/EEOJpdwLK5ZGd/DBmtwGVq66O/pDXWK7f6igyhgKhuyGjSOlDS+4DJrKVjeb18diM +4BhanOtazDvwX7ZgYHzJ8OWlu5xbo17bOHMTfZ1JOs8QNyoats8nlkSsinUxl/ixMmy KPIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=c8I+qykTI74Ab/VGldPB2UipRn0pmrBXTGeZi/iZopU=; b=zCMnTPJNNIB4HaWpGyYBn9RY0wDnq93yUNYD5D2XOPctCyCnUCf2twB3R4pplWjLaF 5FFHP0n/61y/VCWpdOCq5aVnz0TIiap61GpMSGGxG4clYYcLgXiPcGjwsCEZW/N068LV i/Gur6TTZiB5BFVysBf7MHnapDj2dQAndZHJKxz0LqWzO0N8aimoZ410T1opD2hKXgxM YvTurWB7UdkOaV1yw67VY3VT7z8O1YTg3vGT9l0HTuSj6D5UY7P4ZQjBf6Snj89SEk0h S18zBKvrW4Z5ZhXHI14VqPjS9S9CfIQum+CYaAWU1FWBWt4asd56iSU7DVgu+QzZvPyA K1rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bHnwexfl; 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=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q16-20020a631f50000000b0050b1a0068d3si1860484pgm.102.2023.03.17.03.16.50; Fri, 17 Mar 2023 03:17:02 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bHnwexfl; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230084AbjCQJ5Y (ORCPT + 99 others); Fri, 17 Mar 2023 05:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230137AbjCQJ5V (ORCPT ); Fri, 17 Mar 2023 05:57:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77767E63D3 for ; Fri, 17 Mar 2023 02:56:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679046977; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=c8I+qykTI74Ab/VGldPB2UipRn0pmrBXTGeZi/iZopU=; b=bHnwexfl8HC3ZMzwVtPdSOI7UWrc/yGK9tZgYo0ztgOeUwdhSyLkaq6HMoHJwpEpO0N5Ew kgQLL8s94zPMvEyD0pbPmlwG5EwzoZZIC9kF9t3VV5pmyG+9mbfwk9GfVg1maEQLLu1LJP qRRCd1f9Na51WfPwZ41TIm56gTLxt3s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-207-Ig_oibI_OreWsZwzXHgosg-1; Fri, 17 Mar 2023 05:56:16 -0400 X-MC-Unique: Ig_oibI_OreWsZwzXHgosg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 56D4F185A78B; Fri, 17 Mar 2023 09:56:15 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.150]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0C60483EC0; Fri, 17 Mar 2023 09:56:11 +0000 (UTC) From: Viktor Malik To: bpf@vger.kernel.org Cc: Luis Chamberlain , Alexei Starovoitov , Daniel Borkmann , John Fastabend , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, Viktor Malik , kernel test robot Subject: [PATCH bpf-next] kallsyms: move find_kallsyms_symbol_value out of internal header Date: Fri, 17 Mar 2023 10:56:01 +0100 Message-Id: <20230317095601.386738-1-vmalik@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760609669226128773?= X-GMAIL-MSGID: =?utf-8?q?1760609669226128773?= Moving find_kallsyms_symbol_value from kernel/module/internal.h to include/linux/module.h. The reason is that internal.h is not prepared to be included when CONFIG_MODULES=n. find_kallsyms_symbol_value is used by kernel/bpf/verifier.c and including internal.h from it (without modules) leads into a compilation error: In file included from ../include/linux/container_of.h:5, from ../include/linux/list.h:5, from ../include/linux/timer.h:5, from ../include/linux/workqueue.h:9, from ../include/linux/bpf.h:10, from ../include/linux/bpf-cgroup.h:5, from ../kernel/bpf/verifier.c:7: ../kernel/bpf/../module/internal.h: In function 'mod_find': ../include/linux/container_of.h:20:54: error: invalid use of undefined type 'struct module' 20 | static_assert(__same_type(*(ptr), ((type *)0)->member) || \ | ^~ [...] This patch fixes the above error. Signed-off-by: Viktor Malik Reported-by: kernel test robot Link: https://lore.kernel.org/oe-kbuild-all/202303161404.OrmfCy09-lkp@intel.com/ --- include/linux/module.h | 8 ++++++++ kernel/bpf/verifier.c | 2 +- kernel/module/internal.h | 6 ------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/linux/module.h b/include/linux/module.h index 4435ad9439ab..41cfd3be57e5 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -616,6 +616,8 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, /* Look for this name: can be of form module:name. */ unsigned long module_kallsyms_lookup_name(const char *name); +unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name); + extern void __noreturn __module_put_and_kthread_exit(struct module *mod, long code); #define module_put_and_kthread_exit(code) __module_put_and_kthread_exit(THIS_MODULE, code) @@ -796,6 +798,12 @@ static inline unsigned long module_kallsyms_lookup_name(const char *name) return 0; } +static inline unsigned long find_kallsyms_symbol_value(struct module *mod, + const char *name) +{ + return 0; +} + static inline int register_module_notifier(struct notifier_block *nb) { /* no events will happen anyway, so this can always succeed */ diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index d62b7127ff2a..99394a2f7ee4 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -24,7 +24,7 @@ #include #include #include -#include "../module/internal.h" +#include #include "disasm.h" diff --git a/kernel/module/internal.h b/kernel/module/internal.h index 5c9170f9135c..1c877561a7d2 100644 --- a/kernel/module/internal.h +++ b/kernel/module/internal.h @@ -246,7 +246,6 @@ static inline void kmemleak_load_module(const struct module *mod, void init_build_id(struct module *mod, const struct load_info *info); void layout_symtab(struct module *mod, struct load_info *info); void add_kallsyms(struct module *mod, const struct load_info *info); -unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name); static inline bool sect_empty(const Elf_Shdr *sect) { @@ -256,11 +255,6 @@ static inline bool sect_empty(const Elf_Shdr *sect) static inline void init_build_id(struct module *mod, const struct load_info *info) { } static inline void layout_symtab(struct module *mod, struct load_info *info) { } static inline void add_kallsyms(struct module *mod, const struct load_info *info) { } -static inline unsigned long find_kallsyms_symbol_value(struct module *mod, - const char *name) -{ - return 0; -} #endif /* CONFIG_KALLSYMS */ #ifdef CONFIG_SYSFS