提交 c7308c81 编写于 作者: G Greg Kroah-Hartman

Driver core: fix show_uevent from taking up way too much stack

Declaring an array of PAGE_SIZE does bad things for people running with
4k stacks...

Thanks to Tilman Schmidt for tracking this down.

Cc: Tilman Schmidt <tilman@imap.cc>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 dc87c398
...@@ -252,7 +252,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr, ...@@ -252,7 +252,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
struct kobject *top_kobj; struct kobject *top_kobj;
struct kset *kset; struct kset *kset;
char *envp[32]; char *envp[32];
char data[PAGE_SIZE]; char *data = NULL;
char *pos; char *pos;
int i; int i;
size_t count = 0; size_t count = 0;
...@@ -276,6 +276,10 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr, ...@@ -276,6 +276,10 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
if (!kset->uevent_ops->filter(kset, &dev->kobj)) if (!kset->uevent_ops->filter(kset, &dev->kobj))
goto out; goto out;
data = (char *)get_zeroed_page(GFP_KERNEL);
if (!data)
return -ENOMEM;
/* let the kset specific function add its keys */ /* let the kset specific function add its keys */
pos = data; pos = data;
retval = kset->uevent_ops->uevent(kset, &dev->kobj, retval = kset->uevent_ops->uevent(kset, &dev->kobj,
...@@ -290,6 +294,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr, ...@@ -290,6 +294,7 @@ static ssize_t show_uevent(struct device *dev, struct device_attribute *attr,
count += sprintf(pos, "%s\n", envp[i]); count += sprintf(pos, "%s\n", envp[i]);
} }
out: out:
free_page((unsigned long)data);
return count; return count;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册