Skip to contentSkip to conversation

Race/problem with hotplug & network interfaces

PATCH Oleg Drokin 2 participants 3 messages Dec 4, 2000 Scheduler

lore
Share & tools
lore
#0 lore raw

Hello!

It seems I have found some kind of race, if hotplug is enabled, and one have changing number of network interfaces (observed on ppp). I use 2.4.0-test11. Problem is 100% repeatable.

My test case is this: I start ppp over ssh session, then do ifconfig and then kill pppd (by kill -9 pid).
Immediatelly I getting: 1. waitpid(<somepid>) failed, -512 2. oops. Inspecting oops, I have found that
current->files == NULL in kmod.c::exec_usermodehelper.
After some investigations, it appears, that when pppd exits, ppp interface gets destroyed, and /sbin/hotplug net is called, using now dead pppd as parent.
Simple (and probably not that good) solution is attached as patch, below. It get gid of oops, but waitpid failed thing is still there.

Also I post oops here, too. (sorry, no Code decoding)

kmod.c renamed from kmod.c.orig +4 -2
@@ -99,8 +99,10 @@
 	flush_signal_handlers(current);
 	spin_unlock_irq(&current->sigmask_lock);
 
-	for (i = 0; i < current->files->max_fds; i++ ) {
-		if (current->files->fd[i]) close(i);
+	if ( current->files ) {
+		for (i = 0; i < current->files->max_fds; i++ ) {
+			if (current->files->fd[i]) close(i);
+		}
 	}
 
 	/* Drop the "current user" thing */
Unable to handle kernel NULL pointer dereference at virtual address 00000008
c01122a4
*pde = 00000000
Oops: 0000
CPU:    0
EIP:    0010:[<c01122a4>]

Using defaults from ksymoops -t elf32-i386 -a i386
EFLAGS: 00010246
eax: c7acea64 ebx: c7a20000 ecx: c1292000 edx: 00000000
esi: 00000006 edi: 00000000 ebp: c1228320 esp: c7a21fb8
ds: 0018 es: 0018 ss: 0018
Process pppd (pid: 181, stackpage=c7a21000)

Stack: 00000100 c7c43d84 c7c43db4 c7a76b20 c7b8c0c0 c1228320 c7f87a60 c7f87a60 
       c7f87a60 c7f87a60 c011259c c01d7ba0 c7c43e44 c7c43e30 c01073f8 c7c43db4 
       00000078 c7c43e44 
Call Trace: [<c011259c>] [<c01073f8>] 
Code: 8b 4f 08 39 ca 7d 22 90 8b 47 14 83 3c 90 00 74 13 89 f0 89 
Quoted 1 line
Quoted 1 line

EIP; c01122a4 <exec_usermodehelper+298/3d8> <=====

Trace; c011259c <request_module+1b8/1bc>
Trace; c01073f8 <kernel_thread+28/1b8>

Bye,
Oleg
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw
Quoted 7 lines · Oleg Drokin

Hello!

It seems I have found some kind of race, if hotplug is enabled, and one have changing number of network interfaces (observed on ppp). I use 2.4.0-test11. Problem is 100% repeatable.

Quoted 10 lines

My test case is this: I start ppp over ssh session, then do ifconfig and then kill pppd (by kill -9 pid).
Immediatelly I getting: 1. waitpid(<somepid>) failed, -512 2. oops. Inspecting oops, I have found that
current->files == NULL in kmod.c::exec_usermodehelper.
After some investigations, it appears, that when pppd exits, ppp interface gets destroyed, and /sbin/hotplug net is called, using now dead pppd as parent.
Simple (and probably not that good) solution is attached as patch, below. It get gid of oops, but waitpid failed thing is still there.

Yup. This is due to the kernel trying to fork/exec from within a half-dead process.

Could you please test this patch? It was sent to Linus for test12-pre4, but....

include/linux/sched.h +1 -0
@@ -150,6 +150,7 @@
 asmlinkage void schedule(void);
 
 extern void schedule_task(struct tq_struct *task);
+extern int start_context_thread(void);
 
 /*
  * The default fd array needs to be at least BITS_PER_LONG,
kernel/kmod.c +103 -22

150 lines not on this page · raw message

kernel/context.c +31 -11

80 lines not on this page · raw message

init/main.c +5 -5
@@ -700,6 +700,7 @@
 	else mount_initrd =0;
 #endif
 
+	start_context_thread();
 	do_initcalls();
 
 	/* .. filesystems .. */
@@ -712,16 +713,16 @@
 	init_pcmcia_ds();		/* Do this last */
 #endif
 
-#ifdef CONFIG_HOTPLUG
+	/* Mount the root filesystem.. */
+	mount_root();
+
+#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
 	/* do this after other 'do this last' stuff, because we want
 	 * to minimize spurious executions of /sbin/hotplug
 	 * during boot-up
 	 */
 	net_notifier_init();
 #endif
-
-	/* Mount the root filesystem.. */
-	mount_root();
 
 	mount_devfs_fs ();
-

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#2 lore raw
In reply to Oleg Drokin

Hello!

Quoted 2 lines · Andrew Morton

Could you please test this patch? It was sent to Linus for test12-pre4, but....

Yes, it works that way.
But code path and readability became horrible, unfortunatelly. :(

Bye,
Oleg
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/