Commit 61a0bc0f authored by Ken Cox's avatar Ken Cox Committed by Greg Kroah-Hartman

Staging: unisys: Fix multiple variable length array declarations

There were multiple variable length arrays declared on the stack in proc
handlers:
	char buf[count];

I changed these to be fixed length arrays.
Signed-off-by: default avatarKen Cox <jkc@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 56df0122
...@@ -1509,9 +1509,12 @@ vnic_proc_write(struct file *file, const char __user *buffer, ...@@ -1509,9 +1509,12 @@ vnic_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
int action = 0xffff, busNo = 0, i, result = 0; int action = 0xffff, busNo = 0, i, result = 0;
char buf[count]; char buf[4];
char direction; char direction;
/* GUID guid; */ /* GUID guid; */
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
if (copy_from_user(buf, buffer, count)) { if (copy_from_user(buf, buffer, count)) {
LOGERR("echo > /proc/uislib/vnic copy_from_user ****FAILED.\n"); LOGERR("echo > /proc/uislib/vnic copy_from_user ****FAILED.\n");
return -EFAULT; return -EFAULT;
...@@ -1566,9 +1569,12 @@ chipset_proc_write(struct file *file, const char __user *buffer, ...@@ -1566,9 +1569,12 @@ chipset_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
int i, action = 0xffff; int i, action = 0xffff;
char buf[count]; char buf[4];
CONTROLVM_MESSAGE msg; CONTROLVM_MESSAGE msg;
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
memset(&msg, 0, sizeof(CONTROLVM_MESSAGE)); memset(&msg, 0, sizeof(CONTROLVM_MESSAGE));
if (copy_from_user(buf, buffer, count)) { if (copy_from_user(buf, buffer, count)) {
...@@ -1811,10 +1817,13 @@ bus_proc_write(struct file *file, const char __user *buffer, ...@@ -1811,10 +1817,13 @@ bus_proc_write(struct file *file, const char __user *buffer,
{ {
int server_flag = 0; int server_flag = 0;
int i, action = 0xffff, result; int i, action = 0xffff, result;
char buf[count]; char buf[16];
CONTROLVM_MESSAGE msg; CONTROLVM_MESSAGE msg;
U32 busNo, deviceCount; U32 busNo, deviceCount;
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
memset(&msg, 0, sizeof(CONTROLVM_MESSAGE)); memset(&msg, 0, sizeof(CONTROLVM_MESSAGE));
if (copy_from_user(buf, buffer, count)) { if (copy_from_user(buf, buffer, count)) {
...@@ -1892,10 +1901,13 @@ dev_proc_write(struct file *file, const char __user *buffer, ...@@ -1892,10 +1901,13 @@ dev_proc_write(struct file *file, const char __user *buffer,
int server_flag = 0; int server_flag = 0;
CONTROLVM_MESSAGE msg; CONTROLVM_MESSAGE msg;
U32 busNo, devNo; U32 busNo, devNo;
char buf[count]; char buf[32];
unsigned int chanptr; unsigned int chanptr;
int type, i, action = 0xffff, result; int type, i, action = 0xffff, result;
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
if (copy_from_user(buf, buffer, count)) { if (copy_from_user(buf, buffer, count)) {
LOGERR("echo > /proc/uislib/device: copy_from_user ****FAILED."); LOGERR("echo > /proc/uislib/device: copy_from_user ****FAILED.");
return -EFAULT; return -EFAULT;
...@@ -1985,7 +1997,7 @@ static ssize_t ...@@ -1985,7 +1997,7 @@ static ssize_t
cycles_before_wait_proc_write(struct file *file, const char __user *buffer, cycles_before_wait_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char buf[count]; char buf[16];
#define CYCLES_BEFORE_WAIT_USE_ERROR { \ #define CYCLES_BEFORE_WAIT_USE_ERROR { \
LOGERR("Incorrect Call Home Input.\n"); \ LOGERR("Incorrect Call Home Input.\n"); \
...@@ -1993,6 +2005,8 @@ cycles_before_wait_proc_write(struct file *file, const char __user *buffer, ...@@ -1993,6 +2005,8 @@ cycles_before_wait_proc_write(struct file *file, const char __user *buffer,
pr_info("EventID Category Type[parameter1][parameter2][parameter3][parameter4][parameter5][parameter6]\n"); \ pr_info("EventID Category Type[parameter1][parameter2][parameter3][parameter4][parameter5][parameter6]\n"); \
return -EFAULT; \ return -EFAULT; \
} }
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
if (count == 0) if (count == 0)
CYCLES_BEFORE_WAIT_USE_ERROR; CYCLES_BEFORE_WAIT_USE_ERROR;
...@@ -2014,7 +2028,7 @@ static ssize_t ...@@ -2014,7 +2028,7 @@ static ssize_t
reset_counts_proc_write(struct file *file, const char __user *buffer, reset_counts_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char buf[count]; char buf[16];
unsigned long long new_value; unsigned long long new_value;
struct bus_info *bus; struct bus_info *bus;
int i; int i;
...@@ -2026,6 +2040,9 @@ reset_counts_proc_write(struct file *file, const char __user *buffer, ...@@ -2026,6 +2040,9 @@ reset_counts_proc_write(struct file *file, const char __user *buffer,
return -EFAULT; \ return -EFAULT; \
} }
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
if (count == 0) if (count == 0)
RESET_COUNTS_USE_ERROR; RESET_COUNTS_USE_ERROR;
...@@ -2061,7 +2078,7 @@ static ssize_t ...@@ -2061,7 +2078,7 @@ static ssize_t
smart_wakeup_proc_write(struct file *file, const char __user *buffer, smart_wakeup_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char buf[count]; char buf[16];
int new_value; int new_value;
#define SMART_WAKEUP_USE_ERROR { \ #define SMART_WAKEUP_USE_ERROR { \
...@@ -2071,6 +2088,9 @@ smart_wakeup_proc_write(struct file *file, const char __user *buffer, ...@@ -2071,6 +2088,9 @@ smart_wakeup_proc_write(struct file *file, const char __user *buffer,
return -EFAULT; \ return -EFAULT; \
} }
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
if (count == 0) if (count == 0)
SMART_WAKEUP_USE_ERROR; SMART_WAKEUP_USE_ERROR;
...@@ -2092,10 +2112,13 @@ test_proc_write(struct file *file, const char __user *buffer, ...@@ -2092,10 +2112,13 @@ test_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
int i, action = 0xffff; int i, action = 0xffff;
char buf[count]; char buf[16];
CONTROLVM_MESSAGE msg; CONTROLVM_MESSAGE msg;
S64 vrtc_offset; S64 vrtc_offset;
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
memset(&msg, 0, sizeof(CONTROLVM_MESSAGE)); memset(&msg, 0, sizeof(CONTROLVM_MESSAGE));
if (copy_from_user(buf, buffer, count)) { if (copy_from_user(buf, buffer, count)) {
......
...@@ -1493,9 +1493,12 @@ static ssize_t ...@@ -1493,9 +1493,12 @@ static ssize_t
rqwu_proc_write(struct file *file, const char __user *buffer, rqwu_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char buf[count]; char buf[16];
int i, usecs; int i, usecs;
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
if (copy_from_user(buf, buffer, count)) { if (copy_from_user(buf, buffer, count)) {
LOGERR("copy_from_user failed. buf<<%.*s>> count<<%lu>>\n", LOGERR("copy_from_user failed. buf<<%.*s>> count<<%lu>>\n",
(int) count, buf, count); (int) count, buf, count);
......
...@@ -1488,7 +1488,7 @@ static ssize_t info_proc_read(struct file *file, char __user *buf, ...@@ -1488,7 +1488,7 @@ static ssize_t info_proc_read(struct file *file, char __user *buf,
static ssize_t virt_proc_write(struct file *file, const char __user *buffer, static ssize_t virt_proc_write(struct file *file, const char __user *buffer,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
char buf[count]; char buf[16];
int type, i, action = 0xffff; int type, i, action = 0xffff;
unsigned int busno, deviceno; unsigned int busno, deviceno;
void *chanptr; void *chanptr;
...@@ -1518,6 +1518,9 @@ static ssize_t virt_proc_write(struct file *file, const char __user *buffer, ...@@ -1518,6 +1518,9 @@ static ssize_t virt_proc_write(struct file *file, const char __user *buffer,
return -EINVAL; \ return -EINVAL; \
} }
if (count >= ARRAY_SIZE(buf))
return -EINVAL;
if (copy_from_user(buf, buffer, count)) { if (copy_from_user(buf, buffer, count)) {
LOGERR("copy_from_user failed.\n"); LOGERR("copy_from_user failed.\n");
return -EFAULT; return -EFAULT;
......
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