Commit 07bba9c3 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Add missing uacccess checks for sysctl.c

From: Marc-Christian Petersen <m.c.p@wolk-project.de>

Kernel 2.6 lacks two -EFAULT returns in get_user() in kernel/sysctl.c.
parent d21db956
...@@ -1004,7 +1004,8 @@ int do_sysctl_strategy (ctl_table *table, ...@@ -1004,7 +1004,8 @@ int do_sysctl_strategy (ctl_table *table,
* zero, proceed with automatic r/w */ * zero, proceed with automatic r/w */
if (table->data && table->maxlen) { if (table->data && table->maxlen) {
if (oldval && oldlenp) { if (oldval && oldlenp) {
get_user(len, oldlenp); if (get_user(len, oldlenp))
return -EFAULT;
if (len) { if (len) {
if (len > table->maxlen) if (len > table->maxlen)
len = table->maxlen; len = table->maxlen;
...@@ -1303,7 +1304,7 @@ int proc_dostring(ctl_table *table, int write, struct file *filp, ...@@ -1303,7 +1304,7 @@ int proc_dostring(ctl_table *table, int write, struct file *filp,
len = 0; len = 0;
p = buffer; p = buffer;
while (len < *lenp) { while (len < *lenp) {
if(get_user(c, p++)) if (get_user(c, p++))
return -EFAULT; return -EFAULT;
if (c == 0 || c == '\n') if (c == 0 || c == '\n')
break; break;
...@@ -1470,7 +1471,7 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, ...@@ -1470,7 +1471,7 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
p = (char *) buffer; p = (char *) buffer;
while (left) { while (left) {
char c; char c;
if(get_user(c, p++)) if (get_user(c, p++))
return -EFAULT; return -EFAULT;
if (!isspace(c)) if (!isspace(c))
break; break;
...@@ -1705,7 +1706,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write, ...@@ -1705,7 +1706,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write,
p = (char *) buffer; p = (char *) buffer;
while (left) { while (left) {
char c; char c;
if(get_user(c, p++)) if (get_user(c, p++))
return -EFAULT; return -EFAULT;
if (!isspace(c)) if (!isspace(c))
break; break;
...@@ -1930,7 +1931,7 @@ int sysctl_string(ctl_table *table, int __user *name, int nlen, ...@@ -1930,7 +1931,7 @@ int sysctl_string(ctl_table *table, int __user *name, int nlen,
return -ENOTDIR; return -ENOTDIR;
if (oldval && oldlenp) { if (oldval && oldlenp) {
if(get_user(len, oldlenp)) if (get_user(len, oldlenp))
return -EFAULT; return -EFAULT;
if (len) { if (len) {
l = strlen(table->data); l = strlen(table->data);
...@@ -1987,7 +1988,8 @@ int sysctl_intvec(ctl_table *table, int __user *name, int nlen, ...@@ -1987,7 +1988,8 @@ int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {
int value; int value;
get_user(value, vec + i); if (get_user(value, vec + i))
return -EFAULT;
if (min && value < min[i]) if (min && value < min[i])
return -EINVAL; return -EINVAL;
if (max && value > max[i]) if (max && value > max[i])
......
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