Skip to content

Commit 86d5613

Browse files
marineamgregkh
authored andcommitted
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>
1 parent d911d98 commit 86d5613

5 files changed

Lines changed: 25 additions & 9 deletions

File tree

drivers/base/Kconfig

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
menu "Generic Driver Options"
22

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
66
help
7-
Path to uevent helper program forked by the kernel for
7+
The uevent helper program is forked by the kernel for
88
every uevent.
99
Before the switch to the netlink-based uevent source, this was
1010
used to hook hotplug scripts into kernel device events. It
@@ -15,8 +15,13 @@ config UEVENT_HELPER_PATH
1515
that it creates a high system load, or on smaller systems
1616
it is known to create out-of-memory situations during bootup.
1717

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
2025
via /proc/sys/kernel/hotplug or via /sys/kernel/uevent_helper
2126
later at runtime.
2227

include/linux/kobject.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@
3232
#define UEVENT_NUM_ENVP 32 /* number of env pointers */
3333
#define UEVENT_BUFFER_SIZE 2048 /* buffer for the variables */
3434

35+
#ifdef CONFIG_UEVENT_HELPER
3536
/* path to the userspace helper executed on an event */
3637
extern char uevent_helper[];
38+
#endif
3739

3840
/* counter to tag the uevent, read only except for the kobject core */
3941
extern u64 uevent_seqnum;

kernel/ksysfs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static ssize_t uevent_seqnum_show(struct kobject *kobj,
3737
}
3838
KERNEL_ATTR_RO(uevent_seqnum);
3939

40+
#ifdef CONFIG_UEVENT_HELPER
4041
/* uevent helper program, used during early boot */
4142
static ssize_t uevent_helper_show(struct kobject *kobj,
4243
struct kobj_attribute *attr, char *buf)
@@ -56,7 +57,7 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
5657
return count;
5758
}
5859
KERNEL_ATTR_RW(uevent_helper);
59-
60+
#endif
6061

6162
#ifdef CONFIG_PROFILING
6263
static ssize_t profiling_show(struct kobject *kobj,
@@ -189,7 +190,9 @@ EXPORT_SYMBOL_GPL(kernel_kobj);
189190
static struct attribute * kernel_attrs[] = {
190191
&fscaps_attr.attr,
191192
&uevent_seqnum_attr.attr,
193+
#ifdef CONFIG_UEVENT_HELPER
192194
&uevent_helper_attr.attr,
195+
#endif
193196
#ifdef CONFIG_PROFILING
194197
&profiling_attr.attr,
195198
#endif

kernel/sysctl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,15 +643,15 @@ static struct ctl_table kern_table[] = {
643643
.extra2 = &one,
644644
},
645645
#endif
646-
646+
#ifdef CONFIG_UEVENT_HELPER
647647
{
648648
.procname = "hotplug",
649649
.data = &uevent_helper,
650650
.maxlen = UEVENT_HELPER_PATH_LEN,
651651
.mode = 0644,
652652
.proc_handler = proc_dostring,
653653
},
654-
654+
#endif
655655
#ifdef CONFIG_CHR_DEV_SG
656656
{
657657
.procname = "sg-big-buff",

lib/kobject_uevent.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929

3030

3131
u64 uevent_seqnum;
32+
#ifdef CONFIG_UEVENT_HELPER
3233
char uevent_helper[UEVENT_HELPER_PATH_LEN] = CONFIG_UEVENT_HELPER_PATH;
34+
#endif
3335
#ifdef CONFIG_NET
3436
struct uevent_sock {
3537
struct list_head list;
@@ -109,6 +111,7 @@ static int kobj_bcast_filter(struct sock *dsk, struct sk_buff *skb, void *data)
109111
}
110112
#endif
111113

114+
#ifdef CONFIG_UEVENT_HELPER
112115
static int kobj_usermode_filter(struct kobject *kobj)
113116
{
114117
const struct kobj_ns_type_operations *ops;
@@ -147,6 +150,7 @@ static void cleanup_uevent_env(struct subprocess_info *info)
147150
{
148151
kfree(info->data);
149152
}
153+
#endif
150154

151155
/**
152156
* kobject_uevent_env - send an uevent with environmental data
@@ -323,6 +327,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
323327
#endif
324328
mutex_unlock(&uevent_sock_mutex);
325329

330+
#ifdef CONFIG_UEVENT_HELPER
326331
/* call uevent_helper, usually only enabled during early boot */
327332
if (uevent_helper[0] && !kobj_usermode_filter(kobj)) {
328333
struct subprocess_info *info;
@@ -347,6 +352,7 @@ int kobject_uevent_env(struct kobject *kobj, enum kobject_action action,
347352
env = NULL; /* freed by cleanup_uevent_env */
348353
}
349354
}
355+
#endif
350356

351357
exit:
352358
kfree(devpath);

0 commit comments

Comments
 (0)