Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kobject: Make support for uevent_helper optional.

Support for uevent_helper, aka hotplug, is not required on many systems
these days but it can still be enabled via sysfs or sysctl.

Reported-by: Darren Shepherd <darren.s.shepherd@gmail.com>
Signed-off-by: Michael Marineau <mike@marineau.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Michael Marineau and committed by
Greg Kroah-Hartman
86d56134 d911d987

+25 -9
+11 -6
drivers/base/Kconfig
··· 1 1 menu "Generic Driver Options" 2 2 3 - config UEVENT_HELPER_PATH 4 - string "path to uevent helper" 5 - default "" 3 + config UEVENT_HELPER 4 + bool "Support for uevent helper" 5 + default y 6 6 help 7 - Path to uevent helper program forked by the kernel for 7 + The uevent helper program is forked by the kernel for 8 8 every uevent. 9 9 Before the switch to the netlink-based uevent source, this was 10 10 used to hook hotplug scripts into kernel device events. It ··· 15 15 that it creates a high system load, or on smaller systems 16 16 it is known to create out-of-memory situations during bootup. 17 17 18 - To disable user space helper program execution at early boot 19 - time specify an empty string here. This setting can be altered 18 + config UEVENT_HELPER_PATH 19 + string "path to uevent helper" 20 + depends on UEVENT_HELPER 21 + default "" 22 + help 23 + To disable user space helper program execution at by default 24 + specify an empty string here. This setting can still be altered 20 25 via /proc/sys/kernel/hotplug or via /sys/kernel/uevent_helper 21 26 later at runtime. 22 27
+2
include/linux/kobject.h
··· 32 32 #define UEVENT_NUM_ENVP 32 /* number of env pointers */ 33 33 #define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */ 34 34 35 + #ifdef CONFIG_UEVENT_HELPER 35 36 /* path to the userspace helper executed on an event */ 36 37 extern char uevent_helper[]; 38 + #endif 37 39 38 40 /* counter to tag the uevent, read only except for the kobject core */ 39 41 extern u64 uevent_seqnum;
+4 -1
kernel/ksysfs.c
··· 37 37 } 38 38 KERNEL_ATTR_RO(uevent_seqnum); 39 39 40 + #ifdef CONFIG_UEVENT_HELPER 40 41 /* uevent helper program, used during early boot */ 41 42 static ssize_t uevent_helper_show(struct kobject *kobj, 42 43 struct kobj_attribute *attr, char *buf) ··· 57 56 return count; 58 57 } 59 58 KERNEL_ATTR_RW(uevent_helper); 60 - 59 + #endif 61 60 62 61 #ifdef CONFIG_PROFILING 63 62 static ssize_t profiling_show(struct kobject *kobj, ··· 190 189 static struct attribute * kernel_attrs[] = { 191 190 &fscaps_attr.attr, 192 191 &uevent_seqnum_attr.attr, 192 + #ifdef CONFIG_UEVENT_HELPER 193 193 &uevent_helper_attr.attr, 194 + #endif 194 195 #ifdef CONFIG_PROFILING 195 196 &profiling_attr.attr, 196 197 #endif
+2 -2
kernel/sysctl.c
··· 643 643 .extra2 = &one, 644 644 }, 645 645 #endif 646 - 646 + #ifdef CONFIG_UEVENT_HELPER 647 647 { 648 648 .procname = "hotplug", 649 649 .data = &uevent_helper, ··· 651 651 .mode = 0644, 652 652 .proc_handler = proc_dostring, 653 653 }, 654 - 654 + #endif 655 655 #ifdef CONFIG_CHR_DEV_SG 656 656 { 657 657 .procname = "sg-big-buff",
+6
lib/kobject_uevent.c
··· 29 29 30 30 31 31 u64 uevent_seqnum; 32 + #ifdef CONFIG_UEVENT_HELPER 32 33 char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; 34 + #endif 33 35 #ifdef CONFIG_NET 34 36 struct uevent_sock { 35 37 struct list_head list; ··· 111 109 } 112 110 #endif 113 111 112 + #ifdef CONFIG_UEVENT_HELPER 114 113 static int kobj_usermode_filter(struct kobject *kobj) 115 114 { 116 115 const struct kobj_ns_type_operations *ops; ··· 150 147 { 151 148 kfree(info->data); 152 149 } 150 + #endif 153 151 154 152 /** 155 153 * kobject_uevent_env - send an uevent with environmental data ··· 327 323 #endif 328 324 mutex_unlock(&uevent_sock_mutex); 329 325 326 + #ifdef CONFIG_UEVENT_HELPER 330 327 /* call uevent_helper, usually only enabled during early boot */ 331 328 if (uevent_helper[0] && !kobj_usermode_filter(kobj)) { 332 329 struct subprocess_info *info; ··· 352 347 env = NULL; /* freed by cleanup_uevent_env */ 353 348 } 354 349 } 350 + #endif 355 351 356 352 exit: 357 353 kfree(devpath);