Lines Matching defs:module

62 #include <uapi/linux/module.h>
66 #include <trace/events/module.h>
94 * Bounds of module memory, for speeding up __module_address.
118 static void mod_update_bounds(struct module *mod)
128 /* Block module loading/unloading? */
132 /* Waiting for a module to finish initializing? */
154 static inline int strong_try_module_get(struct module *mod)
165 static inline void add_taint_module(struct module *mod, unsigned flag,
173 * A thread that wants to hold a reference to a module only while it
176 void __noreturn __module_put_and_kthread_exit(struct module *mod, long code)
183 /* Find a module section: 0 means not found. */
198 /* Find a module section, or NULL. */
205 /* Find a module section, or NULL. Fill in number of "objects" in section. */
218 /* Find a module section: 0 means not found. Ignores SHF_ALLOC flag. */
232 * Find a module section, or NULL. Fill in number of "objects" in section.
279 struct module *owner,
302 * (optional) module which owns it. Needs preempt disabled or module_mutex.
313 struct module *mod;
345 * Search for module by name: must hold module_mutex (or preempt disabled
348 struct module *find_module_all(const char *name, size_t len,
351 struct module *mod;
365 struct module *find_module(const char *name)
372 static inline void __percpu *mod_percpu(struct module *mod)
377 static int percpu_modalloc(struct module *mod, struct load_info *info)
401 static void percpu_modfree(struct module *mod)
411 static void percpu_modcopy(struct module *mod,
422 struct module *mod;
454 * is_module_percpu_address() - test whether address is from module static percpu
457 * Test whether @addr belongs to module static percpu area.
459 * Return: %true if @addr is from module static percpu area
468 static inline void __percpu *mod_percpu(struct module *mod)
472 static int percpu_modalloc(struct module *mod, struct load_info *info)
479 static inline void percpu_modfree(struct module *mod)
486 static inline void percpu_modcopy(struct module *mod,
505 static void setup_modinfo_##field(struct module *mod, const char *s) \
514 static int modinfo_##field##_exists(struct module *mod) \
518 static void free_modinfo_##field(struct module *mod) \
546 /* Init the unload section of the module. */
547 static int module_unload_init(struct module *mod)
551 * refcnt == 0 means module is going.
565 static int already_uses(struct module *a, struct module *b)
579 * - we add 'a' as a "source", 'b' as a "target" of module use
584 static int add_module_usage(struct module *a, struct module *b)
601 static int ref_module(struct module *a, struct module *b)
608 /* If module isn't available, we fail. */
621 /* Clear the unload stuff of the module. */
622 static void module_unload_free(struct module *mod)
628 struct module *i = use->target;
653 /* Try to release refcount of module, 0 means success. */
654 static int try_release_module_ref(struct module *mod)
668 static int try_stop_module(struct module *mod, int flags, int *forced)
685 * @mod: the module we're checking
688 * -1 if the module is in the process of unloading
689 * otherwise the number of references in the kernel to the module
691 int module_refcount(struct module *mod)
698 static void free_module(struct module *mod);
703 struct module *mod;
734 /* FIXME: if (force), slam module count damn the torpedoes */
744 /* This module can't be removed */
765 /* Store the name and taints of the last unloaded module for diagnostic purposes */
770 /* someone could wait for the module in add_unformed_module() */
795 struct module *modaddr;
802 * Even though we hold a reference on the module; we still need to
822 void __module_get(struct module *module)
824 if (module) {
825 atomic_inc(&module->refcnt);
826 trace_module_get(module, _RET_IP_);
831 bool try_module_get(struct module *module)
835 if (module) {
837 if (likely(module_is_live(module) &&
838 atomic_inc_not_zero(&module->refcnt) != 0))
839 trace_module_get(module, _RET_IP_);
847 void module_put(struct module *module)
851 if (module) {
852 ret = atomic_dec_if_positive(&module->refcnt);
854 trace_module_put(module, _RET_IP_);
860 static inline void module_unload_free(struct module *mod)
864 static int ref_module(struct module *a, struct module *b)
869 static inline int module_unload_init(struct module *mod)
881 if (taint_flags[i].module && test_bit(i, &taints))
1002 int try_to_force_load(struct module *mod, const char *reason)
1066 struct module *mod)
1082 "%s: module uses symbol (%s) from namespace %s, but does not import it.\n",
1091 static bool inherit_taint(struct module *mod, struct module *owner, const char *name)
1097 pr_err("%s: module using GPL-only symbols uses symbols %s from proprietary module %s.\n",
1103 pr_warn("%s: module uses symbols %s from proprietary module %s, inheriting taint.\n",
1110 /* Resolve a symbol for this module. I.e. if we find one, record usage. */
1111 static const struct kernel_symbol *resolve_symbol(struct module *mod,
1167 resolve_symbol_wait(struct module *mod,
1178 pr_warn("%s: gave up waiting for init of module %s.\n",
1184 void __weak module_arch_cleanup(struct module *mod)
1188 void __weak module_arch_freeing_init(struct module *mod)
1192 static int module_memory_alloc(struct module *mod, enum mod_mem_type type)
1210 * The pointer to these blocks of memory are stored on the module
1211 * structure and we keep that around so long as the module is
1212 * around. We only free that memory when we unload the module.
1228 static void module_memory_free(struct module *mod, enum mod_mem_type type,
1239 static void free_mod_mem(struct module *mod, bool unload_codetags)
1258 /* Free a module, remove from lists, etc. */
1259 static void free_module(struct module *mod)
1267 pr_warn("%s: memory allocation(s) from the module still alive, cannot unload cleanly\n",
1297 /* Remove this module from bug list, this uses list_del_rcu */
1302 pr_err("%s: adding tainted module to the unloaded tainted modules list failed.\n",
1342 * in the kernel or in some other module's exported symbol table.
1346 static int verify_exported_symbols(struct module *mod)
1392 static int simplify_symbols(struct module *mod, const struct load_info *info)
1463 static int apply_relocations(struct module *mod, const struct load_info *info)
1499 unsigned int __weak arch_mod_section_prepend(struct module *mod,
1506 long module_get_offset_and_type(struct module *mod, enum mod_mem_type type,
1529 static void __layout_sections(struct module *mod, struct load_info *info, bool is_init)
1588 static void layout_sections(struct module *mod, struct load_info *info)
1602 static void module_license_taint_check(struct module *mod, const char *license)
1609 pr_warn("%s: module license '%s' taints kernel.\n",
1616 static void setup_modinfo(struct module *mod, struct load_info *info)
1627 static void free_modinfo(struct module *mod)
1668 * Check userspace passed ELF module against our expectations, and cache
1680 * o cache the module section
1682 * As a last step we set info->mod to the temporary copy of the module in
1684 * modifications we make to our copy of the module will be carried over
1685 * to the final minted module.
1716 pr_err("Invalid module architecture in ELF header: %u\n",
1804 pr_err("Invalid ELF section in module (section %u type %u)\n",
1820 pr_err("Invalid ELF section name in module (section %u type %u)\n",
1833 /* Try to find a name early so we can log errors with a module name */
1839 pr_warn("%s: module has no symbols (stripped?)\n",
1855 * module of the kernel changes a full kernel rebuild is required.
1862 * o The section size must match the kernel's run time's struct module
1866 pr_err("module %s: Only one .gnu.linkonce.this_module section must exist.\n",
1878 pr_err("module %s: .gnu.linkonce.this_module section must have a size set\n",
1884 pr_err("module %s: .gnu.linkonce.this_module must occupy memory during process execution\n",
1889 if (shdr->sh_size != sizeof(struct module)) {
1890 pr_err("module %s: .gnu.linkonce.this_module section size must match the kernel's built struct module size at run time\n",
1937 static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
1946 pr_err("%s: module is marked as livepatch module, but livepatch support is disabled",
1951 static void check_modinfo_retpoline(struct module *mod, struct load_info *info)
1956 pr_warn("%s: loading module not compiled with retpoline compiler.\n",
2027 * These calls taint the kernel depending certain module circumstances */
2028 static void module_augment_kernel_taints(struct module *mod, struct load_info *info)
2034 pr_warn("%s: loading out-of-tree module taints kernel.\n",
2043 pr_warn("%s: module is from the staging directory, the quality "
2057 pr_warn("%s: loading test module taints kernel.\n",
2064 pr_notice_once("%s: module verification failed: signature "
2090 pr_warn("%s: module license taints kernel.\n", mod->name);
2094 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
2120 static int find_module_sections(struct module *mod, struct load_info *info)
2141 * building all parts of the module.
2243 static int move_module(struct module *mod, struct load_info *info)
2279 * userspace copy of the entire struct module.
2282 (WARN_ON_ONCE(shdr->sh_size != sizeof(struct module)))) {
2306 static int check_export_symbol_versions(struct module *mod)
2318 static void flush_module_icache(const struct module *mod)
2322 * Do it before processing of module parameters, so the module
2343 struct module *mod)
2348 /* module_blacklist is a comma-separated list of module names */
2369 static struct module *layout_and_allocate(struct load_info *info, int flags)
2371 struct module *mod;
2401 * at module load time.
2427 static void module_deallocate(struct module *mod, struct load_info *info)
2437 struct module *me)
2442 static int post_relocation(struct module *mod, const struct load_info *info)
2454 /* Arch-specific module finalizing. */
2458 /* Call module constructors. */
2459 static void do_mod_ctors(struct module *mod)
2501 #define MODULE_PARAM_PREFIX "module."
2502 /* Default value for module->async_probe_requested */
2512 static noinline int do_init_module(struct module *mod)
2539 /* Start the module */
2548 "%s: loading module anyway...\n",
2558 /* Delay uevent until module has finished its init routine */
2562 * We need to finish all async code before the module init sequence
2563 * is done. This has potential to deadlock if synchronous module
2649 /* Is this module of this name done loading? No locks held. */
2652 struct module *mod;
2674 struct module *old;
2691 /* The module might have gone in the meantime. */
2696 pr_warn("Could not add fail-tracking for module: %s\n", name);
2699 * We are here only when the same module was being loaded. Do
2701 * caused by serialized module load failures. It might happen
2703 * a particular module.
2715 static int add_unformed_module(struct module *mod)
2736 static int complete_formation(struct module *mod, struct load_info *info)
2777 static int prepare_coming_module(struct module *mod)
2798 struct module *mod = arg;
2820 * Now that we know we have the correct module name, check
2832 /* Check module struct version now, before we try to use module. */
2848 * Allocate and load the module: note that size of section 0 is always
2854 struct module *mod;
2864 * of a corrupt module causing problems before
2868 * off the sig length at the end of the module, making
2878 * info->mod to the userspace passed struct module.
2888 /* Figure out module layout, and allocate all the memory. */
2905 * We are tainting your kernel if your module gets into
2915 /* Now module is in final location, initialize linked lists, etc. */
3054 * failures once the proper module was allocated and
3217 char *module_flags(struct module *mod, char *buf, bool show_state)
3229 /* Show a - for module-is-being-unloaded */
3232 /* Show a + for module-is-being-loaded */
3243 /* Given an address, look for it in the module exception tables. */
3247 struct module *mod;
3265 * we cannot unload the module, hence no refcnt needed.
3271 * is_module_address() - is this address inside a module?
3289 * __module_address() - get the module which contains an address.
3292 * Must be called with preempt disabled or module mutex held so that
3293 * module doesn't get freed during this.
3295 struct module *__module_address(unsigned long addr)
3297 struct module *mod;
3322 * is_module_text_address() - is this address inside module code?
3326 * anywhere in a module. See kernel_text_address() for testing if an
3327 * address corresponds to kernel or module code.
3341 * __module_text_address() - get the module whose code contains an address.
3344 * Must be called with preempt disabled or module mutex held so that
3345 * module doesn't get freed during this.
3347 struct module *__module_text_address(unsigned long addr)
3349 struct module *mod = __module_address(addr);
3362 struct module *mod;