History

Merge tag 'modules-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux

Pull module updates from Jessica Yu: "Summary of modules changes for the 5.6 merge window: - Add "MS" (SHF_MERGE|SHF_STRINGS) section flags to __ksymtab_strings to indicate to the linker that it can perform string deduplication (i.e., duplicate strings are reduced to a single copy in the string table). This means any repeated namespace string would be merged to just one entry in __ksymtab_strings. - Various code cleanups and small fixes (fix small memleak in error path, improve moduleparam docs, silence rcu warnings, improve error logging)" * tag 'modules-for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux: module.h: Annotate mod_kallsyms with __rcu module: avoid setting info->name early in case we can fall back to info->mod->name modsign: print module name along with error message kernel/module: Fix memleak in module_add_modinfo_attrs() export.h: reduce __ksymtab_strings string duplication by using "MS" section flags moduleparam: fix kerneldoc modules: lockdep: Suppress suspicious RCU usage warning

Linus Torvalds committed 6 years ago

Commit ddaefe82 parents c5951e7 6080d605 files · +119 −28Browse files

Showing the changes to include/linux (3 of 5 files). Show all

Unified · Split

3 files
  1. include/linux/export.h +23 −10
  2. include/linux/module.h +1 −1
  3. include/linux/moduleparam.h +77 −5
