Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull module updates from Luis Chamberlain:
"For the 6.0 merge window the modules code shifts to cleanup and minor
fixes effort. This becomes much easier to do and review now due to the
code split to its own directory from effort on the last kernel
release. I expect to see more of this with time and as we expand on
test coverage in the future. The cleanups and fixes come from usual
suspects such as Christophe Leroy and Aaron Tomlin but there are also
some other contributors.

One particular minor fix worth mentioning is from Helge Deller, where
he spotted a *forever* incorrect natural alignment on both ELF section
header tables:

* .altinstructions
* __bug_table sections

A lot of back and forth went on in trying to determine the ill effects
of this misalignment being present for years and it has been
determined there should be no real ill effects unless you have a buggy
exception handler. Helge actually hit one of these buggy exception
handlers on parisc which is how he ended up spotting this issue. When
implemented correctly these paths with incorrect misalignment would
just mean a performance penalty, but given that we are dealing with
alternatives on modules and with the __bug_table (where info regardign
BUG()/WARN() file/line information associated with it is stored) this
really shouldn't be a big deal.

The only other change with mentioning is the kmap() with
kmap_local_page() and my only concern with that was on what is done
after preemption, but the virtual addresses are restored after
preemption. This is only used on module decompression.

This all has sit on linux-next for a while except the kmap stuff which
has been there for 3 weeks"

* tag 'modules-6.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux:
module: Replace kmap() with kmap_local_page()
module: Show the last unloaded module's taint flag(s)
module: Use strscpy() for last_unloaded_module
module: Modify module_flags() to accept show_state argument
module: Move module's Kconfig items in kernel/module/
MAINTAINERS: Update file list for module maintainers
module: Use vzalloc() instead of vmalloc()/memset(0)
modules: Ensure natural alignment for .altinstructions and __bug_table sections
module: Increase readability of module_kallsyms_lookup_name()
module: Fix ERRORs reported by checkpatch.pl
module: Add support for default value for module async_probe

