Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86d56134 authored by Michael Marineau's avatar Michael Marineau Committed by Greg Kroah-Hartman
Browse files

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: default avatarDarren Shepherd <darren.s.shepherd@gmail.com>
Signed-off-by: default avatarMichael Marineau <mike@marineau.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d911d987
Loading
Loading
Loading
Loading
+11 −6
Original line number Original line Diff line number Diff line
menu "Generic Driver Options"
menu "Generic Driver Options"


config UEVENT_HELPER_PATH
config UEVENT_HELPER
	string "path to uevent helper"
	bool "Support for uevent helper"
	default ""
	default y
	help
	help
	  Path to uevent helper program forked by the kernel for
	  The uevent helper program is forked by the kernel for
	  every uevent.
	  every uevent.
	  Before the switch to the netlink-based uevent source, this was
	  Before the switch to the netlink-based uevent source, this was
	  used to hook hotplug scripts into kernel device events. It
	  used to hook hotplug scripts into kernel device events. It
@@ -15,8 +15,13 @@ config UEVENT_HELPER_PATH
	  that it creates a high system load, or on smaller systems
	  that it creates a high system load, or on smaller systems
	  it is known to create out-of-memory situations during bootup.
	  it is known to create out-of-memory situations during bootup.


	  To disable user space helper program execution at early boot
config UEVENT_HELPER_PATH
	  time specify an empty string here. This setting can be altered
	string "path to uevent helper"
	depends on UEVENT_HELPER
	default ""
	help
	  To disable user space helper program execution at by default
	  specify an empty string here. This setting can still be altered
	  via /proc/sys/kernel/hotplug or via /sys/kernel/uevent_helper
	  via /proc/sys/kernel/hotplug or via /sys/kernel/uevent_helper
	  later at runtime.
	  later at runtime.


+2 −0
Original line number Original line Diff line number Diff line
@@ -32,8 +32,10 @@
#define UEVENT_NUM_ENVP			32	/* number of env pointers */
#define UEVENT_NUM_ENVP			32	/* number of env pointers */
#define UEVENT_BUFFER_SIZE		2048	/* buffer for the variables */
#define UEVENT_BUFFER_SIZE		2048	/* buffer for the variables */


#ifdef CONFIG_UEVENT_HELPER
/* path to the userspace helper executed on an event */
/* path to the userspace helper executed on an event */
extern char uevent_helper[];
extern char uevent_helper[];
#endif


/* counter to tag the uevent, read only except for the kobject core */
/* counter to tag the uevent, read only except for the kobject core */
extern u64 uevent_seqnum;
extern u64 uevent_seqnum;
+4 −1
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ static ssize_t uevent_seqnum_show(struct kobject *kobj,
}
}
KERNEL_ATTR_RO(uevent_seqnum);
KERNEL_ATTR_RO(uevent_seqnum);


#ifdef CONFIG_UEVENT_HELPER
/* uevent helper program, used during early boot */
/* uevent helper program, used during early boot */
static ssize_t uevent_helper_show(struct kobject *kobj,
static ssize_t uevent_helper_show(struct kobject *kobj,
				  struct kobj_attribute *attr, char *buf)
				  struct kobj_attribute *attr, char *buf)
@@ -56,7 +57,7 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
	return count;
	return count;
}
}
KERNEL_ATTR_RW(uevent_helper);
KERNEL_ATTR_RW(uevent_helper);

#endif


#ifdef CONFIG_PROFILING
#ifdef CONFIG_PROFILING
static ssize_t profiling_show(struct kobject *kobj,
static ssize_t profiling_show(struct kobject *kobj,
@@ -189,7 +190,9 @@ EXPORT_SYMBOL_GPL(kernel_kobj);
static struct attribute * kernel_attrs[] = {
static struct attribute * kernel_attrs[] = {
	&fscaps_attr.attr,
	&fscaps_attr.attr,
	&uevent_seqnum_attr.attr,
	&uevent_seqnum_attr.attr,
#ifdef CONFIG_UEVENT_HELPER
	&uevent_helper_attr.attr,
	&uevent_helper_attr.attr,
#endif
#ifdef CONFIG_PROFILING
#ifdef CONFIG_PROFILING
	&profiling_attr.attr,
	&profiling_attr.attr,
#endif
#endif
+2 −2
Original line number Original line Diff line number Diff line
@@ -643,7 +643,7 @@ static struct ctl_table kern_table[] = {
		.extra2		= &one,
		.extra2		= &one,
	},
	},
#endif
#endif

#ifdef CONFIG_UEVENT_HELPER
	{
	{
		.procname	= "hotplug",
		.procname	= "hotplug",
		.data		= &uevent_helper,
		.data		= &uevent_helper,
@@ -651,7 +651,7 @@ static struct ctl_table kern_table[] = {
		.mode		= 0644,
		.mode		= 0644,
		.proc_handler	= proc_dostring,
		.proc_handler	= proc_dostring,
	},
	},

#endif
#ifdef CONFIG_CHR_DEV_SG
#ifdef CONFIG_CHR_DEV_SG
	{
	{
		.procname	= "sg-big-buff",
		.procname	= "sg-big-buff",
+6 −0
Original line number Original line Diff line number Diff line
@@ -29,7 +29,9 @@




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


#ifdef CONFIG_UEVENT_HELPER
static int kobj_usermode_filter(struct kobject *kobj)
static int kobj_usermode_filter(struct kobject *kobj)
{
{
	const struct kobj_ns_type_operations *ops;
	const struct kobj_ns_type_operations *ops;
@@ -147,6 +150,7 @@ static void cleanup_uevent_env(struct subprocess_info *info)
{
{
	kfree(info->data);
	kfree(info->data);
}
}
#endif


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


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


exit:
exit:
	kfree(devpath);
	kfree(devpath);