@@ -86,6 +86,12 @@ struct mod_tree_root mod_tree __cacheline_aligned = {
8686static unsigned long module_addr_min = -1UL , module_addr_max ;
8787#endif /* CONFIG_MODULES_TREE_LOOKUP */
8888
89+ struct symsearch {
90+ const struct kernel_symbol * start , * stop ;
91+ const s32 * crcs ;
92+ enum mod_license license ;
93+ };
94+
8995/*
9096 * Bounds of module text, for speeding up __module_address.
9197 * Protected by module_mutex.
@@ -244,28 +250,6 @@ static __maybe_unused void *any_section_objs(const struct load_info *info,
244250#define symversion (base , idx ) ((base != NULL) ? ((base) + (idx)) : NULL)
245251#endif
246252
247- struct symsearch {
248- const struct kernel_symbol * start , * stop ;
249- const s32 * crcs ;
250- enum mod_license {
251- NOT_GPL_ONLY ,
252- GPL_ONLY ,
253- } license ;
254- };
255-
256- struct find_symbol_arg {
257- /* Input */
258- const char * name ;
259- bool gplok ;
260- bool warn ;
261-
262- /* Output */
263- struct module * owner ;
264- const s32 * crc ;
265- const struct kernel_symbol * sym ;
266- enum mod_license license ;
267- };
268-
269253static bool check_exported_symbol (const struct symsearch * syms ,
270254 struct module * owner ,
271255 unsigned int symnum , void * data )
@@ -327,7 +311,7 @@ static bool find_exported_symbol_in_section(const struct symsearch *syms,
327311 * Find an exported symbol and return it, along with, (optional) crc and
328312 * (optional) module which owns it. Needs preempt disabled or module_mutex.
329313 */
330- static bool find_symbol (struct find_symbol_arg * fsa )
314+ bool find_symbol (struct find_symbol_arg * fsa )
331315{
332316 static const struct symsearch arr [] = {
333317 { __start___ksymtab , __stop___ksymtab , __start___kcrctab ,
@@ -1001,7 +985,7 @@ size_t modinfo_attrs_count = ARRAY_SIZE(modinfo_attrs);
1001985
1002986static const char vermagic [] = VERMAGIC_STRING ;
1003987
1004- static int try_to_force_load (struct module * mod , const char * reason )
988+ int try_to_force_load (struct module * mod , const char * reason )
1005989{
1006990#ifdef CONFIG_MODULE_FORCE_LOAD
1007991 if (!test_taint (TAINT_FORCED_MODULE ))
@@ -1013,115 +997,6 @@ static int try_to_force_load(struct module *mod, const char *reason)
1013997#endif
1014998}
1015999
1016- #ifdef CONFIG_MODVERSIONS
1017-
1018- static u32 resolve_rel_crc (const s32 * crc )
1019- {
1020- return * (u32 * )((void * )crc + * crc );
1021- }
1022-
1023- static int check_version (const struct load_info * info ,
1024- const char * symname ,
1025- struct module * mod ,
1026- const s32 * crc )
1027- {
1028- Elf_Shdr * sechdrs = info -> sechdrs ;
1029- unsigned int versindex = info -> index .vers ;
1030- unsigned int i , num_versions ;
1031- struct modversion_info * versions ;
1032-
1033- /* Exporting module didn't supply crcs? OK, we're already tainted. */
1034- if (!crc )
1035- return 1 ;
1036-
1037- /* No versions at all? modprobe --force does this. */
1038- if (versindex == 0 )
1039- return try_to_force_load (mod , symname ) == 0 ;
1040-
1041- versions = (void * ) sechdrs [versindex ].sh_addr ;
1042- num_versions = sechdrs [versindex ].sh_size
1043- / sizeof (struct modversion_info );
1044-
1045- for (i = 0 ; i < num_versions ; i ++ ) {
1046- u32 crcval ;
1047-
1048- if (strcmp (versions [i ].name , symname ) != 0 )
1049- continue ;
1050-
1051- if (IS_ENABLED (CONFIG_MODULE_REL_CRCS ))
1052- crcval = resolve_rel_crc (crc );
1053- else
1054- crcval = * crc ;
1055- if (versions [i ].crc == crcval )
1056- return 1 ;
1057- pr_debug ("Found checksum %X vs module %lX\n" ,
1058- crcval , versions [i ].crc );
1059- goto bad_version ;
1060- }
1061-
1062- /* Broken toolchain. Warn once, then let it go.. */
1063- pr_warn_once ("%s: no symbol version for %s\n" , info -> name , symname );
1064- return 1 ;
1065-
1066- bad_version :
1067- pr_warn ("%s: disagrees about version of symbol %s\n" ,
1068- info -> name , symname );
1069- return 0 ;
1070- }
1071-
1072- static inline int check_modstruct_version (const struct load_info * info ,
1073- struct module * mod )
1074- {
1075- struct find_symbol_arg fsa = {
1076- .name = "module_layout" ,
1077- .gplok = true,
1078- };
1079-
1080- /*
1081- * Since this should be found in kernel (which can't be removed), no
1082- * locking is necessary -- use preempt_disable() to placate lockdep.
1083- */
1084- preempt_disable ();
1085- if (!find_symbol (& fsa )) {
1086- preempt_enable ();
1087- BUG ();
1088- }
1089- preempt_enable ();
1090- return check_version (info , "module_layout" , mod , fsa .crc );
1091- }
1092-
1093- /* First part is kernel version, which we ignore if module has crcs. */
1094- static inline int same_magic (const char * amagic , const char * bmagic ,
1095- bool has_crcs )
1096- {
1097- if (has_crcs ) {
1098- amagic += strcspn (amagic , " " );
1099- bmagic += strcspn (bmagic , " " );
1100- }
1101- return strcmp (amagic , bmagic ) == 0 ;
1102- }
1103- #else
1104- static inline int check_version (const struct load_info * info ,
1105- const char * symname ,
1106- struct module * mod ,
1107- const s32 * crc )
1108- {
1109- return 1 ;
1110- }
1111-
1112- static inline int check_modstruct_version (const struct load_info * info ,
1113- struct module * mod )
1114- {
1115- return 1 ;
1116- }
1117-
1118- static inline int same_magic (const char * amagic , const char * bmagic ,
1119- bool has_crcs )
1120- {
1121- return strcmp (amagic , bmagic ) == 0 ;
1122- }
1123- #endif /* CONFIG_MODVERSIONS */
1124-
11251000static char * get_modinfo (const struct load_info * info , const char * tag );
11261001static char * get_next_modinfo (const struct load_info * info , const char * tag ,
11271002 char * prev );
@@ -3247,18 +3122,3 @@ void print_modules(void)
32473122 pr_cont (" [last unloaded: %s]" , last_unloaded_module );
32483123 pr_cont ("\n" );
32493124}
3250-
3251- #ifdef CONFIG_MODVERSIONS
3252- /*
3253- * Generate the signature for all relevant module structures here.
3254- * If these change, we don't want to try to parse the module.
3255- */
3256- void module_layout (struct module * mod ,
3257- struct modversion_info * ver ,
3258- struct kernel_param * kp ,
3259- struct kernel_symbol * ks ,
3260- struct tracepoint * const * tp )
3261- {
3262- }
3263- EXPORT_SYMBOL (module_layout );
3264- #endif
0 commit comments