aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Marineau <mike@marineau.org>2014-04-10 17:09:31 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-04-25 15:00:49 -0400
commit86d56134f1b67d0c18025ba5cade95c048ed528d (patch)
treecaa4346965954ded259784e3b68af159e3161aeb
parentd911d98748018f7c8facc035ba39c30f5cce6f9c (diff)
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>
-rw-r--r--drivers/base/Kconfig17
-rw-r--r--include/linux/kobject.h2
-rw-r--r--kernel/ksysfs.c5
-rw-r--r--kernel/sysctl.c4
-rw-r--r--lib/kobject_uevent.c6
5 files changed, 25 insertions, 9 deletions
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 8fa8deab6449..4b7b4522b64f 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -1,10 +1,10 @@
1menu "Generic Driver Options" 1menu "Generic Driver Options"
2 2
3config UEVENT_HELPER_PATH 3config UEVENT_HELPER
4 string "path to uevent helper" 4 bool "Support for uevent helper"
5 default "" 5 default y
6 help 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 every uevent. 8 every uevent.
9 Before the switch to the netlink-based uevent source, this was 9 Before the switch to the netlink-based uevent source, this was
10 used to hook hotplug scripts into kernel device events. It 10 used to hook hotplug scripts into kernel device events. It
@@ -15,8 +15,13 @@ config UEVENT_HELPER_PATH
15 that it creates a high system load, or on smaller systems 15 that it creates a high system load, or on smaller systems
16 it is known to create out-of-memory situations during bootup. 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 18config UEVENT_HELPER_PATH
19 time specify an empty string here. This setting can be altered 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 via /proc/sys/kernel/hotplug or via /sys/kernel/uevent_helper 25 via /proc/sys/kernel/hotplug or via /sys/kernel/uevent_helper
21 later at runtime. 26 later at runtime.
22 27
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index f896a33e8341..2d61b909f414 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -32,8 +32,10 @@
32#define UEVENT_NUM_ENVP 32 /* number of env pointers */ 32#define UEVENT_NUM_ENVP 32 /* number of env pointers */
33#define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */ 33#define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */
34 34
35#ifdef CONFIG_UEVENT_HELPER
35/* path to the userspace helper executed on an event */ 36/* path to the userspace helper executed on an event */
36extern char uevent_helper[]; 37extern char uevent_helper[];
38#endif
37 39
38/* counter to tag the uevent, read only except for the kobject core */ 40/* counter to tag the uevent, read only except for the kobject core */
39extern u64 uevent_seqnum; 41extern u64 uevent_seqnum;
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 2495a9b14ac8..6683ccef9fff 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -37,6 +37,7 @@ static ssize_t uevent_seqnum_show(struct kobject *kobj,
37} 37}
38KERNEL_ATTR_RO(uevent_seqnum); 38KERNEL_ATTR_RO(uevent_seqnum);
39 39
40#ifdef CONFIG_UEVENT_HELPER
40/* uevent helper program, used during early boot */ 41/* uevent helper program, used during early boot */
41static ssize_t uevent_helper_show(struct kobject *kobj, 42static ssize_t uevent_helper_show(struct kobject *kobj,
42 struct kobj_attribute *attr, char *buf) 43 struct kobj_attribute *attr, char *buf)
@@ -56,7 +57,7 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
56 return count; 57 return count;
57} 58}
58KERNEL_ATTR_RW(uevent_helper); 59KERNEL_ATTR_RW(uevent_helper);
59 60#endif
60 61
61#ifdef CONFIG_PROFILING 62#ifdef CONFIG_PROFILING
62static ssize_t profiling_show(struct kobject *kobj, 63static ssize_t profiling_show(struct kobject *kobj,
@@ -189,7 +190,9 @@ EXPORT_SYMBOL_GPL(kernel_kobj);
189static struct attribute * kernel_attrs[] = { 190static struct attribute * kernel_attrs[] = {
190 &fscaps_attr.attr, 191 &fscaps_attr.attr,
191 &uevent_seqnum_attr.attr, 192 &uevent_seqnum_attr.attr,
193#ifdef CONFIG_UEVENT_HELPER
192 &uevent_helper_attr.attr, 194 &uevent_helper_attr.attr,
195#endif
193#ifdef CONFIG_PROFILING 196#ifdef CONFIG_PROFILING
194 &profiling_attr.attr, 197 &profiling_attr.attr,
195#endif 198#endif
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 74f5b580fe34..bc966a8ffc3e 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -643,7 +643,7 @@ static struct ctl_table kern_table[] = {
643 .extra2 = &one, 643 .extra2 = &one,
644 }, 644 },
645#endif 645#endif
646 646#ifdef CONFIG_UEVENT_HELPER
647 { 647 {
648 .procname = "hotplug", 648 .procname = "hotplug",
649 .data = &uevent_helper, 649 .data = &uevent_helper,
@@ -651,7 +651,7 @@ static struct ctl_table kern_table[] = {
651 .mode = 0644, 651 .mode = 0644,
652 .proc_handler = proc_dostring, 652 .proc_handler = proc_dostring,
653 }, 653 },
654 654#endif
655#ifdef CONFIG_CHR_DEV_SG 655#ifdef CONFIG_CHR_DEV_SG
656 { 656 {
657 .procname = "sg-big-buff", 657 .procname = "sg-big-buff",
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 4e3bd71bd949..9ebf9e20de53 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -29,7 +29,9 @@
29 29
30 30
31u64 uevent_seqnum; 31u64 uevent_seqnum;
32#ifdef CONFIG_UEVENT_HELPER
32char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH; 33char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH;
34#endif
33#ifdef CONFIG_NET 35#ifdef CONFIG_NET
34struct uevent_sock { 36struct uevent_sock {
35 struct list_head list; 37 struct list_head list;
@@ -109,6 +111,7 @@ static int kobj_bcast_filter(struct sock *dsk, struct sk_buff *skb, void *data)
109} 111}
110#endif 112#endif
111 113
114#ifdef CONFIG_UEVENT_HELPER
112static int kobj_usermode_filter(struct kobject *kobj) 115static int kobj_usermode_filter(struct kobject *kobj)
113{ 116{
114 const struct kobj_ns_type_operations *ops; 117 const struct kobj_ns_type_operations *ops;
@@ -147,6 +150,7 @@ static void cleanup_uevent_env(struct subprocess_info *info)
147{ 150{
148 kfree(info->data); 151 kfree(info->data);
149} 152}
153#endif
150 154
151/** 155/**
152 * kobject_uevent_env - send an uevent with environmental data 156 * kobject_uevent_env - send an uevent with environmental data
@@ -323,6 +327,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
323#endif 327#endif
324 mutex_unlock(&uevent_sock_mutex); 328 mutex_unlock(&uevent_sock_mutex);
325 329
330#ifdef CONFIG_UEVENT_HELPER
326 /* call uevent_helper, usually only enabled during early boot */ 331 /* call uevent_helper, usually only enabled during early boot */
327 if (uevent_helper[0] && !kobj_usermode_filter(kobj)) { 332 if (uevent_helper[0] && !kobj_usermode_filter(kobj)) {
328 struct subprocess_info *info; 333 struct subprocess_info *info;
@@ -347,6 +352,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
347 env = NULL; /* freed by cleanup_uevent_env */ 352 env = NULL; /* freed by cleanup_uevent_env */
348 } 353 }
349 } 354 }
355#endif
350 356
351exit: 357exit:
352 kfree(devpath); 358 kfree(devpath);