+375 -327
+15 -2
Documentation/admin-guide/kernel-parameters.txt
··· 1158 1158 nopku [X86] Disable Memory Protection Keys CPU feature found 1159 1159 in some Intel CPUs. 1160 1160 1161 - <module>.async_probe [KNL] 1162 - Enable asynchronous probe on this module. 1161 + <module>.async_probe[=<bool>] [KNL] 1162 + If no <bool> value is specified or if the value 1163 + specified is not a valid <bool>, enable asynchronous 1164 + probe on this module. Otherwise, enable/disable 1165 + asynchronous probe on this module as indicated by the 1166 + <bool> value. See also: module.async_probe 1163 1167 1164 1168 early_ioremap_debug [KNL] 1165 1169 Enable debug messages in early_ioremap support. This ··· 3280 3276 3281 3277 For details see: 3282 3278 Documentation/admin-guide/hw-vuln/processor_mmio_stale_data.rst 3279 + 3280 + module.async_probe=<bool> 3281 + [KNL] When set to true, modules will use async probing 3282 + by default. To enable/disable async probing for a 3283 + specific module, use the module specific control that 3284 + is documented under <module>.async_probe. When both 3285 + module.async_probe and <module>.async_probe are 3286 + specified, <module>.async_probe takes precedence for 3287 + the specific module. 3283 3288 3284 3289 module.sig_enforce 3285 3290 [KNL] When CONFIG_MODULE_SIG is set, this means that
+1
MAINTAINERS
··· 13745 13745 T: git git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git modules-next 13746 13746 F: include/linux/module.h 13747 13747 F: kernel/module/ 13748 + F: scripts/module* 13748 13749 13749 13750 MONOLITHIC POWER SYSTEM PMIC DRIVER 13750 13751 M: Saravanan Sekar <sravanhome@gmail.com>
+1 -292
init/Kconfig
··· 1933 1933 def_bool n 1934 1934 select SYSTEM_DATA_VERIFICATION 1935 1935 1936 - menuconfig MODULES 1937 - bool "Enable loadable module support" 1938 - modules 1939 - help 1940 - Kernel modules are small pieces of compiled code which can 1941 - be inserted in the running kernel, rather than being 1942 - permanently built into the kernel. You use the "modprobe" 1943 - tool to add (and sometimes remove) them. If you say Y here, 1944 - many parts of the kernel can be built as modules (by 1945 - answering M instead of Y where indicated): this is most 1946 - useful for infrequently used options which are not required 1947 - for booting. For more information, see the man pages for 1948 - modprobe, lsmod, modinfo, insmod and rmmod. 1949 - 1950 - If you say Y here, you will need to run "make 1951 - modules_install" to put the modules under /lib/modules/ 1952 - where modprobe can find them (you may need to be root to do 1953 - this). 1954 - 1955 - If unsure, say Y. 1956 - 1957 - if MODULES 1958 - 1959 - config MODULE_FORCE_LOAD 1960 - bool "Forced module loading" 1961 - default n 1962 - help 1963 - Allow loading of modules without version information (ie. modprobe 1964 - --force). Forced module loading sets the 'F' (forced) taint flag and 1965 - is usually a really bad idea. 1966 - 1967 - config MODULE_UNLOAD 1968 - bool "Module unloading" 1969 - help 1970 - Without this option you will not be able to unload any 1971 - modules (note that some modules may not be unloadable 1972 - anyway), which makes your kernel smaller, faster 1973 - and simpler. If unsure, say Y. 1974 - 1975 - config MODULE_FORCE_UNLOAD 1976 - bool "Forced module unloading" 1977 - depends on MODULE_UNLOAD 1978 - help 1979 - This option allows you to force a module to unload, even if the 1980 - kernel believes it is unsafe: the kernel will remove the module 1981 - without waiting for anyone to stop using it (using the -f option to 1982 - rmmod). This is mainly for kernel developers and desperate users. 1983 - If unsure, say N. 1984 - 1985 - config MODULE_UNLOAD_TAINT_TRACKING 1986 - bool "Tainted module unload tracking" 1987 - depends on MODULE_UNLOAD 1988 - default n 1989 - help 1990 - This option allows you to maintain a record of each unloaded 1991 - module that tainted the kernel. In addition to displaying a 1992 - list of linked (or loaded) modules e.g. on detection of a bad 1993 - page (see bad_page()), the aforementioned details are also 1994 - shown. If unsure, say N. 1995 - 1996 - config MODVERSIONS 1997 - bool "Module versioning support" 1998 - help 1999 - Usually, you have to use modules compiled with your kernel. 2000 - Saying Y here makes it sometimes possible to use modules 2001 - compiled for different kernels, by adding enough information 2002 - to the modules to (hopefully) spot any changes which would 2003 - make them incompatible with the kernel you are running. If 2004 - unsure, say N. 2005 - 2006 - config ASM_MODVERSIONS 2007 - bool 2008 - default HAVE_ASM_MODVERSIONS && MODVERSIONS 2009 - help 2010 - This enables module versioning for exported symbols also from 2011 - assembly. This can be enabled only when the target architecture 2012 - supports it. 2013 - 2014 - config MODULE_SRCVERSION_ALL 2015 - bool "Source checksum for all modules" 2016 - help 2017 - Modules which contain a MODULE_VERSION get an extra "srcversion" 2018 - field inserted into their modinfo section, which contains a 2019 - sum of the source files which made it. This helps maintainers 2020 - see exactly which source was used to build a module (since 2021 - others sometimes change the module source without updating 2022 - the version). With this option, such a "srcversion" field 2023 - will be created for all modules. If unsure, say N. 2024 - 2025 - config MODULE_SIG 2026 - bool "Module signature verification" 2027 - select MODULE_SIG_FORMAT 2028 - help 2029 - Check modules for valid signatures upon load: the signature 2030 - is simply appended to the module. For more information see 2031 - <file:Documentation/admin-guide/module-signing.rst>. 2032 - 2033 - Note that this option adds the OpenSSL development packages as a 2034 - kernel build dependency so that the signing tool can use its crypto 2035 - library. 2036 - 2037 - You should enable this option if you wish to use either 2038 - CONFIG_SECURITY_LOCKDOWN_LSM or lockdown functionality imposed via 2039 - another LSM - otherwise unsigned modules will be loadable regardless 2040 - of the lockdown policy. 2041 - 2042 - !!!WARNING!!! If you enable this option, you MUST make sure that the 2043 - module DOES NOT get stripped after being signed. This includes the 2044 - debuginfo strip done by some packagers (such as rpmbuild) and 2045 - inclusion into an initramfs that wants the module size reduced. 2046 - 2047 - config MODULE_SIG_FORCE 2048 - bool "Require modules to be validly signed" 2049 - depends on MODULE_SIG 2050 - help 2051 - Reject unsigned modules or signed modules for which we don't have a 2052 - key. Without this, such modules will simply taint the kernel. 2053 - 2054 - config MODULE_SIG_ALL 2055 - bool "Automatically sign all modules" 2056 - default y 2057 - depends on MODULE_SIG || IMA_APPRAISE_MODSIG 2058 - help 2059 - Sign all modules during make modules_install. Without this option, 2060 - modules must be signed manually, using the scripts/sign-file tool. 2061 - 2062 - comment "Do not forget to sign required modules with scripts/sign-file" 2063 - depends on MODULE_SIG_FORCE && !MODULE_SIG_ALL 2064 - 2065 - choice 2066 - prompt "Which hash algorithm should modules be signed with?" 2067 - depends on MODULE_SIG || IMA_APPRAISE_MODSIG 2068 - help 2069 - This determines which sort of hashing algorithm will be used during 2070 - signature generation. This algorithm _must_ be built into the kernel 2071 - directly so that signature verification can take place. It is not 2072 - possible to load a signed module containing the algorithm to check 2073 - the signature on that module. 2074 - 2075 - config MODULE_SIG_SHA1 2076 - bool "Sign modules with SHA-1" 2077 - select CRYPTO_SHA1 2078 - 2079 - config MODULE_SIG_SHA224 2080 - bool "Sign modules with SHA-224" 2081 - select CRYPTO_SHA256 2082 - 2083 - config MODULE_SIG_SHA256 2084 - bool "Sign modules with SHA-256" 2085 - select CRYPTO_SHA256 2086 - 2087 - config MODULE_SIG_SHA384 2088 - bool "Sign modules with SHA-384" 2089 - select CRYPTO_SHA512 2090 - 2091 - config MODULE_SIG_SHA512 2092 - bool "Sign modules with SHA-512" 2093 - select CRYPTO_SHA512 2094 - 2095 - endchoice 2096 - 2097 - config MODULE_SIG_HASH 2098 - string 2099 - depends on MODULE_SIG || IMA_APPRAISE_MODSIG 2100 - default "sha1" if MODULE_SIG_SHA1 2101 - default "sha224" if MODULE_SIG_SHA224 2102 - default "sha256" if MODULE_SIG_SHA256 2103 - default "sha384" if MODULE_SIG_SHA384 2104 - default "sha512" if MODULE_SIG_SHA512 2105 - 2106 - choice 2107 - prompt "Module compression mode" 2108 - help 2109 - This option allows you to choose the algorithm which will be used to 2110 - compress modules when 'make modules_install' is run. (or, you can 2111 - choose to not compress modules at all.) 2112 - 2113 - External modules will also be compressed in the same way during the 2114 - installation. 2115 - 2116 - For modules inside an initrd or initramfs, it's more efficient to 2117 - compress the whole initrd or initramfs instead. 2118 - 2119 - This is fully compatible with signed modules. 2120 - 2121 - Please note that the tool used to load modules needs to support the 2122 - corresponding algorithm. module-init-tools MAY support gzip, and kmod 2123 - MAY support gzip, xz and zstd. 2124 - 2125 - Your build system needs to provide the appropriate compression tool 2126 - to compress the modules. 2127 - 2128 - If in doubt, select 'None'. 2129 - 2130 - config MODULE_COMPRESS_NONE 2131 - bool "None" 2132 - help 2133 - Do not compress modules. The installed modules are suffixed 2134 - with .ko. 2135 - 2136 - config MODULE_COMPRESS_GZIP 2137 - bool "GZIP" 2138 - help 2139 - Compress modules with GZIP. The installed modules are suffixed 2140 - with .ko.gz. 2141 - 2142 - config MODULE_COMPRESS_XZ 2143 - bool "XZ" 2144 - help 2145 - Compress modules with XZ. The installed modules are suffixed 2146 - with .ko.xz. 2147 - 2148 - config MODULE_COMPRESS_ZSTD 2149 - bool "ZSTD" 2150 - help 2151 - Compress modules with ZSTD. The installed modules are suffixed 2152 - with .ko.zst. 2153 - 2154 - endchoice 2155 - 2156 - config MODULE_DECOMPRESS 2157 - bool "Support in-kernel module decompression" 2158 - depends on MODULE_COMPRESS_GZIP || MODULE_COMPRESS_XZ 2159 - select ZLIB_INFLATE if MODULE_COMPRESS_GZIP 2160 - select XZ_DEC if MODULE_COMPRESS_XZ 2161 - help 2162 - 2163 - Support for decompressing kernel modules by the kernel itself 2164 - instead of relying on userspace to perform this task. Useful when 2165 - load pinning security policy is enabled. 2166 - 2167 - If unsure, say N. 2168 - 2169 - config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS 2170 - bool "Allow loading of modules with missing namespace imports" 2171 - help 2172 - Symbols exported with EXPORT_SYMBOL_NS*() are considered exported in 2173 - a namespace. A module that makes use of a symbol exported with such a 2174 - namespace is required to import the namespace via MODULE_IMPORT_NS(). 2175 - There is no technical reason to enforce correct namespace imports, 2176 - but it creates consistency between symbols defining namespaces and 2177 - users importing namespaces they make use of. This option relaxes this 2178 - requirement and lifts the enforcement when loading a module. 2179 - 2180 - If unsure, say N. 2181 - 2182 - config MODPROBE_PATH 2183 - string "Path to modprobe binary" 2184 - default "/sbin/modprobe" 2185 - help 2186 - When kernel code requests a module, it does so by calling 2187 - the "modprobe" userspace utility. This option allows you to 2188 - set the path where that binary is found. This can be changed 2189 - at runtime via the sysctl file 2190 - /proc/sys/kernel/modprobe. Setting this to the empty string 2191 - removes the kernel's ability to request modules (but 2192 - userspace can still load modules explicitly). 2193 - 2194 - config TRIM_UNUSED_KSYMS 2195 - bool "Trim unused exported kernel symbols" if EXPERT 2196 - depends on !COMPILE_TEST 2197 - help 2198 - The kernel and some modules make many symbols available for 2199 - other modules to use via EXPORT_SYMBOL() and variants. Depending 2200 - on the set of modules being selected in your kernel configuration, 2201 - many of those exported symbols might never be used. 2202 - 2203 - This option allows for unused exported symbols to be dropped from 2204 - the build. In turn, this provides the compiler more opportunities 2205 - (especially when using LTO) for optimizing the code and reducing 2206 - binary size. This might have some security advantages as well. 2207 - 2208 - If unsure, or if you need to build out-of-tree modules, say N. 2209 - 2210 - config UNUSED_KSYMS_WHITELIST 2211 - string "Whitelist of symbols to keep in ksymtab" 2212 - depends on TRIM_UNUSED_KSYMS 2213 - help 2214 - By default, all unused exported symbols will be un-exported from the 2215 - build when TRIM_UNUSED_KSYMS is selected. 2216 - 2217 - UNUSED_KSYMS_WHITELIST allows to whitelist symbols that must be kept 2218 - exported at all times, even in absence of in-tree users. The value to 2219 - set here is the path to a text file containing the list of symbols, 2220 - one per line. The path can be absolute, or relative to the kernel 2221 - source tree. 2222 - 2223 - endif # MODULES 2224 - 2225 - config MODULES_TREE_LOOKUP 2226 - def_bool y 2227 - depends on PERF_EVENTS || TRACING || CFI_CLANG 1936 + source "kernel/module/Kconfig" 2228 1937 2229 1938 config INIT_ALL_POSSIBLE 2230 1939 bool
+293
kernel/module/Kconfig
··· 1 + # SPDX-License-Identifier: GPL-2.0-only 2 + menuconfig MODULES 3 + bool "Enable loadable module support" 4 + modules 5 + help 6 + Kernel modules are small pieces of compiled code which can 7 + be inserted in the running kernel, rather than being 8 + permanently built into the kernel. You use the "modprobe" 9 + tool to add (and sometimes remove) them. If you say Y here, 10 + many parts of the kernel can be built as modules (by 11 + answering M instead of Y where indicated): this is most 12 + useful for infrequently used options which are not required 13 + for booting. For more information, see the man pages for 14 + modprobe, lsmod, modinfo, insmod and rmmod. 15 + 16 + If you say Y here, you will need to run "make 17 + modules_install" to put the modules under /lib/modules/ 18 + where modprobe can find them (you may need to be root to do 19 + this). 20 + 21 + If unsure, say Y. 22 + 23 + if MODULES 24 + 25 + config MODULE_FORCE_LOAD 26 + bool "Forced module loading" 27 + default n 28 + help 29 + Allow loading of modules without version information (ie. modprobe 30 + --force). Forced module loading sets the 'F' (forced) taint flag and 31 + is usually a really bad idea. 32 + 33 + config MODULE_UNLOAD 34 + bool "Module unloading" 35 + help 36 + Without this option you will not be able to unload any 37 + modules (note that some modules may not be unloadable 38 + anyway), which makes your kernel smaller, faster 39 + and simpler. If unsure, say Y. 40 + 41 + config MODULE_FORCE_UNLOAD 42 + bool "Forced module unloading" 43 + depends on MODULE_UNLOAD 44 + help 45 + This option allows you to force a module to unload, even if the 46 + kernel believes it is unsafe: the kernel will remove the module 47 + without waiting for anyone to stop using it (using the -f option to 48 + rmmod). This is mainly for kernel developers and desperate users. 49 + If unsure, say N. 50 + 51 + config MODULE_UNLOAD_TAINT_TRACKING 52 + bool "Tainted module unload tracking" 53 + depends on MODULE_UNLOAD 54 + default n 55 + help 56 + This option allows you to maintain a record of each unloaded 57 + module that tainted the kernel. In addition to displaying a 58 + list of linked (or loaded) modules e.g. on detection of a bad 59 + page (see bad_page()), the aforementioned details are also 60 + shown. If unsure, say N. 61 + 62 + config MODVERSIONS 63 + bool "Module versioning support" 64 + help 65 + Usually, you have to use modules compiled with your kernel. 66 + Saying Y here makes it sometimes possible to use modules 67 + compiled for different kernels, by adding enough information 68 + to the modules to (hopefully) spot any changes which would 69 + make them incompatible with the kernel you are running. If 70 + unsure, say N. 71 + 72 + config ASM_MODVERSIONS 73 + bool 74 + default HAVE_ASM_MODVERSIONS && MODVERSIONS 75 + help 76 + This enables module versioning for exported symbols also from 77 + assembly. This can be enabled only when the target architecture 78 + supports it. 79 + 80 + config MODULE_SRCVERSION_ALL 81 + bool "Source checksum for all modules" 82 + help 83 + Modules which contain a MODULE_VERSION get an extra "srcversion" 84 + field inserted into their modinfo section, which contains a 85 + sum of the source files which made it. This helps maintainers 86 + see exactly which source was used to build a module (since 87 + others sometimes change the module source without updating 88 + the version). With this option, such a "srcversion" field 89 + will be created for all modules. If unsure, say N. 90 + 91 + config MODULE_SIG 92 + bool "Module signature verification" 93 + select MODULE_SIG_FORMAT 94 + help 95 + Check modules for valid signatures upon load: the signature 96 + is simply appended to the module. For more information see 97 + <file:Documentation/admin-guide/module-signing.rst>. 98 + 99 + Note that this option adds the OpenSSL development packages as a 100 + kernel build dependency so that the signing tool can use its crypto 101 + library. 102 + 103 + You should enable this option if you wish to use either 104 + CONFIG_SECURITY_LOCKDOWN_LSM or lockdown functionality imposed via 105 + another LSM - otherwise unsigned modules will be loadable regardless 106 + of the lockdown policy. 107 + 108 + !!!WARNING!!! If you enable this option, you MUST make sure that the 109 + module DOES NOT get stripped after being signed. This includes the 110 + debuginfo strip done by some packagers (such as rpmbuild) and 111 + inclusion into an initramfs that wants the module size reduced. 112 + 113 + config MODULE_SIG_FORCE 114 + bool "Require modules to be validly signed" 115 + depends on MODULE_SIG 116 + help 117 + Reject unsigned modules or signed modules for which we don't have a 118 + key. Without this, such modules will simply taint the kernel. 119 + 120 + config MODULE_SIG_ALL 121 + bool "Automatically sign all modules" 122 + default y 123 + depends on MODULE_SIG || IMA_APPRAISE_MODSIG 124 + help 125 + Sign all modules during make modules_install. Without this option, 126 + modules must be signed manually, using the scripts/sign-file tool. 127 + 128 + comment "Do not forget to sign required modules with scripts/sign-file" 129 + depends on MODULE_SIG_FORCE && !MODULE_SIG_ALL 130 + 131 + choice 132 + prompt "Which hash algorithm should modules be signed with?" 133 + depends on MODULE_SIG || IMA_APPRAISE_MODSIG 134 + help 135 + This determines which sort of hashing algorithm will be used during 136 + signature generation. This algorithm _must_ be built into the kernel 137 + directly so that signature verification can take place. It is not 138 + possible to load a signed module containing the algorithm to check 139 + the signature on that module. 140 + 141 + config MODULE_SIG_SHA1 142 + bool "Sign modules with SHA-1" 143 + select CRYPTO_SHA1 144 + 145 + config MODULE_SIG_SHA224 146 + bool "Sign modules with SHA-224" 147 + select CRYPTO_SHA256 148 + 149 + config MODULE_SIG_SHA256 150 + bool "Sign modules with SHA-256" 151 + select CRYPTO_SHA256 152 + 153 + config MODULE_SIG_SHA384 154 + bool "Sign modules with SHA-384" 155 + select CRYPTO_SHA512 156 + 157 + config MODULE_SIG_SHA512 158 + bool "Sign modules with SHA-512" 159 + select CRYPTO_SHA512 160 + 161 + endchoice 162 + 163 + config MODULE_SIG_HASH 164 + string 165 + depends on MODULE_SIG || IMA_APPRAISE_MODSIG 166 + default "sha1" if MODULE_SIG_SHA1 167 + default "sha224" if MODULE_SIG_SHA224 168 + default "sha256" if MODULE_SIG_SHA256 169 + default "sha384" if MODULE_SIG_SHA384 170 + default "sha512" if MODULE_SIG_SHA512 171 + 172 + choice 173 + prompt "Module compression mode" 174 + help 175 + This option allows you to choose the algorithm which will be used to 176 + compress modules when 'make modules_install' is run. (or, you can 177 + choose to not compress modules at all.) 178 + 179 + External modules will also be compressed in the same way during the 180 + installation. 181 + 182 + For modules inside an initrd or initramfs, it's more efficient to 183 + compress the whole initrd or initramfs instead. 184 + 185 + This is fully compatible with signed modules. 186 + 187 + Please note that the tool used to load modules needs to support the 188 + corresponding algorithm. module-init-tools MAY support gzip, and kmod 189 + MAY support gzip, xz and zstd. 190 + 191 + Your build system needs to provide the appropriate compression tool 192 + to compress the modules. 193 + 194 + If in doubt, select 'None'. 195 + 196 + config MODULE_COMPRESS_NONE 197 + bool "None" 198 + help 199 + Do not compress modules. The installed modules are suffixed 200 + with .ko. 201 + 202 + config MODULE_COMPRESS_GZIP 203 + bool "GZIP" 204 + help 205 + Compress modules with GZIP. The installed modules are suffixed 206 + with .ko.gz. 207 + 208 + config MODULE_COMPRESS_XZ 209 + bool "XZ" 210 + help 211 + Compress modules with XZ. The installed modules are suffixed 212 + with .ko.xz. 213 + 214 + config MODULE_COMPRESS_ZSTD 215 + bool "ZSTD" 216 + help 217 + Compress modules with ZSTD. The installed modules are suffixed 218 + with .ko.zst. 219 + 220 + endchoice 221 + 222 + config MODULE_DECOMPRESS 223 + bool "Support in-kernel module decompression" 224 + depends on MODULE_COMPRESS_GZIP || MODULE_COMPRESS_XZ 225 + select ZLIB_INFLATE if MODULE_COMPRESS_GZIP 226 + select XZ_DEC if MODULE_COMPRESS_XZ 227 + help 228 + 229 + Support for decompressing kernel modules by the kernel itself 230 + instead of relying on userspace to perform this task. Useful when 231 + load pinning security policy is enabled. 232 + 233 + If unsure, say N. 234 + 235 + config MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS 236 + bool "Allow loading of modules with missing namespace imports" 237 + help 238 + Symbols exported with EXPORT_SYMBOL_NS*() are considered exported in 239 + a namespace. A module that makes use of a symbol exported with such a 240 + namespace is required to import the namespace via MODULE_IMPORT_NS(). 241 + There is no technical reason to enforce correct namespace imports, 242 + but it creates consistency between symbols defining namespaces and 243 + users importing namespaces they make use of. This option relaxes this 244 + requirement and lifts the enforcement when loading a module. 245 + 246 + If unsure, say N. 247 + 248 + config MODPROBE_PATH 249 + string "Path to modprobe binary" 250 + default "/sbin/modprobe" 251 + help 252 + When kernel code requests a module, it does so by calling 253 + the "modprobe" userspace utility. This option allows you to 254 + set the path where that binary is found. This can be changed 255 + at runtime via the sysctl file 256 + /proc/sys/kernel/modprobe. Setting this to the empty string 257 + removes the kernel's ability to request modules (but 258 + userspace can still load modules explicitly). 259 + 260 + config TRIM_UNUSED_KSYMS 261 + bool "Trim unused exported kernel symbols" if EXPERT 262 + depends on !COMPILE_TEST 263 + help 264 + The kernel and some modules make many symbols available for 265 + other modules to use via EXPORT_SYMBOL() and variants. Depending 266 + on the set of modules being selected in your kernel configuration, 267 + many of those exported symbols might never be used. 268 + 269 + This option allows for unused exported symbols to be dropped from 270 + the build. In turn, this provides the compiler more opportunities 271 + (especially when using LTO) for optimizing the code and reducing 272 + binary size. This might have some security advantages as well. 273 + 274 + If unsure, or if you need to build out-of-tree modules, say N. 275 + 276 + config UNUSED_KSYMS_WHITELIST 277 + string "Whitelist of symbols to keep in ksymtab" 278 + depends on TRIM_UNUSED_KSYMS 279 + help 280 + By default, all unused exported symbols will be un-exported from the 281 + build when TRIM_UNUSED_KSYMS is selected. 282 + 283 + UNUSED_KSYMS_WHITELIST allows to whitelist symbols that must be kept 284 + exported at all times, even in absence of in-tree users. The value to 285 + set here is the path to a text file containing the list of symbols, 286 + one per line. The path can be absolute, or relative to the kernel 287 + source tree. 288 + 289 + config MODULES_TREE_LOOKUP 290 + def_bool y 291 + depends on PERF_EVENTS || TRACING || CFI_CLANG 292 + 293 + endif # MODULES
+4 -4
kernel/module/decompress.c
··· 119 119 goto out_inflate_end; 120 120 } 121 121 122 - s.next_out = kmap(page); 122 + s.next_out = kmap_local_page(page); 123 123 s.avail_out = PAGE_SIZE; 124 124 rc = zlib_inflate(&s, 0); 125 - kunmap(page); 125 + kunmap_local(s.next_out); 126 126 127 127 new_size += PAGE_SIZE - s.avail_out; 128 128 } while (rc == Z_OK); ··· 178 178 goto out; 179 179 } 180 180 181 - xz_buf.out = kmap(page); 181 + xz_buf.out = kmap_local_page(page); 182 182 xz_buf.out_pos = 0; 183 183 xz_buf.out_size = PAGE_SIZE; 184 184 xz_ret = xz_dec_run(xz_dec, &xz_buf); 185 - kunmap(page); 185 + kunmap_local(xz_buf.out); 186 186 187 187 new_size += xz_buf.out_pos; 188 188 } while (xz_buf.out_pos == PAGE_SIZE && xz_ret == XZ_OK);
+1 -1
kernel/module/internal.h
··· 103 103 int cmp_name(const void *name, const void *sym); 104 104 long module_get_offset(struct module *mod, unsigned int *size, Elf_Shdr *sechdr, 105 105 unsigned int section); 106 - char *module_flags(struct module *mod, char *buf); 106 + char *module_flags(struct module *mod, char *buf, bool show_state); 107 107 size_t module_flags_taint(unsigned long taints, char *buf); 108 108 109 109 static inline void module_assert_mutex_or_preempt(void)
+27 -14
kernel/module/kallsyms.c
··· 457 457 return 0; 458 458 } 459 459 460 - /* Look for this name: can be of form module:name. */ 461 - unsigned long module_kallsyms_lookup_name(const char *name) 460 + static unsigned long __module_kallsyms_lookup_name(const char *name) 462 461 { 463 462 struct module *mod; 464 463 char *colon; 465 - unsigned long ret = 0; 464 + 465 + colon = strnchr(name, MODULE_NAME_LEN, ':'); 466 + if (colon) { 467 + mod = find_module_all(name, colon - name, false); 468 + if (mod) 469 + return find_kallsyms_symbol_value(mod, colon + 1); 470 + return 0; 471 + } 472 + 473 + list_for_each_entry_rcu(mod, &modules, list) { 474 + unsigned long ret; 475 + 476 + if (mod->state == MODULE_STATE_UNFORMED) 477 + continue; 478 + ret = find_kallsyms_symbol_value(mod, name); 479 + if (ret) 480 + return ret; 481 + } 482 + return 0; 483 + } 484 + 485 + /* Look for this name: can be of form module:name. */ 486 + unsigned long module_kallsyms_lookup_name(const char *name) 487 + { 488 + unsigned long ret; 466 489 467 490 /* Don't lock: we're in enough trouble already. */ 468 491 preempt_disable(); 469 - if ((colon = strnchr(name, MODULE_NAME_LEN, ':')) != NULL) { 470 - if ((mod = find_module_all(name, colon - name, false)) != NULL) 471 - ret = find_kallsyms_symbol_value(mod, colon + 1); 472 - } else { 473 - list_for_each_entry_rcu(mod, &modules, list) { 474 - if (mod->state == MODULE_STATE_UNFORMED) 475 - continue; 476 - if ((ret = find_kallsyms_symbol_value(mod, name)) != 0) 477 - break; 478 - } 479 - } 492 + ret = __module_kallsyms_lookup_name(name); 480 493 preempt_enable(); 481 494 return ret; 482 495 }
+30 -13
kernel/module/main.c
··· 119 119 } 120 120 121 121 /* Block module loading/unloading? */ 122 - int modules_disabled = 0; 122 + int modules_disabled; 123 123 core_param(nomodule, modules_disabled, bint, 0); 124 124 125 125 /* Waiting for a module to finish initializing? */ ··· 524 524 MODINFO_ATTR(version); 525 525 MODINFO_ATTR(srcversion); 526 526 527 - static char last_unloaded_module[MODULE_NAME_LEN+1]; 527 + static struct { 528 + char name[MODULE_NAME_LEN + 1]; 529 + char taints[MODULE_FLAGS_BUF_SIZE]; 530 + } last_unloaded_module; 528 531 529 532 #ifdef CONFIG_MODULE_UNLOAD 530 533 ··· 697 694 { 698 695 struct module *mod; 699 696 char name[MODULE_NAME_LEN]; 697 + char buf[MODULE_FLAGS_BUF_SIZE]; 700 698 int ret, forced = 0; 701 699 702 700 if (!capable(CAP_SYS_MODULE) || modules_disabled) ··· 757 753 758 754 async_synchronize_full(); 759 755 760 - /* Store the name of the last unloaded module for diagnostic purposes */ 761 - strlcpy(last_unloaded_module, mod->name, sizeof(last_unloaded_module)); 756 + /* Store the name and taints of the last unloaded module for diagnostic purposes */ 757 + strscpy(last_unloaded_module.name, mod->name, sizeof(last_unloaded_module.name)); 758 + strscpy(last_unloaded_module.taints, module_flags(mod, buf, false), sizeof(last_unloaded_module.taints)); 762 759 763 760 free_module(mod); 764 761 /* someone could wait for the module in add_unformed_module() */ ··· 2156 2151 2157 2152 #ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC 2158 2153 /* Do the allocs. */ 2159 - ptr = vmalloc(mod->data_layout.size); 2154 + ptr = vzalloc(mod->data_layout.size); 2160 2155 /* 2161 2156 * The pointer to this block is stored in the module structure 2162 2157 * which is inside the block. Just mark it as not being a ··· 2169 2164 return -ENOMEM; 2170 2165 } 2171 2166 2172 - memset(ptr, 0, mod->data_layout.size); 2173 2167 mod->data_layout.base = ptr; 2174 2168 #endif 2175 2169 /* Transfer each section which specifies SHF_ALLOC */ ··· 2427 2423 } 2428 2424 } 2429 2425 2426 + #undef MODULE_PARAM_PREFIX 2427 + #define MODULE_PARAM_PREFIX "module." 2428 + /* Default value for module->async_probe_requested */ 2429 + static bool async_probe; 2430 + module_param(async_probe, bool, 0644); 2431 + 2430 2432 /* 2431 2433 * This is where the real work happens. 2432 2434 * ··· 2653 2643 int ret; 2654 2644 2655 2645 if (strcmp(param, "async_probe") == 0) { 2656 - mod->async_probe_requested = true; 2646 + if (strtobool(val, &mod->async_probe_requested)) 2647 + mod->async_probe_requested = true; 2657 2648 return 0; 2658 2649 } 2659 2650 ··· 2820 2809 err = prepare_coming_module(mod); 2821 2810 if (err) 2822 2811 goto bug_cleanup; 2812 + 2813 + mod->async_probe_requested = async_probe; 2823 2814 2824 2815 /* Module is ready to execute: parsing args may do that. */ 2825 2816 after_dashes = parse_args(mod->name, mod->args, mod->kp, mod->num_kp, ··· 2997 2984 } 2998 2985 2999 2986 /* Keep in sync with MODULE_FLAGS_BUF_SIZE !!! */ 3000 - char *module_flags(struct module *mod, char *buf) 2987 + char *module_flags(struct module *mod, char *buf, bool show_state) 3001 2988 { 3002 2989 int bx = 0; 3003 2990 3004 2991 BUG_ON(mod->state == MODULE_STATE_UNFORMED); 2992 + if (!mod->taints && !show_state) 2993 + goto out; 3005 2994 if (mod->taints || 3006 2995 mod->state == MODULE_STATE_GOING || 3007 2996 mod->state == MODULE_STATE_COMING) { 3008 2997 buf[bx++] = '('; 3009 2998 bx += module_flags_taint(mod->taints, buf + bx); 3010 2999 /* Show a - for module-is-being-unloaded */ 3011 - if (mod->state == MODULE_STATE_GOING) 3000 + if (mod->state == MODULE_STATE_GOING && show_state) 3012 3001 buf[bx++] = '-'; 3013 3002 /* Show a + for module-is-being-loaded */ 3014 - if (mod->state == MODULE_STATE_COMING) 3003 + if (mod->state == MODULE_STATE_COMING && show_state) 3015 3004 buf[bx++] = '+'; 3016 3005 buf[bx++] = ')'; 3017 3006 } 3007 + out: 3018 3008 buf[bx] = '\0'; 3019 3009 3020 3010 return buf; ··· 3150 3134 list_for_each_entry_rcu(mod, &modules, list) { 3151 3135 if (mod->state == MODULE_STATE_UNFORMED) 3152 3136 continue; 3153 - pr_cont(" %s%s", mod->name, module_flags(mod, buf)); 3137 + pr_cont(" %s%s", mod->name, module_flags(mod, buf, true)); 3154 3138 } 3155 3139 3156 3140 print_unloaded_tainted_modules(); 3157 3141 preempt_enable(); 3158 - if (last_unloaded_module[0]) 3159 - pr_cont(" [last unloaded: %s]", last_unloaded_module); 3142 + if (last_unloaded_module.name[0]) 3143 + pr_cont(" [last unloaded: %s%s]", last_unloaded_module.name, 3144 + last_unloaded_module.taints); 3160 3145 pr_cont("\n"); 3161 3146 }
+1 -1
kernel/module/procfs.c
··· 91 91 92 92 /* Taints info */ 93 93 if (mod->taints) 94 - seq_printf(m, " %s", module_flags(mod, buf)); 94 + seq_printf(m, " %s", module_flags(mod, buf, true)); 95 95 96 96 seq_puts(m, "\n"); 97 97 return 0;
+2
scripts/module.lds.S
··· 27 27 .ctors 0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) } 28 28 .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) } 29 29 30 + .altinstructions 0 : ALIGN(8) { KEEP(*(.altinstructions)) } 31 + __bug_table 0 : ALIGN(8) { KEEP(*(__bug_table)) } 30 32 __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) } 31 33 32 34 __patchable_function_entries : { *(__patchable_function_entries) }