aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-05-14 13:55:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-05-14 13:55:54 -0400
commit280664f558c9d973315d48f125eb664cc607d089 (patch)
tree681375d73394670824c2bff1936fbbd62d8c3d1a
parente0654264c4806dc436b291294a0fbf9be7571ab6 (diff)
parentdadec066d8fa7da227f623f632ea114690fecaf8 (diff)
Merge tag 'modules-for-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux
Pull modules updates from Jessica Yu: - Use a separate table to store symbol types instead of hijacking fields in struct Elf_Sym - Trivial code cleanups * tag 'modules-for-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux: module: add stubs for within_module functions kallsyms: store type information in its own array vmlinux.lds.h: drop unused __vermagic
-rw-r--r--include/asm-generic/vmlinux.lds.h1
-rw-r--r--include/linux/module.h12
-rw-r--r--kernel/module-internal.h2
-rw-r--r--kernel/module.c21
4 files changed, 27 insertions, 9 deletions
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index bbb9e332f2fe..088987e9a3ea 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -332,7 +332,6 @@
332 __start_rodata = .; \ 332 __start_rodata = .; \
333 *(.rodata) *(.rodata.*) \ 333 *(.rodata) *(.rodata.*) \
334 RO_AFTER_INIT_DATA /* Read only after init */ \ 334 RO_AFTER_INIT_DATA /* Read only after init */ \
335 KEEP(*(__vermagic)) /* Kernel version magic */ \
336 . = ALIGN(8); \ 335 . = ALIGN(8); \
337 __start___tracepoints_ptrs = .; \ 336 __start___tracepoints_ptrs = .; \
338 KEEP(*(__tracepoints_ptrs)) /* Tracepoints: pointer array */ \ 337 KEEP(*(__tracepoints_ptrs)) /* Tracepoints: pointer array */ \
diff --git a/include/linux/module.h b/include/linux/module.h
index 8f75277d4cef..188998d3dca9 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -332,6 +332,7 @@ struct mod_kallsyms {
332 Elf_Sym *symtab; 332 Elf_Sym *symtab;
333 unsigned int num_symtab; 333 unsigned int num_symtab;
334 char *strtab; 334 char *strtab;
335 char *typetab;
335}; 336};
336 337
337#ifdef CONFIG_LIVEPATCH 338#ifdef CONFIG_LIVEPATCH
@@ -717,6 +718,17 @@ static inline bool within_module_core(unsigned long addr,
717 return false; 718 return false;
718} 719}
719 720
721static inline bool within_module_init(unsigned long addr,
722 const struct module *mod)
723{
724 return false;
725}
726
727static inline bool within_module(unsigned long addr, const struct module *mod)
728{
729 return false;
730}
731
720/* Get/put a kernel symbol (calls should be symmetric) */ 732/* Get/put a kernel symbol (calls should be symmetric) */
721#define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); }) 733#define symbol_get(x) ({ extern typeof(x) x __attribute__((weak)); &(x); })
722#define symbol_put(x) do { } while (0) 734#define symbol_put(x) do { } while (0)
diff --git a/kernel/module-internal.h b/kernel/module-internal.h
index 79c9be2dbbe9..d354341f8cc0 100644
--- a/kernel/module-internal.h
+++ b/kernel/module-internal.h
@@ -20,7 +20,7 @@ struct load_info {
20 unsigned long len; 20 unsigned long len;
21 Elf_Shdr *sechdrs; 21 Elf_Shdr *sechdrs;
22 char *secstrings, *strtab; 22 char *secstrings, *strtab;
23 unsigned long symoffs, stroffs; 23 unsigned long symoffs, stroffs, init_typeoffs, core_typeoffs;
24 struct _ddebug *debug; 24 struct _ddebug *debug;
25 unsigned int num_debug; 25 unsigned int num_debug;
26 bool sig_ok; 26 bool sig_ok;
diff --git a/kernel/module.c b/kernel/module.c
index a9e1e7f2c224..6e6712b3aaf5 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2642,6 +2642,8 @@ static void layout_symtab(struct module *mod, struct load_info *info)
2642 info->symoffs = ALIGN(mod->core_layout.size, symsect->sh_addralign ?: 1); 2642 info->symoffs = ALIGN(mod->core_layout.size, symsect->sh_addralign ?: 1);
2643 info->stroffs = mod->core_layout.size = info->symoffs + ndst * sizeof(Elf_Sym); 2643 info->stroffs = mod->core_layout.size = info->symoffs + ndst * sizeof(Elf_Sym);
2644 mod->core_layout.size += strtab_size; 2644 mod->core_layout.size += strtab_size;
2645 info->core_typeoffs = mod->core_layout.size;
2646 mod->core_layout.size += ndst * sizeof(char);
2645 mod->core_layout.size = debug_align(mod->core_layout.size); 2647 mod->core_layout.size = debug_align(mod->core_layout.size);
2646 2648
2647 /* Put string table section at end of init part of module. */ 2649 /* Put string table section at end of init part of module. */
@@ -2655,6 +2657,8 @@ static void layout_symtab(struct module *mod, struct load_info *info)
2655 __alignof__(struct mod_kallsyms)); 2657 __alignof__(struct mod_kallsyms));
2656 info->mod_kallsyms_init_off = mod->init_layout.size; 2658 info->mod_kallsyms_init_off = mod->init_layout.size;
2657 mod->init_layout.size += sizeof(struct mod_kallsyms); 2659 mod->init_layout.size += sizeof(struct mod_kallsyms);
2660 info->init_typeoffs = mod->init_layout.size;
2661 mod->init_layout.size += nsrc * sizeof(char);
2658 mod->init_layout.size = debug_align(mod->init_layout.size); 2662 mod->init_layout.size = debug_align(mod->init_layout.size);
2659} 2663}
2660 2664
@@ -2678,20 +2682,23 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
2678 mod->kallsyms->num_symtab = symsec->sh_size / sizeof(Elf_Sym); 2682 mod->kallsyms->num_symtab = symsec->sh_size / sizeof(Elf_Sym);
2679 /* Make sure we get permanent strtab: don't use info->strtab. */ 2683 /* Make sure we get permanent strtab: don't use info->strtab. */
2680 mod->kallsyms->strtab = (void *)info->sechdrs[info->index.str].sh_addr; 2684 mod->kallsyms->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
2685 mod->kallsyms->typetab = mod->init_layout.base + info->init_typeoffs;
2681 2686
2682 /* Set types up while we still have access to sections. */ 2687 /*
2683 for (i = 0; i < mod->kallsyms->num_symtab; i++) 2688 * Now populate the cut down core kallsyms for after init
2684 mod->kallsyms->symtab[i].st_size 2689 * and set types up while we still have access to sections.
2685 = elf_type(&mod->kallsyms->symtab[i], info); 2690 */
2686
2687 /* Now populate the cut down core kallsyms for after init. */
2688 mod->core_kallsyms.symtab = dst = mod->core_layout.base + info->symoffs; 2691 mod->core_kallsyms.symtab = dst = mod->core_layout.base + info->symoffs;
2689 mod->core_kallsyms.strtab = s = mod->core_layout.base + info->stroffs; 2692 mod->core_kallsyms.strtab = s = mod->core_layout.base + info->stroffs;
2693 mod->core_kallsyms.typetab = mod->core_layout.base + info->core_typeoffs;
2690 src = mod->kallsyms->symtab; 2694 src = mod->kallsyms->symtab;
2691 for (ndst = i = 0; i < mod->kallsyms->num_symtab; i++) { 2695 for (ndst = i = 0; i < mod->kallsyms->num_symtab; i++) {
2696 mod->kallsyms->typetab[i] = elf_type(src + i, info);
2692 if (i == 0 || is_livepatch_module(mod) || 2697 if (i == 0 || is_livepatch_module(mod) ||
2693 is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum, 2698 is_core_symbol(src+i, info->sechdrs, info->hdr->e_shnum,
2694 info->index.pcpu)) { 2699 info->index.pcpu)) {
2700 mod->core_kallsyms.typetab[ndst] =
2701 mod->kallsyms->typetab[i];
2695 dst[ndst] = src[i]; 2702 dst[ndst] = src[i];
2696 dst[ndst++].st_name = s - mod->core_kallsyms.strtab; 2703 dst[ndst++].st_name = s - mod->core_kallsyms.strtab;
2697 s += strlcpy(s, &mod->kallsyms->strtab[src[i].st_name], 2704 s += strlcpy(s, &mod->kallsyms->strtab[src[i].st_name],
@@ -4091,7 +4098,7 @@ int module_get_kallsym(unsigned int symnum, unsigned long *value, char *type,
4091 const Elf_Sym *sym = &kallsyms->symtab[symnum]; 4098 const Elf_Sym *sym = &kallsyms->symtab[symnum];
4092 4099
4093 *value = kallsyms_symbol_value(sym); 4100 *value = kallsyms_symbol_value(sym);
4094 *type = sym->st_size; 4101 *type = kallsyms->typetab[symnum];
4095 strlcpy(name, kallsyms_symbol_name(kallsyms, symnum), KSYM_NAME_LEN); 4102 strlcpy(name, kallsyms_symbol_name(kallsyms, symnum), KSYM_NAME_LEN);
4096 strlcpy(module_name, mod->name, MODULE_NAME_LEN); 4103 strlcpy(module_name, mod->name, MODULE_NAME_LEN);
4097 *exported = is_exported(name, *value, mod); 4104 *exported = is_exported(name, *value, mod);