public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RETRY] [PATCH] load_module: no BUG if module_subsys uninitialized
@ 2006-09-22 19:48 Ed Swierk
  2006-09-22 20:16 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Ed Swierk @ 2006-09-22 19:48 UTC (permalink / raw)
  To: linux-kernel; +Cc: rusty

[-- Attachment #1: Type: text/plain, Size: 969 bytes --]

[I discovered after sending my previous message that Gmail helpfully
line-wrapped and de-tabified my patch. I'm resending it as an
attachment; apologies for the error.]

Invoking load_module() before param_sysfs_init() is called crashes in
mod_sysfs_setup(), since the kset in module_subsys is not initialized
yet.

Another patch for the same symptom
(module_subsys-initialize-earlier.patch) moves param_sysfs_init() to
the subsys initcalls, but this is still not early enough in the boot
process in some cases. In particular, topology_init() causes
/sbin/hotplug to run, which requests net-pf-1 (the UNIX socket
protocol) which can be compiled as a module. Moving param_sysfs_init()
to the postcore initcalls fixes this particular race, but there might
well be other cases where a usermodehelper causes a module to load
earlier still.

The patch below makes load_module() return an error rather than
crashing the kernel if invoked before module_subsys is initialized.

[-- Attachment #2: module_subsys-uninit-return-err.patch --]
[-- Type: text/x-patch, Size: 465 bytes --]

--- linux-2.6.17.11.orig/kernel/module.c	2006-08-23 21:16:33.000000000 +0000
+++ linux-2.6.17.11/kernel/module.c	2006-09-22 05:19:03.000000000 +0000
@@ -998,6 +998,12 @@
 {
 	int err;
 
+	if (!module_subsys.kset.subsys) {
+		printk(KERN_ERR "%s: module_subsys not initialized\n",
+		       mod->name);
+		err = -EINVAL;
+		goto out;
+	}
 	memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj));
 	err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name);
 	if (err)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RETRY] [PATCH] load_module: no BUG if module_subsys uninitialized
  2006-09-22 19:48 [RETRY] [PATCH] load_module: no BUG if module_subsys uninitialized Ed Swierk
@ 2006-09-22 20:16 ` Greg KH
  2006-09-22 21:28   ` Ed Swierk
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2006-09-22 20:16 UTC (permalink / raw)
  To: Ed Swierk; +Cc: linux-kernel, rusty

On Fri, Sep 22, 2006 at 12:48:48PM -0700, Ed Swierk wrote:
> [I discovered after sending my previous message that Gmail helpfully
> line-wrapped and de-tabified my patch. I'm resending it as an
> attachment; apologies for the error.]
> 
> Invoking load_module() before param_sysfs_init() is called crashes in
> mod_sysfs_setup(), since the kset in module_subsys is not initialized
> yet.

How are you calling load_module before this init call is made?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RETRY] [PATCH] load_module: no BUG if module_subsys uninitialized
  2006-09-22 20:16 ` Greg KH
@ 2006-09-22 21:28   ` Ed Swierk
  2006-09-27  4:56     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Ed Swierk @ 2006-09-22 21:28 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, rusty

On 9/22/06, Greg KH <greg@kroah.com> wrote:
> How are you calling load_module before this init call is made?

In my case, net-pf-1 is getting modprobed as a result of hotplug
trying to create a UNIX socket. Calls to hotplug begin after the
topology_init initcall.

--Ed

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RETRY] [PATCH] load_module: no BUG if module_subsys uninitialized
  2006-09-22 21:28   ` Ed Swierk
@ 2006-09-27  4:56     ` Greg KH
  2006-09-27 19:10       ` Ed Swierk
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2006-09-27  4:56 UTC (permalink / raw)
  To: Ed Swierk; +Cc: linux-kernel, rusty

On Fri, Sep 22, 2006 at 02:28:57PM -0700, Ed Swierk wrote:
> On 9/22/06, Greg KH <greg@kroah.com> wrote:
> >How are you calling load_module before this init call is made?
> 
> In my case, net-pf-1 is getting modprobed as a result of hotplug
> trying to create a UNIX socket. Calls to hotplug begin after the
> topology_init initcall.

So, with this patch the module will still not be loaded properly, right?
Well, I guess at least we don't oops... ok.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RETRY] [PATCH] load_module: no BUG if module_subsys uninitialized
  2006-09-27  4:56     ` Greg KH
@ 2006-09-27 19:10       ` Ed Swierk
  0 siblings, 0 replies; 5+ messages in thread
From: Ed Swierk @ 2006-09-27 19:10 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, rusty

On 9/26/06, Greg KH <greg@kroah.com> wrote:
> So, with this patch the module will still not be loaded properly, right?
> Well, I guess at least we don't oops... ok.

Correct. sys_init_module() ends up returning an error to
/sbin/modprobe, which trickles down to request_module() if it was
invoked via kmod. The module doesn't get loaded, but at least the
error message states which module it is, and as you say, at least we
don't oops.

I think that not oopsing is pretty important in a case where a goofy
but technically valid configuration (compiling Unix sockets as a
module, and trying to boot with a rootfs containing a version of
/sbin/hotplug that requires Unix sockets) collides with an obscure
kernel implementation detail (initcall ordering).

--Ed

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-09-27 19:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-22 19:48 [RETRY] [PATCH] load_module: no BUG if module_subsys uninitialized Ed Swierk
2006-09-22 20:16 ` Greg KH
2006-09-22 21:28   ` Ed Swierk
2006-09-27  4:56     ` Greg KH
2006-09-27 19:10       ` Ed Swierk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox