Commit d0f3b7fd authored by Kazuto Miyoshi's avatar Kazuto Miyoshi Committed by Linus Torvalds

[PATCH] fix for /proc operation:

  I found that 'max' pointer is not updated in proc_dointvec_minmax()
  and proc_doulongvec_minmax(), when I write smaller values than min to
  /proc/sys entry (and val<*min++ check becomes true.)
  This may lead to min/max checking of values with bogus maximum.
parent c4023a9c
...@@ -971,7 +971,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, ...@@ -971,7 +971,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
vleft = table->maxlen / sizeof(int); vleft = table->maxlen / sizeof(int);
left = *lenp; left = *lenp;
for (; left && vleft--; i++, first=0) { for (; left && vleft--; i++, min++, max++, first=0) {
if (write) { if (write) {
while (left) { while (left) {
char c; char c;
...@@ -1007,9 +1007,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, ...@@ -1007,9 +1007,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
buffer += len; buffer += len;
left -= len; left -= len;
if (min && val < *min++) if ((min && val < *min) || (max && val > *max))
continue;
if (max && val > *max++)
continue; continue;
*i = val; *i = val;
} else { } else {
...@@ -1074,7 +1072,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write, ...@@ -1074,7 +1072,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write,
vleft = table->maxlen / sizeof(unsigned long); vleft = table->maxlen / sizeof(unsigned long);
left = *lenp; left = *lenp;
for (; left && vleft--; i++, first=0) { for (; left && vleft--; i++, min++, max++, first=0) {
if (write) { if (write) {
while (left) { while (left) {
char c; char c;
...@@ -1112,9 +1110,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write, ...@@ -1112,9 +1110,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write,
if(neg) if(neg)
continue; continue;
if (min && val < *min++) if ((min && val < *min) || (max && val > *max))
continue;
if (max && val > *max++)
continue; continue;
*i = val; *i = val;
} else { } else {
......
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