Skip to content

Commit bd5314f

Browse files
viktormalikborkmann
authored andcommitted
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. Fixes: 31bf1db ("bpf: Fix attaching fentry/fexit/fmod_ret/lsm to modules") Reported-by: kernel test robot <[email protected]> Signed-off-by: Viktor Malik <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/ Link: https://lore.kernel.org/bpf/[email protected]
1 parent 94bbbdf commit bd5314f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

include/linux/module.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,8 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
616616
/* Look for this name: can be of form module:name. */
617617
unsigned long module_kallsyms_lookup_name(const char *name);
618618

619+
unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name);
620+
619621
extern void __noreturn __module_put_and_kthread_exit(struct module *mod,
620622
long code);
621623
#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)
796798
return 0;
797799
}
798800

801+
static inline unsigned long find_kallsyms_symbol_value(struct module *mod,
802+
const char *name)
803+
{
804+
return 0;
805+
}
806+
799807
static inline int register_module_notifier(struct notifier_block *nb)
800808
{
801809
/* no events will happen anyway, so this can always succeed */

kernel/bpf/verifier.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <linux/bpf_lsm.h>
2525
#include <linux/btf_ids.h>
2626
#include <linux/poison.h>
27-
#include "../module/internal.h"
27+
#include <linux/module.h>
2828

2929
#include "disasm.h"
3030

kernel/module/internal.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ static inline void kmemleak_load_module(const struct module *mod,
246246
void init_build_id(struct module *mod, const struct load_info *info);
247247
void layout_symtab(struct module *mod, struct load_info *info);
248248
void add_kallsyms(struct module *mod, const struct load_info *info);
249-
unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name);
250249

251250
static inline bool sect_empty(const Elf_Shdr *sect)
252251
{
@@ -256,11 +255,6 @@ static inline bool sect_empty(const Elf_Shdr *sect)
256255
static inline void init_build_id(struct module *mod, const struct load_info *info) { }
257256
static inline void layout_symtab(struct module *mod, struct load_info *info) { }
258257
static inline void add_kallsyms(struct module *mod, const struct load_info *info) { }
259-
static inline unsigned long find_kallsyms_symbol_value(struct module *mod,
260-
const char *name)
261-
{
262-
return 0;
263-
}
264258
#endif /* CONFIG_KALLSYMS */
265259

266260
#ifdef CONFIG_SYSFS

0 commit comments

Comments
 (0)