diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-13 14:28:19 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-13 14:28:19 -0400 |
| commit | 4791bcccf8ce02c2bf6f9dfbc328a3a46d9e9569 (patch) | |
| tree | 5224a477d2c8b81acf6798f719cf302de71a9c96 /scripts/mod | |
| parent | 3882a734c19b3cd7feb9e30e1dbd8ae54ac0905a (diff) | |
| parent | 0bf8bf50eddc7511b52461bae798cbfaa0157a34 (diff) | |
Merge tag 'modules-for-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux
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
Diffstat (limited to 'scripts/mod')
| -rw-r--r-- | scripts/mod/modpost.c | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index b920d186ad4a..98314b400a95 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
| @@ -47,6 +47,12 @@ enum export { | |||
| 47 | export_unused_gpl, export_gpl_future, export_unknown | 47 | export_unused_gpl, export_gpl_future, export_unknown |
| 48 | }; | 48 | }; |
| 49 | 49 | ||
| 50 | /* In kernel, this size is defined in linux/module.h; | ||
| 51 | * here we use Elf_Addr instead of long for covering cross-compile | ||
| 52 | */ | ||
| 53 | |||
| 54 | #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) | ||
| 55 | |||
| 50 | #define PRINTF __attribute__ ((format (printf, 1, 2))) | 56 | #define PRINTF __attribute__ ((format (printf, 1, 2))) |
| 51 | 57 | ||
| 52 | PRINTF void fatal(const char *fmt, ...) | 58 | PRINTF void fatal(const char *fmt, ...) |
| @@ -2111,6 +2117,23 @@ static void check_exports(struct module *mod) | |||
| 2111 | } | 2117 | } |
| 2112 | } | 2118 | } |
| 2113 | 2119 | ||
| 2120 | static int check_modname_len(struct module *mod) | ||
| 2121 | { | ||
| 2122 | const char *mod_name; | ||
| 2123 | |||
| 2124 | mod_name = strrchr(mod->name, '/'); | ||
| 2125 | if (mod_name == NULL) | ||
| 2126 | mod_name = mod->name; | ||
| 2127 | else | ||
| 2128 | mod_name++; | ||
| 2129 | if (strlen(mod_name) >= MODULE_NAME_LEN) { | ||
| 2130 | merror("module name is too long [%s.ko]\n", mod->name); | ||
| 2131 | return 1; | ||
| 2132 | } | ||
| 2133 | |||
| 2134 | return 0; | ||
| 2135 | } | ||
| 2136 | |||
| 2114 | /** | 2137 | /** |
| 2115 | * Header for the generated file | 2138 | * Header for the generated file |
| 2116 | **/ | 2139 | **/ |
| @@ -2150,11 +2173,6 @@ static void add_staging_flag(struct buffer *b, const char *name) | |||
| 2150 | buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); | 2173 | buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); |
| 2151 | } | 2174 | } |
| 2152 | 2175 | ||
| 2153 | /* In kernel, this size is defined in linux/module.h; | ||
| 2154 | * here we use Elf_Addr instead of long for covering cross-compile | ||
| 2155 | */ | ||
| 2156 | #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) | ||
| 2157 | |||
| 2158 | /** | 2176 | /** |
| 2159 | * Record CRCs for unresolved symbols | 2177 | * Record CRCs for unresolved symbols |
| 2160 | **/ | 2178 | **/ |
| @@ -2485,6 +2503,7 @@ int main(int argc, char **argv) | |||
| 2485 | 2503 | ||
| 2486 | buf.pos = 0; | 2504 | buf.pos = 0; |
| 2487 | 2505 | ||
| 2506 | err |= check_modname_len(mod); | ||
| 2488 | add_header(&buf, mod); | 2507 | add_header(&buf, mod); |
| 2489 | add_intree_flag(&buf, !external_module); | 2508 | add_intree_flag(&buf, !external_module); |
| 2490 | add_staging_flag(&buf, mod->name); | 2509 | add_staging_flag(&buf, mod->name); |
