mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [BUG] 2.5.62 kmod rewrite broke modprobe's install command
@ 2003-02-23 13:00 Mikael Pettersson
  2003-02-24  2:52 ` Rusty Russell
  0 siblings, 1 reply; 3+ messages in thread
From: Mikael Pettersson @ 2003-02-23 13:00 UTC (permalink / raw)
  To: rusty; +Cc: linux-kernel

In kernel 2.5.62, modprobe logs "FATAL: Error -1" when invoked
via request_module() to run a trivial /bin/true "install" command.
This problem did not exist in 2.5.61 or earlier kernels.

Repeat-by: Build a kernel without the RTC driver, put
"install char-major-10-135 /bin/true" in /etc/modprobe.conf
(new ugly way of saying "alias ... off"), od -c /dev/rtc,
and observe the modprobe error in /var/log/messages.
This will trigger the problem with 100% repeatability for me.

The reason this happens is that in 2.5.62, modprobe is started
with SIGCHLD set to SIG_IGN and not blocked. The "install"
command is run by system(), but due to SIGCHLD being SIG_IGN,
the child (which terminates quickly) is reaped automatically.
The parent process (modprobe) does a wait or waitpid, which fails
with ECHILD since the child is already gone. system() returns -1,
and modprobe logs a fatal error.

In 2.5.61 and earlier kernels, modprobe is started with SIGCHLD
set to SIG_DFL and not blocked, and system() works normally.

/Mikael

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [BUG] 2.5.62 kmod rewrite broke modprobe's install command
@ 2003-02-24 12:58 Mikael Pettersson
  0 siblings, 0 replies; 3+ messages in thread
From: Mikael Pettersson @ 2003-02-24 12:58 UTC (permalink / raw)
  To: rusty; +Cc: linux-kernel, torvalds

On Mon, 24 Feb 2003 13:52:18 +1100, Rusty Russell wrote:
>--- linux-2.5.62-bk6/kernel/kmod.c	2003-02-18 11:18:57.000000000 +1100
>+++ working-2.5.62-bk6-usermode-sig/kernel/kmod.c	2003-02-24 12:18:55.000000000 +1100
>@@ -152,6 +152,14 @@ static int ____call_usermodehelper(void 
> 	struct subprocess_info *sub_info = data;
> 	int retval;
> 
>+	/* Unblock all signals. */
>+	flush_signals(curtask);
>+	flush_signal_handlers(curtask);
>+	spin_lock_irq(&curtask->sighand->siglock);
>+	sigemptyset(&curtask->blocked);
>+	recalc_sigpending();
>+	spin_unlock_irq(&curtask->sighand->siglock);
>+
> 	retval = -EPERM;
> 	if (current->fs->root)
> 		retval = execve(sub_info->path, sub_info->argv,sub_info->envp);
>

Doesn't compile (curtask undeclared) and doesn't work (SIGCHLD is
still SIG_IGN causing system() to fail). The problem is that
kernel/workqueue.c:worker_thread() [which is what runs modprobe now]
sets SIGCHLD to SIG_IGN, and your patch doesn't unbreak that.

The patch below, applied on top of your patch, makes it work for me.

/Mikael

--- linux-2.5.62/kernel/kmod.c.~2~	2003-02-24 12:39:01.000000000 +0100
+++ linux-2.5.62/kernel/kmod.c	2003-02-24 13:27:51.000000000 +0100
@@ -150,10 +150,12 @@
 static int ____call_usermodehelper(void *data)
 {
 	struct subprocess_info *sub_info = data;
+	struct task_struct *curtask = current;
 	int retval;
 
 	/* Unblock all signals. */
 	flush_signals(curtask);
+	curtask->sighand->action[SIGCHLD-1].sa.sa_handler = SIG_DFL;
 	flush_signal_handlers(curtask);
 	spin_lock_irq(&curtask->sighand->siglock);
 	sigemptyset(&curtask->blocked);

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

end of thread, other threads:[~2003-02-24 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-23 13:00 [BUG] 2.5.62 kmod rewrite broke modprobe's install command Mikael Pettersson
2003-02-24  2:52 ` Rusty Russell
2003-02-24 12:58 Mikael Pettersson

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

all inboxes | Powered by JetHome®