Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'modules-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux

Pull module updates from Daniel Gomez:
"This is a small set of changes for modules, primarily to extend module
users to use the module data structures in combination with the
already no-op stub module functions, even when support for modules is
disabled in the kernel configuration. This change follows the kernel's
coding style for conditional compilation and allows kunit code to drop
all CONFIG_MODULES ifdefs, which is also part of the changes. This
should allow others part of the kernel to do the same cleanup.

The remaining changes include a fix for module name length handling
which could potentially lead to the removal of an incorrect module,
and various cleanups"

* tag 'modules-6.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux:
module: Rename MAX_PARAM_PREFIX_LEN to __MODULE_NAME_LEN
tracing: Replace MAX_PARAM_PREFIX_LEN with MODULE_NAME_LEN
module: Restore the moduleparam prefix length check
module: Remove unnecessary +1 from last_unloaded_module::name size
module: Prevent silent truncation of module name in delete_module(2)
kunit: test: Drop CONFIG_MODULE ifdeffery
module: make structure definitions always visible
module: move 'struct module_use' to internal.h

+35 -38
+11 -18
include/linux/module.h
··· 33 33 #include <linux/percpu.h> 34 34 #include <asm/module.h> 35 35 36 - #define MODULE_NAME_LEN MAX_PARAM_PREFIX_LEN 36 + #define MODULE_NAME_LEN __MODULE_NAME_LEN 37 37 38 38 struct modversion_info { 39 39 unsigned long crc; ··· 302 302 #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, ns) 303 303 304 304 struct notifier_block; 305 - 306 - #ifdef CONFIG_MODULES 307 - 308 - /* Get/put a kernel symbol (calls must be symmetric) */ 309 - void *__symbol_get(const char *symbol); 310 - void *__symbol_get_gpl(const char *symbol); 311 - #define symbol_get(x) ({ \ 312 - static const char __notrim[] \ 313 - __used __section(".no_trim_symbol") = __stringify(x); \ 314 - (typeof(&x))(__symbol_get(__stringify(x))); }) 315 - 316 - /* modules using other modules: kdb wants to see this. */ 317 - struct module_use { 318 - struct list_head source_list; 319 - struct list_head target_list; 320 - struct module *source, *target; 321 - }; 322 305 323 306 enum module_state { 324 307 MODULE_STATE_LIVE, /* Normal state. */ ··· 586 603 #ifndef MODULE_ARCH_INIT 587 604 #define MODULE_ARCH_INIT {} 588 605 #endif 606 + 607 + #ifdef CONFIG_MODULES 608 + 609 + /* Get/put a kernel symbol (calls must be symmetric) */ 610 + void *__symbol_get(const char *symbol); 611 + void *__symbol_get_gpl(const char *symbol); 612 + #define symbol_get(x) ({ \ 613 + static const char __notrim[] \ 614 + __used __section(".no_trim_symbol") = __stringify(x); \ 615 + (typeof(&x))(__symbol_get(__stringify(x))); }) 589 616 590 617 #ifndef HAVE_ARCH_KALLSYMS_SYMBOL_VALUE 591 618 static inline unsigned long kallsyms_symbol_value(const Elf_Sym *sym)
+9 -6
include/linux/moduleparam.h
··· 6 6 #include <linux/stringify.h> 7 7 #include <linux/kernel.h> 8 8 9 + /* 10 + * The maximum module name length, including the NUL byte. 11 + * Chosen so that structs with an unsigned long line up, specifically 12 + * modversion_info. 13 + */ 14 + #define __MODULE_NAME_LEN (64 - sizeof(unsigned long)) 15 + 9 16 /* You can override this manually, but generally this should match the 10 17 module name. */ 11 18 #ifdef MODULE ··· 23 16 /* We cannot use MODULE_PARAM_PREFIX because some modules override it. */ 24 17 #define __MODULE_INFO_PREFIX KBUILD_MODNAME "." 25 18 #endif 26 - 27 - /* Chosen so that structs with an unsigned long line up. */ 28 - #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long)) 29 19 30 20 #define __MODULE_INFO(tag, name, info) \ 31 21 static const char __UNIQUE_ID(name)[] \ ··· 286 282 #define __moduleparam_const const 287 283 #endif 288 284 289 - /* This is the fundamental function for registering boot/module 290 - parameters. */ 285 + /* This is the fundamental function for registering boot/module parameters. */ 291 286 #define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ 292 - /* Default value instead of permissions? */ \ 287 + static_assert(sizeof(""prefix) - 1 <= __MODULE_NAME_LEN); \ 293 288 static const char __param_str_##name[] = prefix #name; \ 294 289 static struct kernel_param __moduleparam_const __param_##name \ 295 290 __used __section("__param") \
+7
kernel/module/internal.h
··· 112 112 enum mod_license license; 113 113 }; 114 114 115 + /* modules using other modules */ 116 + struct module_use { 117 + struct list_head source_list; 118 + struct list_head target_list; 119 + struct module *source, *target; 120 + }; 121 + 115 122 int mod_verify_sig(const void *mod, struct load_info *info); 116 123 int try_to_force_load(struct module *mod, const char *reason); 117 124 bool find_symbol(struct find_symbol_arg *fsa);
+7 -5
kernel/module/main.c
··· 608 608 MODINFO_ATTR(srcversion); 609 609 610 610 static struct { 611 - char name[MODULE_NAME_LEN + 1]; 611 + char name[MODULE_NAME_LEN]; 612 612 char taints[MODULE_FLAGS_BUF_SIZE]; 613 613 } last_unloaded_module; 614 614 ··· 779 779 struct module *mod; 780 780 char name[MODULE_NAME_LEN]; 781 781 char buf[MODULE_FLAGS_BUF_SIZE]; 782 - int ret, forced = 0; 782 + int ret, len, forced = 0; 783 783 784 784 if (!capable(CAP_SYS_MODULE) || modules_disabled) 785 785 return -EPERM; 786 786 787 - if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) 788 - return -EFAULT; 789 - name[MODULE_NAME_LEN-1] = '\0'; 787 + len = strncpy_from_user(name, name_user, MODULE_NAME_LEN); 788 + if (len == 0 || len == MODULE_NAME_LEN) 789 + return -ENOENT; 790 + if (len < 0) 791 + return len; 790 792 791 793 audit_log_kern_module(name); 792 794
+1 -1
kernel/trace/trace.c
··· 10376 10376 { 10377 10377 /* All modules have the symbol __this_module */ 10378 10378 static const char this_mod[] = "__this_module"; 10379 - char modname[MAX_PARAM_PREFIX_LEN + sizeof(this_mod) + 2]; 10379 + char modname[MODULE_NAME_LEN + sizeof(this_mod) + 2]; 10380 10380 unsigned long val; 10381 10381 int n; 10382 10382
-8
lib/kunit/test.c
··· 802 802 } 803 803 EXPORT_SYMBOL_GPL(__kunit_test_suites_exit); 804 804 805 - #ifdef CONFIG_MODULES 806 805 static void kunit_module_init(struct module *mod) 807 806 { 808 807 struct kunit_suite_set suite_set, filtered_set; ··· 889 890 .notifier_call = kunit_module_notify, 890 891 .priority = 0, 891 892 }; 892 - #endif 893 893 894 894 KUNIT_DEFINE_ACTION_WRAPPER(kfree_action_wrapper, kfree, const void *) 895 895 ··· 979 981 kunit_debugfs_init(); 980 982 981 983 kunit_bus_init(); 982 - #ifdef CONFIG_MODULES 983 984 return register_module_notifier(&kunit_mod_nb); 984 - #else 985 - return 0; 986 - #endif 987 985 } 988 986 late_initcall(kunit_init); 989 987 990 988 static void __exit kunit_exit(void) 991 989 { 992 990 memset(&kunit_hooks, 0, sizeof(kunit_hooks)); 993 - #ifdef CONFIG_MODULES 994 991 unregister_module_notifier(&kunit_mod_nb); 995 - #endif 996 992 997 993 kunit_bus_shutdown(); 998 994