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,
vleft = table->maxlen / sizeof(int);
left = *lenp;
for (; left && vleft--; i++, first=0) {
for (; left && vleft--; i++, min++, max++, first=0) {
if (write) {
while (left) {
char c;
......@@ -1007,9 +1007,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
buffer += len;
left -= len;
if (min && val < *min++)
continue;
if (max && val > *max++)
if ((min && val < *min) || (max && val > *max))
continue;
*i = val;
} else {
......@@ -1074,7 +1072,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write,
vleft = table->maxlen / sizeof(unsigned long);
left = *lenp;
for (; left && vleft--; i++, first=0) {
for (; left && vleft--; i++, min++, max++, first=0) {
if (write) {
while (left) {
char c;
......@@ -1112,9 +1110,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write,
if(neg)
continue;
if (min && val < *min++)
continue;
if (max && val > *max++)
if ((min && val < *min) || (max && val > *max))
continue;
*i = val;
} 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