Lines Matching defs:module

60 #include <uapi/linux/module.h>
64 #include <trace/events/module.h>
92 * Bounds of module memory, for speeding up __module_address.
116 static void mod_update_bounds(struct module *mod)
126 /* Block module loading/unloading? */
130 /* Waiting for a module to finish initializing? */
152 static inline int strong_try_module_get(struct module *mod)
163 static inline void add_taint_module(struct module *mod, unsigned flag,
171 * A thread that wants to hold a reference to a module only while it
174 void __noreturn __module_put_and_kthread_exit(struct module *mod, long code)
181 /* Find a module section: 0 means not found. */
196 /* Find a module section, or NULL. */
203 /* Find a module section, or NULL. Fill in number of "objects" in section. */
216 /* Find a module section: 0 means not found. Ignores SHF_ALLOC flag. */
230 * Find a module section, or NULL. Fill in number of "objects" in section.
277 struct module *owner,
300 * (optional) module which owns it. Needs preempt disabled or module_mutex.
311 struct module *mod;
343 * Search for module by name: must hold module_mutex (or preempt disabled
346 struct module *find_module_all(const char *name, size_t len,
349 struct module *mod;
363 struct module *find_module(const char *name)
370 static inline void __percpu *mod_percpu(struct module *mod)
375 static int percpu_modalloc(struct module *mod, struct load_info *info)
399 static void percpu_modfree(struct module *mod)
409 static void percpu_modcopy(struct module *mod,
420 struct module *mod;
452 * is_module_percpu_address() - test whether address is from module static percpu
455 * Test whether @addr belongs to module static percpu area.
457 * Return: %true if @addr is from module static percpu area
466 static inline void __percpu *mod_percpu(struct module *mod)
470 static int percpu_modalloc(struct module *mod, struct load_info *info)
477 static inline void percpu_modfree(struct module *mod)
484 static inline void percpu_modcopy(struct module *mod,
503 static void setup_modinfo_##field(struct module *mod, const char *s) \
512 static int modinfo_##field##_exists(struct module *mod) \
516 static void free_modinfo_##field(struct module *mod) \
544 /* Init the unload section of the module. */
545 static int module_unload_init(struct module *mod)
549 * refcnt == 0 means module is going.
563 static int already_uses(struct module *a, struct module *b)
577 * - we add 'a' as a "source", 'b' as a "target" of module use
582 static int add_module_usage(struct module *a, struct module *b)
599 static int ref_module(struct module *a, struct module *b)
606 /* If module isn't available, we fail. */
619 /* Clear the unload stuff of the module. */
620 static void module_unload_free(struct module *mod)
626 struct module *i = use->target;
651 /* Try to release refcount of module, 0 means success. */
652 static int try_release_module_ref(struct module *mod)
666 static int try_stop_module(struct module *mod, int flags, int *forced)
683 * @mod: the module we're checking
686 * -1 if the module is in the process of unloading
687 * otherwise the number of references in the kernel to the module
689 int module_refcount(struct module *mod)
696 static void free_module(struct module *mod);
701 struct module *mod;
732 /* FIXME: if (force), slam module count damn the torpedoes */
742 /* This module can't be removed */
763 /* Store the name and taints of the last unloaded module for diagnostic purposes */
768 /* someone could wait for the module in add_unformed_module() */
793 struct module *modaddr;
800 * Even though we hold a reference on the module; we still need to
820 void __module_get(struct module *module)
822 if (module) {
823 atomic_inc(&module->refcnt);
824 trace_module_get(module, _RET_IP_);
829 bool try_module_get(struct module *module)
833 if (module) {
835 if (likely(module_is_live(module) &&
836 atomic_inc_not_zero(&module->refcnt) != 0))
837 trace_module_get(module, _RET_IP_);
845 void module_put(struct module *module)
849 if (module) {
850 ret = atomic_dec_if_positive(&module->refcnt);
852 trace_module_put(module, _RET_IP_);
858 static inline void module_unload_free(struct module *mod)
862 static int ref_module(struct module *a, struct module *b)
867 static inline int module_unload_init(struct module *mod)
879 if (taint_flags[i].module && test_bit(i, &taints))
1000 int try_to_force_load(struct module *mod, const char *reason)
1064 struct module *mod)
1080 "%s: module uses symbol (%s) from namespace %s, but does not import it.\n",
1089 static bool inherit_taint(struct module *mod, struct module *owner, const char *name)
1095 pr_err("%s: module using GPL-only symbols uses symbols %s from proprietary module %s.\n",
1101 pr_warn("%s: module uses symbols %s from proprietary module %s, inheriting taint.\n",
1108 /* Resolve a symbol for this module. I.e. if we find one, record usage. */
1109 static const struct kernel_symbol *resolve_symbol(struct module *mod,
1165 resolve_symbol_wait(struct module *mod,
1176 pr_warn("%s: gave up waiting for init of module %s.\n",
1192 void __weak module_arch_cleanup(struct module *mod)
1196 void __weak module_arch_freeing_init(struct module *mod)
1221 static void free_mod_mem(struct module *mod)
1240 /* Free a module, remove from lists, etc. */
1241 static void free_module(struct module *mod)
1272 /* Remove this module from bug list, this uses list_del_rcu */
1277 pr_err("%s: adding tainted module to the unloaded tainted modules list failed.\n",
1317 * in the kernel or in some other module's exported symbol table.
1321 static int verify_exported_symbols(struct module *mod)
1367 static int simplify_symbols(struct module *mod, const struct load_info *info)
1438 static int apply_relocations(struct module *mod, const struct load_info *info)
1474 unsigned int __weak arch_mod_section_prepend(struct module *mod,
1481 long module_get_offset_and_type(struct module *mod, enum mod_mem_type type,
1504 static void __layout_sections(struct module *mod, struct load_info *info, bool is_init)
1563 static void layout_sections(struct module *mod, struct load_info *info)
1577 static void module_license_taint_check(struct module *mod, const char *license)
1584 pr_warn("%s: module license '%s' taints kernel.\n",
1591 static void setup_modinfo(struct module *mod, struct load_info *info)
1602 static void free_modinfo(struct module *mod)
1650 * Check userspace passed ELF module against our expectations, and cache
1662 * o cache the module section
1664 * As a last step we set info->mod to the temporary copy of the module in
1666 * modifications we make to our copy of the module will be carried over
1667 * to the final minted module.
1698 pr_err("Invalid module architecture in ELF header: %u\n",
1786 pr_err("Invalid ELF section in module (section %u type %u)\n",
1802 pr_err("Invalid ELF section name in module (section %u type %u)\n",
1815 /* Try to find a name early so we can log errors with a module name */
1821 pr_warn("%s: module has no symbols (stripped?)\n",
1837 * module of the kernel changes a full kernel rebuild is required.
1844 * o The section size must match the kernel's run time's struct module
1848 pr_err("module %s: Only one .gnu.linkonce.this_module section must exist.\n",
1860 pr_err("module %s: .gnu.linkonce.this_module section must have a size set\n",
1866 pr_err("module %s: .gnu.linkonce.this_module must occupy memory during process execution\n",
1871 if (shdr->sh_size != sizeof(struct module)) {
1872 pr_err("module %s: .gnu.linkonce.this_module section size must match the kernel's built struct module size at run time\n",
1919 static int check_modinfo_livepatch(struct module *mod, struct load_info *info)
1928 pr_err("%s: module is marked as livepatch module, but livepatch support is disabled",
1933 static void check_modinfo_retpoline(struct module *mod, struct load_info *info)
1938 pr_warn("%s: loading module not compiled with retpoline compiler.\n",
2009 * These calls taint the kernel depending certain module circumstances */
2010 static void module_augment_kernel_taints(struct module *mod, struct load_info *info)
2016 pr_warn("%s: loading out-of-tree module taints kernel.\n",
2025 pr_warn("%s: module is from the staging directory, the quality "
2039 pr_warn("%s: loading test module taints kernel.\n",
2046 pr_notice_once("%s: module verification failed: signature "
2072 pr_warn("%s: module license taints kernel.\n", mod->name);
2076 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
2102 static int find_module_sections(struct module *mod, struct load_info *info)
2123 * building all parts of the module.
2225 static int move_module(struct module *mod, struct load_info *info)
2240 * The pointer to these blocks of memory are stored on the module
2241 * structure and we keep that around so long as the module is
2242 * around. We only free that memory when we unload the module.
2276 * userspace copy of the entire struct module.
2279 (WARN_ON_ONCE(shdr->sh_size != sizeof(struct module)))) {
2303 static int check_export_symbol_versions(struct module *mod)
2315 static void flush_module_icache(const struct module *mod)
2319 * Do it before processing of module parameters, so the module
2340 struct module *mod)
2345 /* module_blacklist is a comma-separated list of module names */
2366 static struct module *layout_and_allocate(struct load_info *info, int flags)
2368 struct module *mod;
2398 * at module load time.
2424 static void module_deallocate(struct module *mod, struct load_info *info)
2434 struct module *me)
2439 static int post_relocation(struct module *mod, const struct load_info *info)
2451 /* Arch-specific module finalizing. */
2455 /* Call module constructors. */
2456 static void do_mod_ctors(struct module *mod)
2498 #define MODULE_PARAM_PREFIX "module."
2499 /* Default value for module->async_probe_requested */
2509 static noinline int do_init_module(struct module *mod)
2536 /* Start the module */
2545 "%s: loading module anyway...\n",
2555 /* Delay uevent until module has finished its init routine */
2559 * We need to finish all async code before the module init sequence
2560 * is done. This has potential to deadlock if synchronous module
2646 /* Is this module of this name done loading? No locks held. */
2649 struct module *mod;
2671 struct module *old;
2688 /* The module might have gone in the meantime. */
2693 pr_warn("Could not add fail-tracking for module: %s\n", name);
2696 * We are here only when the same module was being loaded. Do
2698 * caused by serialized module load failures. It might happen
2700 * a particular module.
2712 static int add_unformed_module(struct module *mod)
2733 static int complete_formation(struct module *mod, struct load_info *info)
2774 static int prepare_coming_module(struct module *mod)
2795 struct module *mod = arg;
2817 * Now that we know we have the correct module name, check
2829 /* Check module struct version now, before we try to use module. */
2845 * Allocate and load the module: note that size of section 0 is always
2851 struct module *mod;
2861 * of a corrupt module causing problems before
2865 * off the sig length at the end of the module, making
2875 * info->mod to the userspace passed struct module.
2885 /* Figure out module layout, and allocate all the memory. */
2902 * We are tainting your kernel if your module gets into
2912 /* Now module is in final location, initialize linked lists, etc. */
3049 * failures once the proper module was allocated and
3212 char *module_flags(struct module *mod, char *buf, bool show_state)
3224 /* Show a - for module-is-being-unloaded */
3227 /* Show a + for module-is-being-loaded */
3238 /* Given an address, look for it in the module exception tables. */
3242 struct module *mod;
3260 * we cannot unload the module, hence no refcnt needed.
3266 * is_module_address() - is this address inside a module?
3284 * __module_address() - get the module which contains an address.
3287 * Must be called with preempt disabled or module mutex held so that
3288 * module doesn't get freed during this.
3290 struct module *__module_address(unsigned long addr)
3292 struct module *mod;
3317 * is_module_text_address() - is this address inside module code?
3321 * anywhere in a module. See kernel_text_address() for testing if an
3322 * address corresponds to kernel or module code.
3336 * __module_text_address() - get the module whose code contains an address.
3339 * Must be called with preempt disabled or module mutex held so that
3340 * module doesn't get freed during this.
3342 struct module *__module_text_address(unsigned long addr)
3344 struct module *mod = __module_address(addr);
3357 struct module *mod;