History

kallsyms, bpf: Move find_kallsyms_symbol_value out of internal header

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.

Viktor Malik committed 3 years ago

Commit bd5314f1 parent 94bbbdf3 files · +9 −7Browse files

Unified · Split

3 files
  1. include/linux/module.h +8 −0
  2. kernel/bpf/verifier.c +1 −1
  3. kernel/module/internal.h +0 −6
include/linux/module.h+8−0
@@ -616,6 +616,8 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type, · 615 unmodified lines
616/* Look for this name: can be of form module:name. */616/* Look for this name: can be of form module:name. */
617unsigned long module_kallsyms_lookup_name(const char *name);617unsigned long module_kallsyms_lookup_name(const char *name);
618 618
619unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name);
620
619extern void __noreturn __module_put_and_kthread_exit(struct module *mod,621extern void __noreturn __module_put_and_kthread_exit(struct module *mod,
620 long code);622 long code);
621#define module_put_and_kthread_exit(code) __module_put_and_kthread_exit(THIS_MODULE, code)623#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) · 174 unmodified lines
796 return 0;798 return 0;
797}799}
798 800
801static inline unsigned long find_kallsyms_symbol_value(struct module *mod,
802 const char *name)
803{
804 return 0;
805}
806
799static inline int register_module_notifier(struct notifier_block *nb)807static inline int register_module_notifier(struct notifier_block *nb)
800{808{
801 /* no events will happen anyway, so this can always succeed */809 /* no events will happen anyway, so this can always succeed */
kernel/bpf/verifier.c+1−1
@@ -24,7 +24,7 @@ · 23 unmodified lines
24#include <linux/bpf_lsm.h>24#include <linux/bpf_lsm.h>
25#include <linux/btf_ids.h>25#include <linux/btf_ids.h>
26#include <linux/poison.h>26#include <linux/poison.h>
27#include "../module/internal.h"27#include <linux/module.h>
28 28
29#include "disasm.h"29#include "disasm.h"
30 30
kernel/module/internal.h+0−6
@@ -246,7 +246,6 @@ static inline void kmemleak_load_module(const struct module *mod, · 245 unmodified lines
246void init_build_id(struct module *mod, const struct load_info *info);246void init_build_id(struct module *mod, const struct load_info *info);
247void layout_symtab(struct module *mod, struct load_info *info);247void layout_symtab(struct module *mod, struct load_info *info);
248void add_kallsyms(struct module *mod, const struct load_info *info);248void add_kallsyms(struct module *mod, const struct load_info *info);
249unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name);
250 249
251static inline bool sect_empty(const Elf_Shdr *sect)250static inline bool sect_empty(const Elf_Shdr *sect)
252{251{
@@ -256,11 +255,6 @@ static inline bool sect_empty(const Elf_Shdr *sect) · 3 unmodified lines
256static inline void init_build_id(struct module *mod, const struct load_info *info) { }255static inline void init_build_id(struct module *mod, const struct load_info *info) { }
257static inline void layout_symtab(struct module *mod, struct load_info *info) { }256static inline void layout_symtab(struct module *mod, struct load_info *info) { }
258static inline void add_kallsyms(struct module *mod, const struct load_info *info) { }257static inline void add_kallsyms(struct module *mod, const struct load_info *info) { }
259static inline unsigned long find_kallsyms_symbol_value(struct module *mod,
260 const char *name)
261{
262 return 0;
263}
264#endif /* CONFIG_KALLSYMS */258#endif /* CONFIG_KALLSYMS */
265 259
266#ifdef CONFIG_SYSFS260#ifdef CONFIG_SYSFS