History

Merge tag 'modules-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux

Pull modules updates from Luis Chamberlain: - It was time to tidy up kernel/module.c and one way of starting with that effort was to split it up into files. At my request Aaron Tomlin spearheaded that effort with the goal to not introduce any functional at all during that endeavour. The penalty for the split is +1322 bytes total, +112 bytes in data, +1210 bytes in text while bss is unchanged. One of the benefits of this other than helping make the code easier to read and review is summoning more help on review for changes with livepatching so kernel/module/livepatch.c is now pegged as maintained by the live patching folks. The before and after with just the move on a defconfig on x86-64: $ size kernel/module.o text data bss dec hex filename 38434 4540 104 43078 a846 kernel/module.o $ size -t kernel/module/*.o text data bss dec hex filename 4785 120 0 4905 1329 kernel/module/kallsyms.o 28577 4416 104 33097 8149 kernel/module/main.o 1158 8 0 1166 48e kernel/module/procfs.o 902 108 0 1010 3f2 kernel/module/strict_rwx.o 3390 0 0 3390 d3e kernel/module/sysfs.o 832 0 0 832 340 kernel/module/tree_lookup.o 39644 4652 104 44400 ad70 (TOTALS) - Aaron added module unload taint tracking (MODULE_UNLOAD_TAINT_TRACKING), to enable tracking unloaded modules which did taint the kernel. - Christophe Leroy added CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC which lets architectures to request having modules data in vmalloc area instead of module area. There are three reasons why an architecture might want this: a) On some architectures (like book3s/32) it is not possible to protect against execution on a page basis. The exec stuff can be mapped by different arch segment sizes (on book3s/32 that is 256M segments). By default the module area is in an Exec segment while vmalloc area is in a NoExec segment. Using vmalloc lets you muck with module data as NoExec on those architectures whereas before you could not. b) By pushing more module data to vmalloc you also increase the probability of module text to remain within a closer distance from kernel core text and this reduces trampolines, this has been reported on arm first and powerpc folks are following that lead. c) Free'ing module_alloc() (Exec by default) area leaves this exposed as Exec by default, some architectures have some security enhancements to set this as NoExec on free, and splitting module data with text let's future generic special allocators be added to the kernel without having developers try to grok the tribal knowledge per arch. Work like Rick Edgecombe's permission vmalloc interface [0] becomes easier to address over time. [0] https://lore.kernel.org/lkml/20201120202426.18009-1-rick.p.edgecombe@intel.com/#r - Masahiro Yamada's symbol search enhancements * tag 'modules-5.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux: (33 commits) module: merge check_exported_symbol() into find_exported_symbol_in_section() module: do not binary-search in __ksymtab_gpl if fsa->gplok is false module: do not pass opaque pointer for symbol search module: show disallowed symbol name for inherit_taint() module: fix [e_shstrndx].sh_size=0 OOB access module: Introduce module unload taint tracking module: Move module_assert_mutex_or_preempt() to internal.h module: Make module_flags_taint() accept a module's taints bitmap and usable outside core code module.h: simplify MODULE_IMPORT_NS powerpc: Select ARCH_WANTS_MODULES_DATA_IN_VMALLOC on book3s/32 and 8xx module: Remove module_addr_min and module_addr_max module: Add CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC module: Introduce data_layout module: Prepare for handling several RB trees module: Always have struct mod_tree_root module: Rename debug_align() as strict_align() module: Rework layout alignment to avoid BUG_ON()s module: Move module_enable_x() and frob_text() in strict_rwx.c module: Make module_enable_x() independent of CONFIG_ARCH_HAS_STRICT_MODULE_RWX module: Move version support into a separate file ...

Linus Torvalds committed 4 years ago

Commit ef98f9c2 parents 44d3572 7390b9429 files · +2384 −2052Browse files

Showing the changes to kernel/debug (5 of 29 files). Show all

Unified · Split

5 files
  1. kernel/debug/kdb/kdb_io.c +0 −1
  2. kernel/debug/kdb/kdb_keyboard.c +0 −1
  3. kernel/debug/kdb/kdb_main.c +0 −49
  4. kernel/debug/kdb/kdb_private.h +0 −4
  5. kernel/debug/kdb/kdb_support.c +0 −1
kernel/debug/kdb/kdb_io.c+0−1
@@ -9,7 +9,6 @@ · 8 unmodified lines
9 * Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved.9 * Copyright (c) 2009 Wind River Systems, Inc. All Rights Reserved.
10 */10 */
11 11
12#include <linux/module.h>
13#include <linux/types.h>12#include <linux/types.h>
14#include <linux/ctype.h>13#include <linux/ctype.h>
15#include <linux/kernel.h>14#include <linux/kernel.h>
kernel/debug/kdb/kdb_keyboard.c+0−1
@@ -11,7 +11,6 @@ · 10 unmodified lines
11#include <linux/kdb.h>11#include <linux/kdb.h>
12#include <linux/keyboard.h>12#include <linux/keyboard.h>
13#include <linux/ctype.h>13#include <linux/ctype.h>
14#include <linux/module.h>
15#include <linux/io.h>14#include <linux/io.h>
16 15
17/* Keyboard Controller Registers on normal PCs. */16/* Keyboard Controller Registers on normal PCs. */
kernel/debug/kdb/kdb_main.c+0−49
@@ -26,7 +26,6 @@ · 25 unmodified lines
26#include <linux/utsname.h>26#include <linux/utsname.h>
27#include <linux/vmalloc.h>27#include <linux/vmalloc.h>
28#include <linux/atomic.h>28#include <linux/atomic.h>
29#include <linux/module.h>
30#include <linux/moduleparam.h>29#include <linux/moduleparam.h>
31#include <linux/mm.h>30#include <linux/mm.h>
32#include <linux/init.h>31#include <linux/init.h>
@@ -2060,54 +2059,6 @@ static int kdb_ef(int argc, const char **argv) · 2027 unmodified lines
2060 return 0;2059 return 0;
2061}2060}
2062 2061
2063#if defined(CONFIG_MODULES)
2064/*
2065 * kdb_lsmod - This function implements the 'lsmod' command. Lists
2066 * currently loaded kernel modules.
2067 * Mostly taken from userland lsmod.
2068 */
2069static int kdb_lsmod(int argc, const char **argv)
2070{
2071 struct module *mod;
2072
2073 if (argc != 0)
2074 return KDB_ARGCOUNT;
2075
2076 kdb_printf("Module Size modstruct Used by\n");
2077 list_for_each_entry(mod, kdb_modules, list) {
2078 if (mod->state == MODULE_STATE_UNFORMED)
2079 continue;
2080
2081 kdb_printf("%-20s%8u 0x%px ", mod->name,
2082 mod->core_layout.size, (void *)mod);
2083#ifdef CONFIG_MODULE_UNLOAD
2084 kdb_printf("%4d ", module_refcount(mod));
2085#endif
2086 if (mod->state == MODULE_STATE_GOING)
2087 kdb_printf(" (Unloading)");
2088 else if (mod->state == MODULE_STATE_COMING)
2089 kdb_printf(" (Loading)");
2090 else
2091 kdb_printf(" (Live)");
2092 kdb_printf(" 0x%px", mod->core_layout.base);
2093
2094#ifdef CONFIG_MODULE_UNLOAD
2095 {
2096 struct module_use *use;
2097 kdb_printf(" [ ");
2098 list_for_each_entry(use, &mod->source_list,
2099 source_list)
2100 kdb_printf("%s ", use->target->name);
2101 kdb_printf("]\n");
2102 }
2103#endif
2104 }
2105
2106 return 0;
2107}
2108
2109#endif /* CONFIG_MODULES */
2110
2111/*2062/*
2112 * kdb_env - This function implements the 'env' command. Display the2063 * kdb_env - This function implements the 'env' command. Display the
2113 * current environment variables.2064 * current environment variables.
kernel/debug/kdb/kdb_private.h+0−4
@@ -226,10 +226,6 @@ extern void kdb_kbd_cleanup_state(void); · 225 unmodified lines
226#define kdb_kbd_cleanup_state()226#define kdb_kbd_cleanup_state()
227#endif /* ! CONFIG_KDB_KEYBOARD */227#endif /* ! CONFIG_KDB_KEYBOARD */
228 228
229#ifdef CONFIG_MODULES
230extern struct list_head *kdb_modules;
231#endif /* CONFIG_MODULES */
232
233extern char kdb_prompt_str[];229extern char kdb_prompt_str[];
234 230
235#define KDB_WORD_SIZE ((int)sizeof(unsigned long))231#define KDB_WORD_SIZE ((int)sizeof(unsigned long))
kernel/debug/kdb/kdb_support.c+0−1
@@ -17,7 +17,6 @@ · 16 unmodified lines
17#include <linux/stddef.h>17#include <linux/stddef.h>
18#include <linux/vmalloc.h>18#include <linux/vmalloc.h>
19#include <linux/ptrace.h>19#include <linux/ptrace.h>
20#include <linux/module.h>
21#include <linux/highmem.h>20#include <linux/highmem.h>
22#include <linux/hardirq.h>21#include <linux/hardirq.h>
23#include <linux/delay.h>22#include <linux/delay.h>