Lines Matching defs:module

60 #include <uapi/linux/module.h>
61 #include "module-internal.h"
64 #include <trace/events/module.h>
81 /* If this is set, the section belongs in the init part of the module */
177 static void mod_tree_insert(struct module *mod)
187 static void mod_tree_remove_init(struct module *mod)
193 static void mod_tree_remove(struct module *mod)
199 static struct module *mod_find(unsigned long addr)
214 static void mod_tree_insert(struct module *mod) { }
215 static void mod_tree_remove_init(struct module *mod) { }
216 static void mod_tree_remove(struct module *mod) { }
218 static struct module *mod_find(unsigned long addr)
220 struct module *mod;
234 * Bounds of module text, for speeding up __module_address.
248 static void mod_update_bounds(struct module *mod)
297 /* Block module loading/unloading? */
301 /* Waiting for a module to finish initializing? */
323 static inline int strong_try_module_get(struct module *mod)
334 static inline void add_taint_module(struct module *mod, unsigned flag,
342 * A thread that wants to hold a reference to a module only while it
345 void __noreturn __module_put_and_exit(struct module *mod, long code)
352 /* Find a module section: 0 means not found. */
367 /* Find a module section, or NULL. */
374 /* Find a module section, or NULL. Fill in number of "objects" in section. */
414 struct module *owner,
416 struct module *owner,
432 struct module *owner,
436 struct module *mod;
501 struct module *owner;
508 struct module *owner,
517 pr_warn("Symbol %s is being used by a non-GPL module, "
525 pr_warn("Symbol %s is marked as UNUSED, however this module is "
577 struct module *owner,
594 * (optional) module which owns it. Needs preempt disabled or module_mutex. */
596 struct module **owner,
623 * Search for module by name: must hold module_mutex (or preempt disabled
626 static struct module *find_module_all(const char *name, size_t len,
629 struct module *mod;
643 struct module *find_module(const char *name)
652 static inline void __percpu *mod_percpu(struct module *mod)
657 static int percpu_modalloc(struct module *mod, struct load_info *info)
681 static void percpu_modfree(struct module *mod)
691 static void percpu_modcopy(struct module *mod,
702 struct module *mod;
734 * is_module_percpu_address - test whether address is from module static percpu
737 * Test whether @addr belongs to module static percpu area.
740 * %true if @addr is from module static percpu area
749 static inline void __percpu *mod_percpu(struct module *mod)
753 static int percpu_modalloc(struct module *mod, struct load_info *info)
760 static inline void percpu_modfree(struct module *mod)
767 static inline void percpu_modcopy(struct module *mod,
786 static void setup_modinfo_##field(struct module *mod, const char *s) \
795 static int modinfo_##field##_exists(struct module *mod) \
799 static void free_modinfo_##field(struct module *mod) \
824 /* Init the unload section of the module. */
825 static int module_unload_init(struct module *mod)
829 * refcnt == 0 means module is going.
843 static int already_uses(struct module *a, struct module *b)
859 * - we add 'a' as a "source", 'b' as a "target" of module use
864 static int add_module_usage(struct module *a, struct module *b)
881 static int ref_module(struct module *a, struct module *b)
888 /* If module isn't available, we fail. */
901 /* Clear the unload stuff of the module. */
902 static void module_unload_free(struct module *mod)
908 struct module *i = use->target;
933 /* Try to release refcount of module, 0 means success. */
934 static int try_release_module_ref(struct module *mod)
948 static int try_stop_module(struct module *mod, int flags, int *forced)
966 * @mod: the module we're checking
969 * -1 if the module is in the process of unloading
970 * otherwise the number of references in the kernel to the module
972 int module_refcount(struct module *mod)
979 static void free_module(struct module *mod);
984 struct module *mod;
1014 /* FIXME: if (force), slam module count damn the torpedoes */
1024 /* This module can't be removed */
1030 /* Stop the machine so refcounts can't move and disable module. */
1046 /* Store the name of the last unloaded module for diagnostic purposes */
1050 /* someone could wait for the module in add_unformed_module() */
1058 static inline void print_unload_info(struct seq_file *m, struct module *mod)
1085 struct module *owner;
1098 struct module *modaddr;
1105 * Even though we hold a reference on the module; we still need to
1125 void __module_get(struct module *module)
1127 if (module) {
1129 atomic_inc(&module->refcnt);
1130 trace_module_get(module, _RET_IP_);
1136 bool try_module_get(struct module *module)
1140 if (module) {
1143 if (likely(module_is_live(module) &&
1144 atomic_inc_not_zero(&module->refcnt) != 0))
1145 trace_module_get(module, _RET_IP_);
1155 void module_put(struct module *module)
1159 if (module) {
1161 ret = atomic_dec_if_positive(&module->refcnt);
1163 trace_module_put(module, _RET_IP_);
1170 static inline void print_unload_info(struct seq_file *m, struct module *mod)
1176 static inline void module_unload_free(struct module *mod)
1180 static int ref_module(struct module *a, struct module *b)
1185 static inline int module_unload_init(struct module *mod)
1191 static size_t module_flags_taint(struct module *mod, char *buf)
1197 if (taint_flags[i].module && test_bit(i, &mod->taints))
1288 static int try_to_force_load(struct module *mod, const char *reason)
1309 struct module *mod,
1317 /* Exporting module didn't supply crcs? OK, we're already tainted. */
1341 pr_debug("Found checksum %X vs module %lX\n",
1357 struct module *mod)
1374 /* First part is kernel version, which we ignore if module has crcs. */
1387 struct module *mod,
1394 struct module *mod)
1412 struct module *mod)
1431 "%s: module uses symbol (%s) from namespace %s, but does not import it.\n",
1440 static bool inherit_taint(struct module *mod, struct module *owner)
1446 pr_err("%s: module using GPL-only symbols uses symbols from proprietary module %s.\n",
1452 pr_warn("%s: module uses symbols from proprietary module %s, inheriting taint.\n",
1459 /* Resolve a symbol for this module. I.e. if we find one, record usage. */
1460 static const struct kernel_symbol *resolve_symbol(struct module *mod,
1465 struct module *owner;
1517 resolve_symbol_wait(struct module *mod,
1528 pr_warn("%s: gave up waiting for init of module %s.\n",
1535 * /sys/module/foo/sections stuff
1596 static void add_sect_attrs(struct module *mod, const struct load_info *info)
1648 static void remove_sect_attrs(struct module *mod)
1661 * /sys/module/foo/notes/.section.name gives contents of SHT_NOTE sections.
1693 static void add_notes_attrs(struct module *mod, const struct load_info *info)
1751 static void remove_notes_attrs(struct module *mod)
1759 static inline void add_sect_attrs(struct module *mod,
1764 static inline void remove_sect_attrs(struct module *mod)
1768 static inline void add_notes_attrs(struct module *mod,
1773 static inline void remove_notes_attrs(struct module *mod)
1778 static void del_usage_links(struct module *mod)
1790 static int add_usage_links(struct module *mod)
1810 static void module_remove_modinfo_attrs(struct module *mod, int end);
1812 static int module_add_modinfo_attrs(struct module *mod)
1848 static void module_remove_modinfo_attrs(struct module *mod, int end)
1866 static void mod_kobject_put(struct module *mod)
1874 static int mod_sysfs_init(struct module *mod)
1880 pr_err("%s: module sysfs not initialized\n", mod->name);
1887 pr_err("%s: module is already loaded\n", mod->name);
1906 static int mod_sysfs_setup(struct module *mod,
1952 static void mod_sysfs_fini(struct module *mod)
1959 static void init_param_lock(struct module *mod)
1965 static int mod_sysfs_setup(struct module *mod,
1973 static void mod_sysfs_fini(struct module *mod)
1977 static void module_remove_modinfo_attrs(struct module *mod, int end)
1981 static void del_usage_links(struct module *mod)
1985 static void init_param_lock(struct module *mod)
1990 static void mod_sysfs_teardown(struct module *mod)
2001 * LKM RO/NX protection: protect module's text/ro-data
2004 * General layout of module is:
2015 * Since some arches are moving towards PAGE_KERNEL module allocations instead
2030 static void module_enable_x(const struct module *mod)
2036 static void module_enable_x(const struct module *mod) { }
2070 static void module_enable_ro(const struct module *mod, bool after_init)
2087 static void module_enable_nx(const struct module *mod)
2097 char *secstrings, struct module *mod)
2114 static void module_enable_nx(const struct module *mod) { }
2115 static void module_enable_ro(const struct module *mod, bool after_init) {}
2117 char *secstrings, struct module *mod)
2125 * Persist Elf information about a module. Copy the Elf header,
2129 static int copy_module_elf(struct module *mod, struct load_info *info)
2166 * to core_kallsyms.symtab since the copy of the symtab in module
2181 static void free_module_elf(struct module *mod)
2188 static int copy_module_elf(struct module *mod, struct load_info *info)
2193 static void free_module_elf(struct module *mod)
2208 void __weak module_arch_cleanup(struct module *mod)
2212 void __weak module_arch_freeing_init(struct module *mod)
2216 static void cfi_cleanup(struct module *mod);
2218 /* Free a module, remove from lists, etc. */
2219 static void free_module(struct module *mod)
2251 /* Remove this module from bug list, this uses list_del_rcu */
2257 /* Clean up CFI for the module. */
2269 /* Finally, free the core (containing the module structure) */
2275 struct module *owner;
2310 * in the kernel or in some other module's exported symbol table.
2314 static int verify_exported_symbols(struct module *mod)
2317 struct module *owner;
2363 static int simplify_symbols(struct module *mod, const struct load_info *info)
2432 static int apply_relocations(struct module *mod, const struct load_info *info)
2468 unsigned int __weak arch_mod_section_prepend(struct module *mod,
2476 static long get_offset(struct module *mod, unsigned int *size,
2491 static void layout_sections(struct module *mod, struct load_info *info)
2579 static void set_license(struct module *mod, const char *license)
2586 pr_warn("%s: module license '%s' taints kernel.\n",
2643 static void setup_modinfo(struct module *mod, struct load_info *info)
2654 static void free_modinfo(struct module *mod)
2677 const struct module *mod)
2762 static void layout_symtab(struct module *mod, struct load_info *info)
2769 /* Put symbol section at end of init part of module. */
2796 /* Put string table section at end of init part of module. */
2817 static void add_kallsyms(struct module *mod, const struct load_info *info)
2858 static inline void layout_symtab(struct module *mod, struct load_info *info)
2862 static void add_kallsyms(struct module *mod, const struct load_info *info)
2867 static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num)
2874 static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug)
2898 static void kmemleak_load_module(const struct module *mod,
2904 kmemleak_scan_area(mod, sizeof(struct module), GFP_KERNEL);
2918 static inline void kmemleak_load_module(const struct module *mod,
2933 * Require flags == 0, as a module with version information
2934 * removed is no longer the module that was signed
2939 /* We truncate the module to discard the signature */
2954 reason = "unsigned module";
2957 reason = "module with unsupported crypto";
2960 reason = "module with unavailable key";
3077 pr_err("Invalid ELF section in module (section %u type %u)\n",
3084 pr_err("Invalid ELF section name in module (section %u type %u)\n",
3114 static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
3126 static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
3129 pr_err("%s: module is marked as livepatch module, but livepatch support is disabled",
3138 static void check_modinfo_retpoline(struct module *mod, struct load_info *info)
3143 pr_warn("%s: loading module not compiled with retpoline compiler.\n",
3210 * search for module section index etc), and do some basic section
3213 * Set info->mod to the temporary copy of the module in info->hdr. The final one
3220 /* Try to find a name early so we can log errors with a module name */
3237 pr_warn("%s: module has no symbols (stripped?)\n",
3244 pr_warn("%s: No module found in object\n",
3268 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
3289 pr_warn("%s: loading out-of-tree module taints kernel.\n",
3298 pr_warn("%s: module is from the staging directory, the quality "
3312 static int find_module_sections(struct module *mod, struct load_info *info)
3348 * building all parts of the module.
3427 static int move_module(struct module *mod, struct load_info *info)
3435 * The pointer to this block is stored in the module structure
3449 * The pointer to this block is stored in the module structure
3452 * after the module is initialized.
3490 static int check_module_license_and_versions(struct module *mod)
3513 pr_warn("%s: module license taints kernel.\n", mod->name);
3531 static void flush_module_icache(const struct module *mod)
3535 * Do it before processing of module parameters, so the module
3549 struct module *mod)
3554 /* module_blacklist is a comma-separated list of module names */
3575 static struct module *layout_and_allocate(struct load_info *info, int flags)
3577 struct module *mod;
3611 * at module load time.
3635 static void module_deallocate(struct module *mod, struct load_info *info)
3645 struct module *me)
3650 static int post_relocation(struct module *mod, const struct load_info *info)
3662 /* Arch-specific module finalizing. */
3666 /* Is this module of this name done loading? No locks held. */
3669 struct module *mod;
3687 /* Call module constructors. */
3688 static void do_mod_ctors(struct module *mod)
3726 static noinline int do_init_module(struct module *mod)
3739 /* Start the module */
3748 "%s: loading module anyway...\n",
3758 /* Delay uevent until module has finished its init routine */
3762 * We need to finish all async code before the module init sequence
3763 * is done. This has potential to deadlock if synchronous module
3840 static int add_unformed_module(struct module *mod)
3843 struct module *old;
3859 /* The module might have gone in the meantime. */
3866 * We are here only when the same module was being loaded. Do
3868 * caused by serialized module load failures. It might happen
3870 * a particular module.
3889 static int complete_formation(struct module *mod, struct load_info *info)
3919 static int prepare_coming_module(struct module *mod)
3940 struct module *mod = arg;
3955 static void cfi_init(struct module *mod);
3957 /* Allocate and load the module: note that size of section 0 is always
3962 struct module *mod;
3971 * of a corrupt module causing problems before
3975 * off the sig length at the end of the module, making
4001 * Now that we know we have the correct module name, check
4014 /* Check module struct version now, before we try to use module. */
4020 /* Figure out module layout, and allocate all the memory. */
4037 pr_notice_once("%s: module verification failed: signature "
4049 /* Now module is in final location, initialize linked lists, etc. */
4084 /* Setup CFI for the module. */
4255 * Given a module and address, find the corresponding symbol and return its name
4258 static const char *find_kallsyms_symbol(struct module *mod,
4267 /* At worse, next value is at end of module */
4309 void * __weak dereference_module_function_descriptor(struct module *mod,
4324 struct module *mod;
4346 struct module *mod;
4372 struct module *mod;
4400 struct module *mod;
4426 /* Given a module and name of symbol, find and return the symbol's value */
4427 static unsigned long find_kallsyms_symbol_value(struct module *mod, const char *name)
4442 /* Look for this name: can be of form module:name. */
4445 struct module *mod;
4467 struct module *, unsigned long),
4470 struct module *mod;
4498 static void cfi_init(struct module *mod)
4525 static void cfi_cleanup(struct module *mod)
4536 static char *module_flags(struct module *mod, char *buf)
4546 /* Show a - for module-is-being-unloaded */
4549 /* Show a + for module-is-being-loaded */
4579 struct module *mod = list_entry(p, struct module, list);
4655 /* Given an address, look for it in the module exception tables. */
4659 struct module *mod;
4677 * we cannot unload the module, hence no refcnt needed.
4683 * is_module_address - is this address inside a module?
4701 * __module_address - get the module which contains an address.
4704 * Must be called with preempt disabled or module mutex held so that
4705 * module doesn't get freed during this.
4707 struct module *__module_address(unsigned long addr)
4709 struct module *mod;
4726 * is_module_text_address - is this address inside module code?
4730 * anywhere in a module. See kernel_text_address() for testing if an
4731 * address corresponds to kernel or module code.
4745 * __module_text_address - get the module whose code contains an address.
4748 * Must be called with preempt disabled or module mutex held so that
4749 * module doesn't get freed during this.
4751 struct module *__module_text_address(unsigned long addr)
4753 struct module *mod = __module_address(addr);
4766 struct module *mod;
4784 /* Generate the signature for all relevant module structures here.
4785 * If these change, we don't want to try to parse the module. */
4786 void module_layout(struct module *mod,