diff --git a/patches.suse/module-delay-kobject-uevent-until-after-module-init-.patch b/patches.suse/module-delay-kobject-uevent-until-after-module-init-.patch new file mode 100644 index 0000000..df154ea --- /dev/null +++ b/patches.suse/module-delay-kobject-uevent-until-after-module-init-.patch @@ -0,0 +1,66 @@ +From 38dc717e97153e46375ee21797aa54777e5498f3 Mon Sep 17 00:00:00 2001 +From: Jessica Yu +Date: Fri, 27 Nov 2020 10:09:39 +0100 +Subject: [PATCH] module: delay kobject uevent until after module init call +Patch-mainline: v5.11-rc1 +Git-commit: 38dc717e97153e46375ee21797aa54777e5498f3 +References: bsc#1178631 + +Apparently there has been a longstanding race between udev/systemd and +the module loader. Currently, the module loader sends a uevent right +after sysfs initialization, but before the module calls its init +function. However, some udev rules expect that the module has +initialized already upon receiving the uevent. + +This race has been triggered recently (see link in references) in some +systemd mount unit files. For instance, the configfs module creates the +/sys/kernel/config mount point in its init function, however the module +loader issues the uevent before this happens. sys-kernel-config.mount +expects to be able to mount /sys/kernel/config upon receipt of the +module loading uevent, but if the configfs module has not called its +init function yet, then this directory will not exist and the mount unit +fails. A similar situation exists for sys-fs-fuse-connections.mount, as +the fuse sysfs mount point is created during the fuse module's init +function. If udev is faster than module initialization then the mount +unit would fail in a similar fashion. + +To fix this race, delay the module KOBJ_ADD uevent until after the +module has finished calling its init routine. + +References: https://github.com/systemd/systemd/issues/17586 +Reviewed-by: Greg Kroah-Hartman +Tested-By: Nicolas Morey-Chaisemartin +Signed-off-by: Jessica Yu +Acked-by: Jessica Yu +--- + kernel/module.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +--- a/kernel/module.c ++++ b/kernel/module.c +@@ -1757,7 +1757,6 @@ static int mod_sysfs_init(struct module + if (err) + mod_kobject_put(mod); + +- /* delay uevent until full sysfs population */ + out: + return err; + } +@@ -1791,7 +1790,6 @@ static int mod_sysfs_setup(struct module + add_sect_attrs(mod, info); + add_notes_attrs(mod, info); + +- kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD); + return 0; + + out_unreg_param: +@@ -3421,6 +3419,9 @@ static noinline int do_init_module(struc + blocking_notifier_call_chain(&module_notify_list, + MODULE_STATE_LIVE, mod); + ++ /* Delay uevent until module has finished its init routine */ ++ kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD); ++ + /* + * We need to finish all async code before the module init sequence + * is done. This has potential to deadlock. For example, a newly diff --git a/patches.suse/supported-flag b/patches.suse/supported-flag index a15c251..9f3d3bb 100644 --- a/patches.suse/supported-flag +++ b/patches.suse/supported-flag @@ -29,7 +29,7 @@ Signed-off-by: Andreas Gruenbacher --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt -@@ -4213,6 +4213,14 @@ +@@ -4651,6 +4651,14 @@ unknown_nmi_panic [X86] Cause panic on unknown NMI. @@ -46,7 +46,7 @@ Signed-off-by: Andreas Gruenbacher (default -1 = authorized except for wireless USB, --- a/Documentation/sysctl/kernel.txt +++ b/Documentation/sysctl/kernel.txt -@@ -963,6 +963,18 @@ can be ORed together: +@@ -974,6 +974,18 @@ can be ORed together: signature. 16384 - A soft lockup has previously occurred on the system. 32768 - The kernel has been live patched. @@ -81,7 +81,7 @@ Signed-off-by: Andreas Gruenbacher KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) --- a/include/linux/kernel.h +++ b/include/linux/kernel.h -@@ -457,6 +457,9 @@ extern int panic_on_unrecovered_nmi; +@@ -461,6 +461,9 @@ extern int panic_on_unrecovered_nmi; extern int panic_on_io_nmi; extern int panic_on_warn; extern int sysctl_panic_on_rcu_stall; @@ -91,7 +91,7 @@ Signed-off-by: Andreas Gruenbacher extern int sysctl_panic_on_stackoverflow; extern bool crash_kexec_post_notifiers; -@@ -515,7 +518,19 @@ extern enum system_states { +@@ -519,7 +522,19 @@ extern enum system_states { #define TAINT_UNSIGNED_MODULE 13 #define TAINT_SOFTLOCKUP 14 #define TAINT_LIVEPATCH 15 @@ -214,7 +214,7 @@ Signed-off-by: Andreas Gruenbacher /* * Mutex protects: * 1) List of modules (also safely readable with preempt_disable), -@@ -1171,6 +1187,12 @@ static size_t module_flags_taint(struct +@@ -1156,6 +1172,12 @@ static size_t module_flags_taint(struct buf[l++] = taint_flags[i].c_true; } @@ -227,7 +227,7 @@ Signed-off-by: Andreas Gruenbacher return l; } -@@ -1243,6 +1265,33 @@ static ssize_t show_taint(struct module_ +@@ -1228,6 +1250,33 @@ static ssize_t show_taint(struct module_ static struct module_attribute modinfo_taint = __ATTR(taint, 0444, show_taint, NULL); @@ -261,7 +261,7 @@ Signed-off-by: Andreas Gruenbacher static struct module_attribute *modinfo_attrs[] = { &module_uevent, &modinfo_version, -@@ -1251,6 +1300,9 @@ static struct module_attribute *modinfo_ +@@ -1236,6 +1285,9 @@ static struct module_attribute *modinfo_ &modinfo_coresize, &modinfo_initsize, &modinfo_taint, @@ -271,7 +271,7 @@ Signed-off-by: Andreas Gruenbacher #ifdef CONFIG_MODULE_UNLOAD &modinfo_refcnt, #endif -@@ -1806,9 +1858,37 @@ static int mod_sysfs_setup(struct module +@@ -1790,8 +1842,36 @@ static int mod_sysfs_setup(struct module add_sect_attrs(mod, info); add_notes_attrs(mod, info); @@ -296,7 +296,6 @@ Signed-off-by: Andreas Gruenbacher + } +#endif + - kobject_uevent(&mod->mkobj.kobj, KOBJ_ADD); return 0; +#ifdef CONFIG_SUSE_KERNEL_SUPPORTED @@ -309,7 +308,7 @@ Signed-off-by: Andreas Gruenbacher out_unreg_param: module_param_sysfs_remove(mod); out_unreg_holders: -@@ -4325,6 +4405,9 @@ void print_modules(void) +@@ -4344,6 +4424,9 @@ void print_modules(void) if (last_unloaded_module[0]) pr_cont(" [last unloaded: %s]", last_unloaded_module); pr_cont("\n"); @@ -321,7 +320,7 @@ Signed-off-by: Andreas Gruenbacher #ifdef CONFIG_MODVERSIONS --- a/kernel/panic.c +++ b/kernel/panic.c -@@ -321,6 +321,10 @@ const struct taint_flag taint_flags[TAIN +@@ -325,6 +325,10 @@ const struct taint_flag taint_flags[TAIN { 'E', ' ', true }, /* TAINT_UNSIGNED_MODULE */ { 'L', ' ', false }, /* TAINT_SOFTLOCKUP */ { 'K', ' ', true }, /* TAINT_LIVEPATCH */ @@ -332,7 +331,7 @@ Signed-off-by: Andreas Gruenbacher }; /** -@@ -342,6 +346,8 @@ const struct taint_flag taint_flags[TAIN +@@ -346,6 +350,8 @@ const struct taint_flag taint_flags[TAIN * 'E' - Unsigned module has been loaded. * 'L' - A soft lockup has previously occurred. * 'K' - Kernel has been live patched. @@ -343,7 +342,7 @@ Signed-off-by: Andreas Gruenbacher */ --- a/kernel/sysctl.c +++ b/kernel/sysctl.c -@@ -790,6 +790,15 @@ static struct ctl_table kern_table[] = { +@@ -795,6 +795,15 @@ static struct ctl_table kern_table[] = { .extra1 = &pid_max_min, .extra2 = &pid_max_max, }, diff --git a/series.conf b/series.conf index 0e17e8d..e791f11 100644 --- a/series.conf +++ b/series.conf @@ -57729,6 +57729,7 @@ patches.suse/NFSv4.2-condition-READDIR-s-mask-for-security-label-.patch patches.suse/lockd-don-t-use-interval-based-rebinding-over-TCP.patch patches.suse/NFS-switch-nfsiod-to-be-an-UNBOUND-workqueue.patch + patches.suse/module-delay-kobject-uevent-until-after-module-init-.patch patches.suse/powerpc-64-Set-up-a-kernel-stack-for-secondaries-bef.patch patches.suse/Revert-powerpc-pseries-hotplug-cpu-Remove-double-fre.patch patches.suse/powerpc-perf-Fix-crash-with-is_sier_available-when-p.patch