Skip to content

Commit 312dcaf

Browse files
committed
Merge tag 'modules-for-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux
Pull modules updates from Jessica Yu: "Summary of modules changes for the 5.11 merge window: - Fix a race condition between systemd/udev and the module loader. The module loader was sending a uevent before the module was fully initialized (i.e., before its init function has been called). This means udev can start processing the module uevent before the module has finished initializing, and some udev rules expect that the module has initialized already upon receiving the uevent. This resulted in some systemd mount units failing if udev processes the event faster than the module can finish init. This is fixed by delaying the uevent until after the module has called its init routine. - Make the linker array sections for kernel params and module version attributes more robust by switching to use the alignment of the type in question. Namely, linker section arrays will be constructed using the alignment required by the struct (using __alignof__()) as opposed to a specific value such as sizeof(void *) or sizeof(long). This is less likely to cause breakages should the size of the type ever change (Johan Hovold) - Fix module state inconsistency by setting it back to GOING when a module fails to load and is on its way out (Miroslav Benes) - Some comment and code cleanups (Sergey Shtylyov)" * tag 'modules-for-v5.11' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux: module: delay kobject uevent until after module init call module: drop semicolon from version macro init: use type alignment for kernel parameters params: clean up module-param macros params: use type alignment for kernel parameters params: drop redundant "unused" attributes module: simplify version-attribute handling module: drop version-attribute alignment module: fix comment style module: add more 'kernel-doc' comments module: fix up 'kernel-doc' comments module: only handle errors with the *switch* statement in module_sig_check() module: avoid *goto*s in module_sig_check() module: merge repetitive strings in module_sig_check() module: set MODULE_STATE_GOING state when a module fails to load
2 parents 6daa904 + 38dc717 commit 312dcaf

5 files changed

Lines changed: 142 additions & 110 deletions

File tree

‎include/linux/init.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ struct obs_kernel_param {
255255
__aligned(1) = str; \
256256
static struct obs_kernel_param __setup_##unique_id \
257257
__used __section(".init.setup") \
258-
__attribute__((aligned((sizeof(long))))) \
258+
__aligned(__alignof__(struct obs_kernel_param)) \
259259
= { __setup_str_##unique_id, fn, early }
260260

261261
#define __setup(str, fn) \

‎include/linux/module.h‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct module_version_attribute {
6666
struct module_attribute mattr;
6767
const char *module_name;
6868
const char *version;
69-
} __attribute__ ((__aligned__(sizeof(void *))));
69+
};
7070

7171
extern ssize_t __modver_version_show(struct module_attribute *,
7272
struct module_kobject *, char *);
@@ -266,20 +266,20 @@ extern typeof(name) __mod_##type##__##name##_device_table \
266266
#else
267267
#define MODULE_VERSION(_version) \
268268
MODULE_INFO(version, _version); \
269-
static struct module_version_attribute ___modver_attr = { \
270-
.mattr = { \
271-
.attr = { \
272-
.name = "version", \
273-
.mode = S_IRUGO, \
269+
static struct module_version_attribute __modver_attr \
270+
__used __section("__modver") \
271+
__aligned(__alignof__(struct module_version_attribute)) \
272+
= { \
273+
.mattr = { \
274+
.attr = { \
275+
.name = "version", \
276+
.mode = S_IRUGO, \
277+
}, \
278+
.show = __modver_version_show, \
274279
}, \
275-
.show = __modver_version_show, \
276-
}, \
277-
.module_name = KBUILD_MODNAME, \
278-
.version = _version, \
279-
}; \
280-
static const struct module_version_attribute \
281-
__used __section("__modver") \
282-
* __moduleparam_const __modver_attr = &___modver_attr
280+
.module_name = KBUILD_MODNAME, \
281+
.version = _version, \
282+
}
283283
#endif
284284

285285
/* Optional firmware file (or files) needed by the module

‎include/linux/moduleparam.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
#define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))
2222

2323
#define __MODULE_INFO(tag, name, info) \
24-
static const char __UNIQUE_ID(name)[] \
25-
__used __section(".modinfo") __attribute__((unused, aligned(1))) \
26-
= __MODULE_INFO_PREFIX __stringify(tag) "=" info
24+
static const char __UNIQUE_ID(name)[] \
25+
__used __section(".modinfo") __aligned(1) \
26+
= __MODULE_INFO_PREFIX __stringify(tag) "=" info
2727

2828
#define __MODULE_PARM_TYPE(name, _type) \
29-
__MODULE_INFO(parmtype, name##type, #name ":" _type)
29+
__MODULE_INFO(parmtype, name##type, #name ":" _type)
3030

3131
/* One for each parameter, describing how to use it. Some files do
3232
multiple of these per line, so can't just use MODULE_INFO. */
@@ -288,8 +288,8 @@ struct kparam_array
288288
/* Default value instead of permissions? */ \
289289
static const char __param_str_##name[] = prefix #name; \
290290
static struct kernel_param __moduleparam_const __param_##name \
291-
__used \
292-
__section("__param") __attribute__ ((unused, aligned(sizeof(void *)))) \
291+
__used __section("__param") \
292+
__aligned(__alignof__(struct kernel_param)) \
293293
= { __param_str_##name, THIS_MODULE, ops, \
294294
VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
295295

0 commit comments

Comments
 (0)