aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorStefan Weinhuber <wein@de.ibm.com>2011-08-03 10:44:20 -0400
committerHeiko Carstens <heiko.carstens@de.ibm.com>2011-08-03 10:44:19 -0400
commite4258d55bff06780cd424c671b576a90acc1592f (patch)
treea8a7da35bff7d9379678ba8f59f512f12681f768 /drivers/s390
parent7dd6b3343fdc190712d1620ee8848d25c4c77c33 (diff)
[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: Stefan Weinhuber <wein@de.ibm.com> Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/block/dasd.c9
-rw-r--r--drivers/s390/block/dasd_proc.c4
2 files changed, 7 insertions, 6 deletions
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 432444af7ee4..a1d3ddba99cc 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -24,6 +24,7 @@
24#include <linux/mutex.h> 24#include <linux/mutex.h>
25#include <linux/debugfs.h> 25#include <linux/debugfs.h>
26#include <linux/seq_file.h> 26#include <linux/seq_file.h>
27#include <linux/vmalloc.h>
27 28
28#include <asm/ccwdev.h> 29#include <asm/ccwdev.h>
29#include <asm/ebcdic.h> 30#include <asm/ebcdic.h>
@@ -888,11 +889,11 @@ char *dasd_get_user_string(const char __user *user_buf, size_t user_len)
888{ 889{
889 char *buffer; 890 char *buffer;
890 891
891 buffer = kmalloc(user_len + 1, GFP_KERNEL); 892 buffer = vmalloc(user_len + 1);
892 if (buffer == NULL) 893 if (buffer == NULL)
893 return ERR_PTR(-ENOMEM); 894 return ERR_PTR(-ENOMEM);
894 if (copy_from_user(buffer, user_buf, user_len) != 0) { 895 if (copy_from_user(buffer, user_buf, user_len) != 0) {
895 kfree(buffer); 896 vfree(buffer);
896 return ERR_PTR(-EFAULT); 897 return ERR_PTR(-EFAULT);
897 } 898 }
898 /* got the string, now strip linefeed. */ 899 /* got the string, now strip linefeed. */
@@ -930,7 +931,7 @@ static ssize_t dasd_stats_write(struct file *file,
930 dasd_profile_off(prof); 931 dasd_profile_off(prof);
931 } else 932 } else
932 rc = -EINVAL; 933 rc = -EINVAL;
933 kfree(buffer); 934 vfree(buffer);
934 return rc; 935 return rc;
935} 936}
936 937
@@ -1042,7 +1043,7 @@ static ssize_t dasd_stats_global_write(struct file *file,
1042 dasd_global_profile_level = DASD_PROFILE_OFF; 1043 dasd_global_profile_level = DASD_PROFILE_OFF;
1043 } else 1044 } else
1044 rc = -EINVAL; 1045 rc = -EINVAL;
1045 kfree(buffer); 1046 vfree(buffer);
1046 return rc; 1047 return rc;
1047} 1048}
1048 1049
diff --git a/drivers/s390/block/dasd_proc.c b/drivers/s390/block/dasd_proc.c
index 6c3c5364d082..e12989fff4ff 100644
--- a/drivers/s390/block/dasd_proc.c
+++ b/drivers/s390/block/dasd_proc.c
@@ -312,14 +312,14 @@ static ssize_t dasd_stats_proc_write(struct file *file,
312 pr_info("The statistics have been reset\n"); 312 pr_info("The statistics have been reset\n");
313 } else 313 } else
314 goto out_parse_error; 314 goto out_parse_error;
315 kfree(buffer); 315 vfree(buffer);
316 return user_len; 316 return user_len;
317out_parse_error: 317out_parse_error:
318 rc = -EINVAL; 318 rc = -EINVAL;
319 pr_warning("%s is not a supported value for /proc/dasd/statistics\n", 319 pr_warning("%s is not a supported value for /proc/dasd/statistics\n",
320 str); 320 str);
321out_error: 321out_error:
322 kfree(buffer); 322 vfree(buffer);
323 return rc; 323 return rc;
324#else 324#else
325 pr_warning("/proc/dasd/statistics: is not activated in this kernel\n"); 325 pr_warning("/proc/dasd/statistics: is not activated in this kernel\n");