]> Git Repo - linux.git/commitdiff
Merge tag 'modules-for-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu...
authorLinus Torvalds <[email protected]>
Wed, 13 Sep 2017 18:28:19 +0000 (11:28 -0700)
committerLinus Torvalds <[email protected]>
Wed, 13 Sep 2017 18:28:19 +0000 (11:28 -0700)
Pull modules updates from Jessica Yu:
 "Summary of modules changes for the 4.14 merge window:

   - minor code cleanups and fixes

   - modpost: avoid building modules that have names that exceed the
     size of the name field in struct module"

* tag 'modules-for-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux:
  module: Remove const attribute from alias for MODULE_DEVICE_TABLE
  module: fix ddebug_remove_module()
  modpost: abort if module name is too long

1  2 
scripts/mod/modpost.c

diff --combined scripts/mod/modpost.c
index b920d186ad4a9abad1ed5557c7504afd96b2548f,301c27740c5c4e85237070218ecbdb7403ec90b4..98314b400a95cd819ad9352518440de1e48db581
@@@ -47,6 -47,12 +47,12 @@@ enum export 
        export_unused_gpl, export_gpl_future, export_unknown
  };
  
+ /* In kernel, this size is defined in linux/module.h;
+  * here we use Elf_Addr instead of long for covering cross-compile
+  */
+ #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr))
  #define PRINTF __attribute__ ((format (printf, 1, 2)))
  
  PRINTF void fatal(const char *fmt, ...)
@@@ -261,17 -267,7 +267,17 @@@ static enum export export_no(const cha
        return export_unknown;
  }
  
 -static const char *sec_name(struct elf_info *elf, int secindex);
 +static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr)
 +{
 +      return (void *)elf->hdr +
 +              elf->sechdrs[elf->secindex_strings].sh_offset +
 +              sechdr->sh_name;
 +}
 +
 +static const char *sec_name(struct elf_info *elf, int secindex)
 +{
 +      return sech_name(elf, &elf->sechdrs[secindex]);
 +}
  
  #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
  
@@@ -785,6 -781,21 +791,6 @@@ static const char *sym_name(struct elf_
                return "(unknown)";
  }
  
 -static const char *sec_name(struct elf_info *elf, int secindex)
 -{
 -      Elf_Shdr *sechdrs = elf->sechdrs;
 -      return (void *)elf->hdr +
 -              elf->sechdrs[elf->secindex_strings].sh_offset +
 -              sechdrs[secindex].sh_name;
 -}
 -
 -static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr)
 -{
 -      return (void *)elf->hdr +
 -              elf->sechdrs[elf->secindex_strings].sh_offset +
 -              sechdr->sh_name;
 -}
 -
  /* The pattern is an array of simple patterns.
   * "foo" will match an exact string equal to "foo"
   * "*foo" will match a string that ends with "foo"
@@@ -2111,6 -2122,23 +2117,23 @@@ static void check_exports(struct modul
        }
  }
  
+ static int check_modname_len(struct module *mod)
+ {
+       const char *mod_name;
+       mod_name = strrchr(mod->name, '/');
+       if (mod_name == NULL)
+               mod_name = mod->name;
+       else
+               mod_name++;
+       if (strlen(mod_name) >= MODULE_NAME_LEN) {
+               merror("module name is too long [%s.ko]\n", mod->name);
+               return 1;
+       }
+       return 0;
+ }
  /**
   * Header for the generated file
   **/
@@@ -2150,11 -2178,6 +2173,6 @@@ static void add_staging_flag(struct buf
                buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
  }
  
- /* In kernel, this size is defined in linux/module.h;
-  * here we use Elf_Addr instead of long for covering cross-compile
-  */
- #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr))
  /**
   * Record CRCs for unresolved symbols
   **/
@@@ -2485,6 -2508,7 +2503,7 @@@ int main(int argc, char **argv
  
                buf.pos = 0;
  
+               err |= check_modname_len(mod);
                add_header(&buf, mod);
                add_intree_flag(&buf, !external_module);
                add_staging_flag(&buf, mod->name);
This page took 0.077048 seconds and 4 git commands to generate.