include/linux/export.h+23−10
@@ -82,16 +82,29 @@ struct kernel_symbol { · 81 unmodified lines
8282
8383 #else
8484
85−/* For every exported symbol, place a struct in the __ksymtab section */
86−#define ___EXPORT_SYMBOL(sym, sec, ns) \
87− extern typeof(sym) sym; \
88− __CRC_SYMBOL(sym, sec); \
89− static const char __kstrtab_##sym[] \
90− __attribute__((section("__ksymtab_strings"), used, aligned(1))) \
91− = #sym; \
92− static const char __kstrtabns_##sym[] \
93− __attribute__((section("__ksymtab_strings"), used, aligned(1))) \
94− = ns; \
85+/*
86+ * For every exported symbol, do the following:
87+ *
88+ * - If applicable, place a CRC entry in the __kcrctab section.
89+ * - Put the name of the symbol and namespace (empty string "" for none) in
90+ * __ksymtab_strings.
91+ * - Place a struct kernel_symbol entry in the __ksymtab section.
92+ *
93+ * note on .section use: we specify progbits since usage of the "M" (SHF_MERGE)
94+ * section flag requires it. Use '%progbits' instead of '@progbits' since the
95+ * former apparently works on all arches according to the binutils source.
96+ */
97+#define ___EXPORT_SYMBOL(sym, sec, ns) \
98+ extern typeof(sym) sym; \
99+ extern const char __kstrtab_##sym[]; \
100+ extern const char __kstrtabns_##sym[]; \
101+ __CRC_SYMBOL(sym, sec); \
102+ asm(" .section \"__ksymtab_strings\",\"aMS\",%progbits,1 \n" \
103+ "__kstrtab_" #sym ": \n" \
104+ " .asciz \"" #sym "\" \n" \
105+ "__kstrtabns_" #sym ": \n" \
106+ " .asciz \"" ns "\" \n" \
107+ " .previous \n"); \
95108 __KSYMTAB_ENTRY(sym, sec)
96109
97110 #endif
include/linux/module.h+1−1
@@ -429,7 +429,7 @@ struct module { · 428 unmodified lines
429429
430430 #ifdef CONFIG_KALLSYMS
431431 /* Protected by RCU and/or module_mutex: use rcu_dereference() */
432− struct mod_kallsyms *kallsyms;
432+ struct mod_kallsyms __rcu *kallsyms;
433433 struct mod_kallsyms core_kallsyms;
434434
435435 /* Section attributes */
include/linux/moduleparam.h+77−5
@@ -128,6 +128,9 @@ struct kparam_array · 127 unmodified lines
128128
129129 /**
130130 * module_param_unsafe - same as module_param but taints kernel
131+ * @name: the variable to alter, and exposed parameter name.
132+ * @type: the type of the parameter
133+ * @perm: visibility in sysfs.
131134 */
132135 #define module_param_unsafe(name, type, perm) \
133136 module_param_named_unsafe(name, name, type, perm)
@@ -150,6 +153,10 @@ struct kparam_array · 16 unmodified lines
150153
151154 /**
152155 * module_param_named_unsafe - same as module_param_named but taints kernel
156+ * @name: a valid C identifier which is the parameter name.
157+ * @value: the actual lvalue to alter.
158+ * @type: the type of the parameter
159+ * @perm: visibility in sysfs.
153160 */
154161 #define module_param_named_unsafe(name, value, type, perm) \
155162 param_check_##type(name, &(value)); \
@@ -160,6 +167,7 @@ struct kparam_array · 4 unmodified lines
160167 * module_param_cb - general callback for a module/cmdline parameter
161168 * @name: a valid C identifier which is the parameter name.
162169 * @ops: the set & get operations for this parameter.
170+ * @arg: args for @ops
163171 * @perm: visibility in sysfs.
164172 *
165173 * The ops can have NULL set or get functions.
@@ -171,36 +179,96 @@ struct kparam_array · 5 unmodified lines
171179 __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \
172180 KERNEL_PARAM_FL_UNSAFE)
173181
182+#define __level_param_cb(name, ops, arg, perm, level) \
183+ __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0)
174184 /**
175− * <level>_param_cb - general callback for a module/cmdline parameter
176− * to be evaluated before certain initcall level
185+ * core_param_cb - general callback for a module/cmdline parameter
186+ * to be evaluated before core initcall level
177187 * @name: a valid C identifier which is the parameter name.
178188 * @ops: the set & get operations for this parameter.
189+ * @arg: args for @ops
179190 * @perm: visibility in sysfs.
180191 *
181192 * The ops can have NULL set or get functions.
182193 */
183−#define __level_param_cb(name, ops, arg, perm, level) \
184− __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, level, 0)
185−
186194 #define core_param_cb(name, ops, arg, perm) \
187195 __level_param_cb(name, ops, arg, perm, 1)
188196
197+/**
198+ * postcore_param_cb - general callback for a module/cmdline parameter
199+ * to be evaluated before postcore initcall level
200+ * @name: a valid C identifier which is the parameter name.
201+ * @ops: the set & get operations for this parameter.
202+ * @arg: args for @ops
203+ * @perm: visibility in sysfs.
204+ *
205+ * The ops can have NULL set or get functions.
206+ */
189207 #define postcore_param_cb(name, ops, arg, perm) \
190208 __level_param_cb(name, ops, arg, perm, 2)
191209
210+/**
211+ * arch_param_cb - general callback for a module/cmdline parameter
212+ * to be evaluated before arch initcall level
213+ * @name: a valid C identifier which is the parameter name.
214+ * @ops: the set & get operations for this parameter.
215+ * @arg: args for @ops
216+ * @perm: visibility in sysfs.
217+ *
218+ * The ops can have NULL set or get functions.
219+ */
192220 #define arch_param_cb(name, ops, arg, perm) \
193221 __level_param_cb(name, ops, arg, perm, 3)
194222
223+/**
224+ * subsys_param_cb - general callback for a module/cmdline parameter
225+ * to be evaluated before subsys initcall level
226+ * @name: a valid C identifier which is the parameter name.
227+ * @ops: the set & get operations for this parameter.
228+ * @arg: args for @ops
229+ * @perm: visibility in sysfs.
230+ *
231+ * The ops can have NULL set or get functions.
232+ */
195233 #define subsys_param_cb(name, ops, arg, perm) \
196234 __level_param_cb(name, ops, arg, perm, 4)
197235
236+/**
237+ * fs_param_cb - general callback for a module/cmdline parameter
238+ * to be evaluated before fs initcall level
239+ * @name: a valid C identifier which is the parameter name.
240+ * @ops: the set & get operations for this parameter.
241+ * @arg: args for @ops
242+ * @perm: visibility in sysfs.
243+ *
244+ * The ops can have NULL set or get functions.
245+ */
198246 #define fs_param_cb(name, ops, arg, perm) \
199247 __level_param_cb(name, ops, arg, perm, 5)
200248
249+/**
250+ * device_param_cb - general callback for a module/cmdline parameter
251+ * to be evaluated before device initcall level
252+ * @name: a valid C identifier which is the parameter name.
253+ * @ops: the set & get operations for this parameter.
254+ * @arg: args for @ops
255+ * @perm: visibility in sysfs.
256+ *
257+ * The ops can have NULL set or get functions.
258+ */
201259 #define device_param_cb(name, ops, arg, perm) \
202260 __level_param_cb(name, ops, arg, perm, 6)
203261
262+/**
263+ * late_param_cb - general callback for a module/cmdline parameter
264+ * to be evaluated before late initcall level
265+ * @name: a valid C identifier which is the parameter name.
266+ * @ops: the set & get operations for this parameter.
267+ * @arg: args for @ops
268+ * @perm: visibility in sysfs.
269+ *
270+ * The ops can have NULL set or get functions.
271+ */
204272 #define late_param_cb(name, ops, arg, perm) \
205273 __level_param_cb(name, ops, arg, perm, 7)
206274
@@ -263,6 +331,10 @@ static inline void kernel_param_unlock(struct module *mod) · 56 unmodified lines
263331
264332 /**
265333 * core_param_unsafe - same as core_param but taints kernel
334+ * @name: the name of the cmdline and sysfs parameter (often the same as var)
335+ * @var: the variable
336+ * @type: the type of the parameter
337+ * @perm: visibility in sysfs
266338 */
267339 #define core_param_unsafe(name, var, type, perm) \
268340 param_check_##type(name, &(var)); \