Skip to contentSkip to conversation

Remove exec_usermodehelper

PATCH In review Rusty Russell 2 participants 2 messages Jan 11, 2003

Subsystems (10)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove exec_usermodehelper

Linus, please apply.

Updated for 2.5.56, and retested (dumb compile error fixed). No word from James, but Marcel and Thomas gave it the thumbs up.

Name: exec_usermodehelper sucks
Author: Rusty Russell, Marcel Holtmann
Status: Tested on 2.5.56

D: Urban Widmark points out that modprobe calls system() in many
D: configurations, which drops privs since request_module() doesn't
D: doesn't set ruid and rguid.
D:
D: This gets rid of exec_usermodehelper and makes everyone use
D: call_usermodehelper, which has a new "wait" flag.

arch/i386/mach-voyager/voyager_thread.c +4 -13
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/arch/i386/mach-voyager/voyager_thread.c working-2.5-bk-kmod-noclean/arch/i386/mach-voyager/voyager_thread.c
@@ -57,7 +57,7 @@ voyager_thread_start(void)
 }
 
 static int
-execute_helper(void *string)
+execute(const char *string)
 {
 	int ret;
 
@@ -74,20 +74,11 @@ execute_helper(void *string)
 		NULL,
 	};
 
-	if((ret = exec_usermodehelper(argv[0], argv, envp)) < 0) {
-		printk(KERN_ERR "Voyager failed to execute \"%s\"\n",
-		       (char *)string);
+	if ((ret = call_usermodehelper(argv[0], argv, envp, 1)) != 0) {
+		printk(KERN_ERR "Voyager failed to run \"%s\": %i\n",
+		       string, ret);
 	}
 	return ret;
-}
-
-static void
-execute(char *string)
-{
-	if(kernel_thread(execute_helper, (void *)string, CLONE_VFORK | SIGCHLD) < 0) {
-		printk(KERN_ERR "Voyager failed to fork before exec of \"%s\"\n",
-		       string);
-	}
 }
 
 static void
drivers/acpi/thermal.c +1 -1
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/drivers/acpi/thermal.c working-2.5-bk-kmod-noclean/drivers/acpi/thermal.c
@@ -431,7 +431,7 @@ acpi_thermal_call_usermode (
 	envp[0] = "HOME=/";
 	envp[1] = "PATH=/sbin:/bin:/usr/sbin:/usr/bin";
 	
-	call_usermodehelper(argv[0], argv, envp);
+	call_usermodehelper(argv[0], argv, envp, 0);
 
 	return_VALUE(0);
 }
drivers/base/hotplug.c +1 -1
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/drivers/base/hotplug.c working-2.5-bk-kmod-noclean/drivers/base/hotplug.c
@@ -114,7 +114,7 @@ static int do_hotplug (struct device *de
 
 	pr_debug ("%s: %s %s %s %s %s %s\n", __FUNCTION__, argv [0], argv[1],
 		  envp[0], envp[1], envp[2], envp[3]);
-	retval = call_usermodehelper (argv [0], argv, envp);
+	retval = call_usermodehelper (argv [0], argv, envp, 0);
 	if (retval)
 		pr_debug ("%s - call_usermodehelper returned %d\n",
 			  __FUNCTION__, retval);
drivers/bluetooth/bt3c_cs.c +7 -54

97 lines not on this page · raw message

drivers/ieee1394/nodemgr.c +1 -1
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/drivers/ieee1394/nodemgr.c working-2.5-bk-kmod-noclean/drivers/ieee1394/nodemgr.c
@@ -786,7 +786,7 @@ static void nodemgr_call_policy(char *ve
 #ifdef CONFIG_IEEE1394_VERBOSEDEBUG
 	HPSB_DEBUG("NodeMgr: %s %s %016Lx", argv[0], verb, (long long unsigned)ud->ne->guid);
 #endif
-	value = call_usermodehelper(argv[0], argv, envp);
+	value = call_usermodehelper(argv[0], argv, envp, 0);
 	kfree(buf);
 	kfree(envp);
 	if (value != 0)
drivers/input/input.c +1 -1
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/drivers/input/input.c working-2.5-bk-kmod-noclean/drivers/input/input.c
@@ -383,7 +383,7 @@ static void input_call_hotplug(char *ver
 		argv[0], argv[1], envp[0], envp[1], envp[2], envp[3], envp[4]);
 #endif
 
-	value = call_usermodehelper(argv [0], argv, envp);
+	value = call_usermodehelper(argv [0], argv, envp, 0);
 
 	kfree(buf);
 	kfree(envp);
drivers/isdn/hardware/eicon/divasmain.c +1 -1
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/drivers/isdn/hardware/eicon/divasmain.c working-2.5-bk-kmod-noclean/drivers/isdn/hardware/eicon/divasmain.c
@@ -263,7 +263,7 @@ static void diva_adapter_trapped(void *c
 		pdpc->card_failed = 0;
 		argv[2] = &adapter[0];
 
-		ret = call_usermodehelper(argv[0], argv, envp);
+		ret = call_usermodehelper(argv[0], argv, envp, 0);
 
 		if (ret) {
 			printk(KERN_ERR
drivers/net/hamradio/baycom_epp.c +6 -39

60 lines not on this page · raw message

drivers/pnp/pnpbios/core.c +1 -1
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/drivers/pnp/pnpbios/core.c working-2.5-bk-kmod-noclean/drivers/pnp/pnpbios/core.c
@@ -602,7 +602,7 @@ static int pnp_dock_event(int dock, stru
 		info->location_id, info->serial, info->capabilities);
 	envp[i] = 0;
 	
-	value = call_usermodehelper (argv [0], argv, envp);
+	value = call_usermodehelper (argv [0], argv, envp, 0);
 	kfree (buf);
 	kfree (envp);
 	return 0;
include/linux/kmod.h +2 -2
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/include/linux/kmod.h working-2.5-bk-kmod-noclean/include/linux/kmod.h
@@ -21,6 +21,7 @@
 
 #include <linux/config.h>
 #include <linux/errno.h>
+#include <linux/compiler.h>
 
 #ifdef CONFIG_KMOD
 extern int request_module(const char * name);
@@ -29,8 +30,7 @@ static inline int request_module(const c
 #endif
 
 #define try_then_request_module(x, mod) ((x) ?: request_module(mod), (x))
-extern int exec_usermodehelper(char *program_path, char *argv[], char *envp[]);
-extern int call_usermodehelper(char *path, char *argv[], char *envp[]);
+extern int call_usermodehelper(char *path, char *argv[], char *envp[], int wait);
 
 #ifdef CONFIG_HOTPLUG
 extern char hotplug_path [];
kernel/futex.c +3 -0
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/kernel/futex.c working-2.5-bk-kmod-noclean/kernel/futex.c
@@ -34,6 +34,7 @@
 #include <linux/futex.h>
 #include <linux/vcache.h>
 #include <linux/mount.h>
+#include <linux/kmod.h>
 
 #define FUTEX_HASHBITS 8
 
@@ -453,6 +454,8 @@ asmlinkage int sys_futex(unsigned long u
 		ret = futex_wait_utime(uaddr, pos_in_page, val, utime);
 		break;
 	case FUTEX_WAKE:
+		ret = request_module("foo");
+		printk("request_module foo = %i\n", ret);
 		ret = futex_wake(uaddr, pos_in_page, val);
 		break;
 	case FUTEX_FD:
kernel/kmod.c +78 -205

383 lines not on this page · raw message

net/bluetooth/hci_core.c +1 -1
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/net/bluetooth/hci_core.c working-2.5-bk-kmod-noclean/net/bluetooth/hci_core.c
@@ -114,7 +114,7 @@ static int hci_run_hotplug(char *dev, ch
 	envp[3] = astr;
 	envp[4] = NULL;
 	
-	return call_usermodehelper(argv[0], argv, envp);
+	return call_usermodehelper(argv[0], argv, envp, 0);
 }
 #else
 #define hci_run_hotplug(A...)
net/core/dev.c +1 -1
diff -urp --exclude TAGS -X /home/rusty/current-dontdiff --minimal linux-2.5-bk/net/core/dev.c working-2.5-bk-kmod-noclean/net/core/dev.c
@@ -2930,6 +2930,6 @@ static int net_run_sbin_hotplug(struct n
 	envp [i++] = action_str;
 	envp [i] = 0;
 
-	return call_usermodehelper(argv [0], argv, envp);
+	return call_usermodehelper(argv [0], argv, envp, 0);
 }
 #endif

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#1 lore raw
Quoted 2 lines · [email protected] said:

Updated for 2.5.56, and retested (dumb compile error fixed). No word from James, but Marcel and Thomas gave it the thumbs up.

Sorry, I'm currently on a business trip. I finally found a voyager system around here to test it on and it seems to work (at least for machine shutdown on panel switch). I can't test the internal battery (of all the Voyagers in the junk heap around here---where NCR manufactured them---none has an internal battery).

Go ahead and apply it. I probably need to migrate the voyager machine state handling to use kevents anyway, but I'll do that later.

James