Commit e4258d55 authored by Stefan Weinhuber's avatar Stefan Weinhuber Committed by Heiko Carstens

[S390] dasd: use vmalloc for statistics input buffer

The size of the buffer that is used to store DASD statistics input
strings depends on the user input. If the input string is to large,
the write operation could fail with -ENOMEM. To avoid this, use
vmalloc instead of kmalloc.
Signed-off-by: default avatarStefan Weinhuber <wein@de.ibm.com>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
parent 7dd6b334
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/debugfs.h> #include <linux/debugfs.h>
#include <linux/seq_file.h> #include <linux/seq_file.h>
#include <linux/vmalloc.h>
#include <asm/ccwdev.h> #include <asm/ccwdev.h>
#include <asm/ebcdic.h> #include <asm/ebcdic.h>
...@@ -888,11 +889,11 @@ char *dasd_get_user_string(const char __user *user_buf, size_t user_len) ...@@ -888,11 +889,11 @@ char *dasd_get_user_string(const char __user *user_buf, size_t user_len)
{ {
char *buffer; char *buffer;
buffer = kmalloc(user_len + 1, GFP_KERNEL); buffer = vmalloc(user_len + 1);
if (buffer == NULL) if (buffer == NULL)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
if (copy_from_user(buffer, user_buf, user_len) != 0) { if (copy_from_user(buffer, user_buf, user_len) != 0) {
kfree(buffer); vfree(buffer);
return ERR_PTR(-EFAULT); return ERR_PTR(-EFAULT);
} }
/* got the string, now strip linefeed. */ /* got the string, now strip linefeed. */
...@@ -930,7 +931,7 @@ static ssize_t dasd_stats_write(struct file *file, ...@@ -930,7 +931,7 @@ static ssize_t dasd_stats_write(struct file *file,
dasd_profile_off(prof); dasd_profile_off(prof);
} else } else
rc = -EINVAL; rc = -EINVAL;
kfree(buffer); vfree(buffer);
return rc; return rc;
} }
...@@ -1042,7 +1043,7 @@ static ssize_t dasd_stats_global_write(struct file *file, ...@@ -1042,7 +1043,7 @@ static ssize_t dasd_stats_global_write(struct file *file,
dasd_global_profile_level = DASD_PROFILE_OFF; dasd_global_profile_level = DASD_PROFILE_OFF;
} else } else
rc = -EINVAL; rc = -EINVAL;
kfree(buffer); vfree(buffer);
return rc; return rc;
} }
......
...@@ -312,14 +312,14 @@ static ssize_t dasd_stats_proc_write(struct file *file, ...@@ -312,14 +312,14 @@ static ssize_t dasd_stats_proc_write(struct file *file,
pr_info("The statistics have been reset\n"); pr_info("The statistics have been reset\n");
} else } else
goto out_parse_error; goto out_parse_error;
kfree(buffer); vfree(buffer);
return user_len; return user_len;
out_parse_error: out_parse_error:
rc = -EINVAL; rc = -EINVAL;
pr_warning("%s is not a supported value for /proc/dasd/statistics\n", pr_warning("%s is not a supported value for /proc/dasd/statistics\n",
str); str);
out_error: out_error:
kfree(buffer); vfree(buffer);
return rc; return rc;
#else #else
pr_warning("/proc/dasd/statistics: is not activated in this kernel\n"); pr_warning("/proc/dasd/statistics: is not activated in this kernel\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment