diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-05 13:58:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-05 13:58:06 -0400 |
commit | f8ce1faf55955de62e0a12e330c6d9a526071f65 (patch) | |
tree | a3b0ddd3f37e40d3ed0fd2cd433a2723403c8b97 /kernel | |
parent | 24d0c2542b38963ae4d5171ecc0a2c1326c656bc (diff) | |
parent | a53a11f35762ff1d5e268adedf2ab9ce313f871d (diff) |
Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull mudule updates from Rusty Russell:
"We get rid of the general module prefix confusion with a binary config
option, fix a remove/insert race which Never Happens, and (my
favorite) handle the case when we have too many modules for a single
commandline. Seriously, the kernel is full, please go away!"
* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
modpost: fix unwanted VMLINUX_SYMBOL_STR expansion
X.509: Support parse long form of length octets in Authority Key Identifier
module: don't unlink the module until we've removed all exposure.
kernel: kallsyms: memory override issue, need check destination buffer length
MODSIGN: do not send garbage to stderr when enabling modules signature
modpost: handle huge numbers of modules.
modpost: add -T option to read module names from file/stdin.
modpost: minor cleanup.
genksyms: pass symbol-prefix instead of arch
module: fix symbol versioning with symbol prefixes
CONFIG_SYMBOL_PREFIX: cleanup.
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/Makefile | 2 | ||||
-rw-r--r-- | kernel/kallsyms.c | 26 | ||||
-rw-r--r-- | kernel/modsign_certificate.S | 13 | ||||
-rw-r--r-- | kernel/module.c | 18 |
4 files changed, 34 insertions, 25 deletions
diff --git a/kernel/Makefile b/kernel/Makefile index d1574d47cf27..271fd3119af9 100644 --- a/kernel/Makefile +++ b/kernel/Makefile | |||
@@ -176,7 +176,7 @@ signing_key.priv signing_key.x509: x509.genkey | |||
176 | openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \ | 176 | openssl req -new -nodes -utf8 -$(CONFIG_MODULE_SIG_HASH) -days 36500 \ |
177 | -batch -x509 -config x509.genkey \ | 177 | -batch -x509 -config x509.genkey \ |
178 | -outform DER -out signing_key.x509 \ | 178 | -outform DER -out signing_key.x509 \ |
179 | -keyout signing_key.priv | 179 | -keyout signing_key.priv 2>&1 |
180 | @echo "###" | 180 | @echo "###" |
181 | @echo "### Key pair generated." | 181 | @echo "### Key pair generated." |
182 | @echo "###" | 182 | @echo "###" |
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 2169feeba529..3127ad52cdb2 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c | |||
@@ -84,9 +84,11 @@ static int is_ksym_addr(unsigned long addr) | |||
84 | 84 | ||
85 | /* | 85 | /* |
86 | * Expand a compressed symbol data into the resulting uncompressed string, | 86 | * Expand a compressed symbol data into the resulting uncompressed string, |
87 | * if uncompressed string is too long (>= maxlen), it will be truncated, | ||
87 | * given the offset to where the symbol is in the compressed stream. | 88 | * given the offset to where the symbol is in the compressed stream. |
88 | */ | 89 | */ |
89 | static unsigned int kallsyms_expand_symbol(unsigned int off, char *result) | 90 | static unsigned int kallsyms_expand_symbol(unsigned int off, |
91 | char *result, size_t maxlen) | ||
90 | { | 92 | { |
91 | int len, skipped_first = 0; | 93 | int len, skipped_first = 0; |
92 | const u8 *tptr, *data; | 94 | const u8 *tptr, *data; |
@@ -113,15 +115,20 @@ static unsigned int kallsyms_expand_symbol(unsigned int off, char *result) | |||
113 | 115 | ||
114 | while (*tptr) { | 116 | while (*tptr) { |
115 | if (skipped_first) { | 117 | if (skipped_first) { |
118 | if (maxlen <= 1) | ||
119 | goto tail; | ||
116 | *result = *tptr; | 120 | *result = *tptr; |
117 | result++; | 121 | result++; |
122 | maxlen--; | ||
118 | } else | 123 | } else |
119 | skipped_first = 1; | 124 | skipped_first = 1; |
120 | tptr++; | 125 | tptr++; |
121 | } | 126 | } |
122 | } | 127 | } |
123 | 128 | ||
124 | *result = '\0'; | 129 | tail: |
130 | if (maxlen) | ||
131 | *result = '\0'; | ||
125 | 132 | ||
126 | /* Return to offset to the next symbol. */ | 133 | /* Return to offset to the next symbol. */ |
127 | return off; | 134 | return off; |
@@ -176,7 +183,7 @@ unsigned long kallsyms_lookup_name(const char *name) | |||
176 | unsigned int off; | 183 | unsigned int off; |
177 | 184 | ||
178 | for (i = 0, off = 0; i < kallsyms_num_syms; i++) { | 185 | for (i = 0, off = 0; i < kallsyms_num_syms; i++) { |
179 | off = kallsyms_expand_symbol(off, namebuf); | 186 | off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf)); |
180 | 187 | ||
181 | if (strcmp(namebuf, name) == 0) | 188 | if (strcmp(namebuf, name) == 0) |
182 | return kallsyms_addresses[i]; | 189 | return kallsyms_addresses[i]; |
@@ -195,7 +202,7 @@ int kallsyms_on_each_symbol(int (*fn)(void *, const char *, struct module *, | |||
195 | int ret; | 202 | int ret; |
196 | 203 | ||
197 | for (i = 0, off = 0; i < kallsyms_num_syms; i++) { | 204 | for (i = 0, off = 0; i < kallsyms_num_syms; i++) { |
198 | off = kallsyms_expand_symbol(off, namebuf); | 205 | off = kallsyms_expand_symbol(off, namebuf, ARRAY_SIZE(namebuf)); |
199 | ret = fn(data, namebuf, NULL, kallsyms_addresses[i]); | 206 | ret = fn(data, namebuf, NULL, kallsyms_addresses[i]); |
200 | if (ret != 0) | 207 | if (ret != 0) |
201 | return ret; | 208 | return ret; |
@@ -294,7 +301,8 @@ const char *kallsyms_lookup(unsigned long addr, | |||
294 | 301 | ||
295 | pos = get_symbol_pos(addr, symbolsize, offset); | 302 | pos = get_symbol_pos(addr, symbolsize, offset); |
296 | /* Grab name */ | 303 | /* Grab name */ |
297 | kallsyms_expand_symbol(get_symbol_offset(pos), namebuf); | 304 | kallsyms_expand_symbol(get_symbol_offset(pos), |
305 | namebuf, KSYM_NAME_LEN); | ||
298 | if (modname) | 306 | if (modname) |
299 | *modname = NULL; | 307 | *modname = NULL; |
300 | return namebuf; | 308 | return namebuf; |
@@ -315,7 +323,8 @@ int lookup_symbol_name(unsigned long addr, char *symname) | |||
315 | 323 | ||
316 | pos = get_symbol_pos(addr, NULL, NULL); | 324 | pos = get_symbol_pos(addr, NULL, NULL); |
317 | /* Grab name */ | 325 | /* Grab name */ |
318 | kallsyms_expand_symbol(get_symbol_offset(pos), symname); | 326 | kallsyms_expand_symbol(get_symbol_offset(pos), |
327 | symname, KSYM_NAME_LEN); | ||
319 | return 0; | 328 | return 0; |
320 | } | 329 | } |
321 | /* See if it's in a module. */ | 330 | /* See if it's in a module. */ |
@@ -333,7 +342,8 @@ int lookup_symbol_attrs(unsigned long addr, unsigned long *size, | |||
333 | 342 | ||
334 | pos = get_symbol_pos(addr, size, offset); | 343 | pos = get_symbol_pos(addr, size, offset); |
335 | /* Grab name */ | 344 | /* Grab name */ |
336 | kallsyms_expand_symbol(get_symbol_offset(pos), name); | 345 | kallsyms_expand_symbol(get_symbol_offset(pos), |
346 | name, KSYM_NAME_LEN); | ||
337 | modname[0] = '\0'; | 347 | modname[0] = '\0'; |
338 | return 0; | 348 | return 0; |
339 | } | 349 | } |
@@ -463,7 +473,7 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter) | |||
463 | 473 | ||
464 | iter->type = kallsyms_get_symbol_type(off); | 474 | iter->type = kallsyms_get_symbol_type(off); |
465 | 475 | ||
466 | off = kallsyms_expand_symbol(off, iter->name); | 476 | off = kallsyms_expand_symbol(off, iter->name, ARRAY_SIZE(iter->name)); |
467 | 477 | ||
468 | return off - iter->nameoff; | 478 | return off - iter->nameoff; |
469 | } | 479 | } |
diff --git a/kernel/modsign_certificate.S b/kernel/modsign_certificate.S index 246b4c6e6135..4a9a86d12c8b 100644 --- a/kernel/modsign_certificate.S +++ b/kernel/modsign_certificate.S | |||
@@ -1,15 +1,8 @@ | |||
1 | /* SYMBOL_PREFIX defined on commandline from CONFIG_SYMBOL_PREFIX */ | 1 | #include <linux/export.h> |
2 | #ifndef SYMBOL_PREFIX | ||
3 | #define ASM_SYMBOL(sym) sym | ||
4 | #else | ||
5 | #define PASTE2(x,y) x##y | ||
6 | #define PASTE(x,y) PASTE2(x,y) | ||
7 | #define ASM_SYMBOL(sym) PASTE(SYMBOL_PREFIX, sym) | ||
8 | #endif | ||
9 | 2 | ||
10 | #define GLOBAL(name) \ | 3 | #define GLOBAL(name) \ |
11 | .globl ASM_SYMBOL(name); \ | 4 | .globl VMLINUX_SYMBOL(name); \ |
12 | ASM_SYMBOL(name): | 5 | VMLINUX_SYMBOL(name): |
13 | 6 | ||
14 | .section ".init.data","aw" | 7 | .section ".init.data","aw" |
15 | 8 | ||
diff --git a/kernel/module.c b/kernel/module.c index 0925c9a71975..b049939177f6 100644 --- a/kernel/module.c +++ b/kernel/module.c | |||
@@ -1209,10 +1209,11 @@ static inline int check_modstruct_version(Elf_Shdr *sechdrs, | |||
1209 | 1209 | ||
1210 | /* Since this should be found in kernel (which can't be removed), | 1210 | /* Since this should be found in kernel (which can't be removed), |
1211 | * no locking is necessary. */ | 1211 | * no locking is necessary. */ |
1212 | if (!find_symbol(MODULE_SYMBOL_PREFIX "module_layout", NULL, | 1212 | if (!find_symbol(VMLINUX_SYMBOL_STR(module_layout), NULL, |
1213 | &crc, true, false)) | 1213 | &crc, true, false)) |
1214 | BUG(); | 1214 | BUG(); |
1215 | return check_version(sechdrs, versindex, "module_layout", mod, crc, | 1215 | return check_version(sechdrs, versindex, |
1216 | VMLINUX_SYMBOL_STR(module_layout), mod, crc, | ||
1216 | NULL); | 1217 | NULL); |
1217 | } | 1218 | } |
1218 | 1219 | ||
@@ -1861,12 +1862,12 @@ static void free_module(struct module *mod) | |||
1861 | { | 1862 | { |
1862 | trace_module_free(mod); | 1863 | trace_module_free(mod); |
1863 | 1864 | ||
1864 | /* Delete from various lists */ | ||
1865 | mutex_lock(&module_mutex); | ||
1866 | stop_machine(__unlink_module, mod, NULL); | ||
1867 | mutex_unlock(&module_mutex); | ||
1868 | mod_sysfs_teardown(mod); | 1865 | mod_sysfs_teardown(mod); |
1869 | 1866 | ||
1867 | /* We leave it in list to prevent duplicate loads, but make sure | ||
1868 | * that noone uses it while it's being deconstructed. */ | ||
1869 | mod->state = MODULE_STATE_UNFORMED; | ||
1870 | |||
1870 | /* Remove dynamic debug info */ | 1871 | /* Remove dynamic debug info */ |
1871 | ddebug_remove_module(mod->name); | 1872 | ddebug_remove_module(mod->name); |
1872 | 1873 | ||
@@ -1879,6 +1880,11 @@ static void free_module(struct module *mod) | |||
1879 | /* Free any allocated parameters. */ | 1880 | /* Free any allocated parameters. */ |
1880 | destroy_params(mod->kp, mod->num_kp); | 1881 | destroy_params(mod->kp, mod->num_kp); |
1881 | 1882 | ||
1883 | /* Now we can delete it from the lists */ | ||
1884 | mutex_lock(&module_mutex); | ||
1885 | stop_machine(__unlink_module, mod, NULL); | ||
1886 | mutex_unlock(&module_mutex); | ||
1887 | |||
1882 | /* This may be NULL, but that's OK */ | 1888 | /* This may be NULL, but that's OK */ |
1883 | unset_module_init_ro_nx(mod); | 1889 | unset_module_init_ro_nx(mod); |
1884 | module_free(mod, mod->module_init); | 1890 | module_free(mod, mod->module_init); |