Lines Matching +full:min +full:- +full:len
1 // SPDX-License-Identifier: GPL-2.0-only
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
85 const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 };
106 * enum sysctl_writes_mode - supported sysctl write modes
125 SYSCTL_WRITES_LEGACY = -1,
149 size_t len; in _proc_do_string() local
160 len = strlen(data); in _proc_do_string()
161 if (len > maxlen - 1) in _proc_do_string()
162 len = maxlen - 1; in _proc_do_string()
164 if (*ppos > len) in _proc_do_string()
166 len = *ppos; in _proc_do_string()
169 len = 0; in _proc_do_string()
174 while ((p - buffer) < *lenp && len < maxlen - 1) { in _proc_do_string()
178 data[len++] = c; in _proc_do_string()
180 data[len] = 0; in _proc_do_string()
182 len = strlen(data); in _proc_do_string()
183 if (len > maxlen) in _proc_do_string()
184 len = maxlen; in _proc_do_string()
186 if (*ppos > len) { in _proc_do_string()
192 len -= *ppos; in _proc_do_string()
194 if (len > *lenp) in _proc_do_string()
195 len = *lenp; in _proc_do_string()
196 if (len) in _proc_do_string()
197 memcpy(buffer, data, len); in _proc_do_string()
198 if (len < *lenp) { in _proc_do_string()
199 buffer[len] = '\n'; in _proc_do_string()
200 len++; in _proc_do_string()
202 *lenp = len; in _proc_do_string()
203 *ppos += len; in _proc_do_string()
212 "warning, set kernel.sysctl_writes_strict = -1\n", in warn_sysctl_write()
213 current->comm, table->procname); in warn_sysctl_write()
217 * proc_first_pos_non_zero_ignore - check if first position is allowed
221 * Returns true if the first position is non-zero and the sysctl_writes_strict
243 * proc_dostring - read a string sysctl
252 * string is truncated. The copied string is %NULL-terminated.
265 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp, in proc_dostring()
274 (*size)--; in proc_skip_spaces()
284 (*size)--; in proc_skip_char()
290 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
313 return -ERANGE; in strtoul_lenient()
326 * proc_get_long - reads an ASCII formatted integer from a user buffer
337 * the amount of bytes read. If @tr is non-NULL and a trailing
338 * character exists (size is non-zero after returning from this
346 ssize_t len = *size; in proc_get_long() local
348 if (len <= 0) in proc_get_long()
349 return -EINVAL; in proc_get_long()
351 if (len > TMPBUFLEN - 1) in proc_get_long()
352 len = TMPBUFLEN - 1; in proc_get_long()
354 memcpy(tmp, *buf, len); in proc_get_long()
356 tmp[len] = 0; in proc_get_long()
358 if (*p == '-' && *size > 1) { in proc_get_long()
364 return -EINVAL; in proc_get_long()
367 return -EINVAL; in proc_get_long()
369 len = p - tmp; in proc_get_long()
374 if (len == TMPBUFLEN - 1) in proc_get_long()
375 return -EINVAL; in proc_get_long()
377 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) in proc_get_long()
378 return -EINVAL; in proc_get_long()
380 if (tr && (len < *size)) in proc_get_long()
383 *buf += len; in proc_get_long()
384 *size -= len; in proc_get_long()
390 * proc_put_long - converts an integer to a decimal ASCII formatted string
402 int len; in proc_put_long() local
405 sprintf(p, "%s%lu", neg ? "-" : "", val); in proc_put_long()
406 len = strlen(tmp); in proc_put_long()
407 if (len > *size) in proc_put_long()
408 len = *size; in proc_put_long()
409 memcpy(*buf, tmp, len); in proc_put_long()
410 *size -= len; in proc_put_long()
411 *buf += len; in proc_put_long()
421 (*size)--; in proc_put_char()
434 return -EINVAL; in do_proc_dointvec_conv()
435 WRITE_ONCE(*valp, -*lvalp); in do_proc_dointvec_conv()
438 return -EINVAL; in do_proc_dointvec_conv()
445 *lvalp = -(unsigned long)val; in do_proc_dointvec_conv()
460 return -EINVAL; in do_proc_douintvec_conv()
482 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { in __do_proc_dointvec()
488 vleft = table->maxlen / sizeof(*i); in __do_proc_dointvec()
498 if (left > PAGE_SIZE - 1) in __do_proc_dointvec()
499 left = PAGE_SIZE - 1; in __do_proc_dointvec()
503 for (; left && vleft--; i++, first=0) { in __do_proc_dointvec()
518 err = -EINVAL; in __do_proc_dointvec()
523 err = -EINVAL; in __do_proc_dointvec()
537 return err ? : -EINVAL; in __do_proc_dointvec()
538 *lenp -= left; in __do_proc_dointvec()
550 return __do_proc_dointvec(table->data, table, write, in do_proc_dointvec()
574 if (left > PAGE_SIZE - 1) in do_proc_douintvec_w()
575 left = PAGE_SIZE - 1; in do_proc_douintvec_w()
579 err = -EINVAL; in do_proc_douintvec_w()
587 err = -EINVAL; in do_proc_douintvec_w()
592 err = -EINVAL; in do_proc_douintvec_w()
601 return -EINVAL; in do_proc_douintvec_w()
625 err = -EINVAL; in do_proc_douintvec_r()
636 *lenp -= left; in do_proc_douintvec_r()
652 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { in __do_proc_douintvec()
658 vleft = table->maxlen / sizeof(*i); in __do_proc_douintvec()
666 return -EINVAL; in __do_proc_douintvec()
685 return __do_proc_douintvec(table->data, table, write, in do_proc_douintvec()
690 * proc_dobool - read/write a bool
700 * table->data must point to a bool variable and table->maxlen must
709 bool *data = table->data; in proc_dobool()
713 if (table->maxlen != sizeof(bool)) in proc_dobool()
714 return -EINVAL; in proc_dobool()
730 * proc_dointvec - read a vector of integers
737 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
749 * proc_douintvec - read a vector of unsigned integers
756 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
780 return -EPERM; in proc_taint()
797 return -EINVAL; in proc_taint()
812 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
813 * @min: pointer to minimum allowable value
821 int *min; member
833 * bounds-check it before touching *valp. in do_proc_dointvec_minmax_conv()
842 if ((param->min && *param->min > tmp) || in do_proc_dointvec_minmax_conv()
843 (param->max && *param->max < tmp)) in do_proc_dointvec_minmax_conv()
844 return -EINVAL; in do_proc_dointvec_minmax_conv()
852 * proc_dointvec_minmax - read a vector of integers with min/max values
859 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
863 * table->extra1 (min) and table->extra2 (max).
865 * Returns 0 on success or -EINVAL on write when the range check fails.
871 .min = (int *) table->extra1, in proc_dointvec_minmax()
872 .max = (int *) table->extra2, in proc_dointvec_minmax()
879 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
880 * @min: pointer to minimum allowable value
888 unsigned int *min; member
899 /* write via temporary local uint for bounds-checking */ in do_proc_douintvec_minmax_conv()
907 if ((param->min && *param->min > tmp) || in do_proc_douintvec_minmax_conv()
908 (param->max && *param->max < tmp)) in do_proc_douintvec_minmax_conv()
909 return -ERANGE; in do_proc_douintvec_minmax_conv()
918 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
925 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
930 * table->extra1 (min) and table->extra2 (max). There is a final sanity
934 * Returns 0 on success or -ERANGE on write when the range check fails.
940 .min = (unsigned int *) table->extra1, in proc_douintvec_minmax()
941 .max = (unsigned int *) table->extra2, in proc_douintvec_minmax()
948 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
955 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
960 * table->extra1 (min) and table->extra2 (max).
968 unsigned int min = 0, max = 255U, val; in proc_dou8vec_minmax() local
969 u8 *data = table->data; in proc_dou8vec_minmax()
971 .min = &min, in proc_dou8vec_minmax()
977 if (table->maxlen != sizeof(u8)) in proc_dou8vec_minmax()
978 return -EINVAL; in proc_dou8vec_minmax()
980 if (table->extra1) in proc_dou8vec_minmax()
981 min = *(unsigned int *) table->extra1; in proc_dou8vec_minmax()
982 if (table->extra2) in proc_dou8vec_minmax()
983 max = *(unsigned int *) table->extra2; in proc_dou8vec_minmax()
1025 unsigned long *i, *min, *max; in __do_proc_doulongvec_minmax() local
1030 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { in __do_proc_doulongvec_minmax()
1036 min = table->extra1; in __do_proc_doulongvec_minmax()
1037 max = table->extra2; in __do_proc_doulongvec_minmax()
1038 vleft = table->maxlen / sizeof(unsigned long); in __do_proc_doulongvec_minmax()
1045 if (left > PAGE_SIZE - 1) in __do_proc_doulongvec_minmax()
1046 left = PAGE_SIZE - 1; in __do_proc_doulongvec_minmax()
1050 for (; left && vleft--; i++, first = 0) { in __do_proc_doulongvec_minmax()
1064 err = -EINVAL; in __do_proc_doulongvec_minmax()
1069 if ((min && val < *min) || (max && val > *max)) { in __do_proc_doulongvec_minmax()
1070 err = -EINVAL; in __do_proc_doulongvec_minmax()
1087 return err ? : -EINVAL; in __do_proc_doulongvec_minmax()
1088 *lenp -= left; in __do_proc_doulongvec_minmax()
1098 return __do_proc_doulongvec_minmax(table->data, table, write, in do_proc_doulongvec_minmax()
1103 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1110 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1114 * table->extra1 (min) and table->extra2 (max).
1125 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1132 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1137 * table->extra1 (min) and table->extra2 (max).
1157 WRITE_ONCE(*valp, -*lvalp * HZ); in do_proc_dointvec_jiffies_conv()
1165 lval = -(unsigned long)val; in do_proc_dointvec_jiffies_conv()
1182 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); in do_proc_dointvec_userhz_jiffies_conv()
1188 lval = -(unsigned long)val; in do_proc_dointvec_userhz_jiffies_conv()
1203 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); in do_proc_dointvec_ms_jiffies_conv()
1213 lval = -(unsigned long)val; in do_proc_dointvec_ms_jiffies_conv()
1230 * bounds-check it before touching *valp. in do_proc_dointvec_ms_jiffies_minmax_conv()
1239 if ((param->min && *param->min > tmp) || in do_proc_dointvec_ms_jiffies_minmax_conv()
1240 (param->max && *param->max < tmp)) in do_proc_dointvec_ms_jiffies_minmax_conv()
1241 return -EINVAL; in do_proc_dointvec_ms_jiffies_minmax_conv()
1248 * proc_dointvec_jiffies - read a vector of integers as seconds
1255 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1273 .min = (int *) table->extra1, in proc_dointvec_ms_jiffies_minmax()
1274 .max = (int *) table->extra2, in proc_dointvec_ms_jiffies_minmax()
1281 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1288 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1303 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1310 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1340 return -ESRCH; in proc_do_cad_pid()
1347 * proc_do_large_bitmap - read/write from/to a large bitmap
1354 * The bitmap is stored at table->data and the bitmap length (in bits)
1355 * in table->maxlen.
1357 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1368 unsigned long bitmap_len = table->maxlen; in proc_do_large_bitmap()
1369 unsigned long *bitmap = *(unsigned long **) table->data; in proc_do_large_bitmap()
1371 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; in proc_do_large_bitmap()
1382 if (left > PAGE_SIZE - 1) { in proc_do_large_bitmap()
1383 left = PAGE_SIZE - 1; in proc_do_large_bitmap()
1385 skipped = *lenp - left; in proc_do_large_bitmap()
1390 return -ENOMEM; in proc_do_large_bitmap()
1397 /* In case we stop parsing mid-number, we can reset */ in proc_do_large_bitmap()
1403 * only one char is left (may be a "-"), then stop here, in proc_do_large_bitmap()
1414 err = -EINVAL; in proc_do_large_bitmap()
1421 left--; in proc_do_large_bitmap()
1424 if (c == '-') { in proc_do_large_bitmap()
1441 err = -EINVAL; in proc_do_large_bitmap()
1446 left--; in proc_do_large_bitmap()
1450 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); in proc_do_large_bitmap()
1463 bit_a + 1) - 1; in proc_do_large_bitmap()
1469 proc_put_char(&buffer, &left, '-'); in proc_do_large_bitmap()
1485 *lenp -= left; in proc_do_large_bitmap()
1498 return -ENOSYS; in proc_dostring()
1504 return -ENOSYS; in proc_dobool()
1510 return -ENOSYS; in proc_dointvec()
1516 return -ENOSYS; in proc_douintvec()
1522 return -ENOSYS; in proc_dointvec_minmax()
1528 return -ENOSYS; in proc_douintvec_minmax()
1534 return -ENOSYS; in proc_dou8vec_minmax()
1540 return -ENOSYS; in proc_dointvec_jiffies()
1546 return -ENOSYS; in proc_dointvec_ms_jiffies_minmax()
1552 return -ENOSYS; in proc_dointvec_userhz_jiffies()
1558 return -ENOSYS; in proc_dointvec_ms_jiffies()
1564 return -ENOSYS; in proc_doulongvec_minmax()
1570 return -ENOSYS; in proc_doulongvec_ms_jiffies_minmax()
1576 return -ENOSYS; in proc_do_large_bitmap()
1585 struct static_key *key = (struct static_key *)table->data; in proc_do_static_key()
1591 .mode = table->mode, in proc_do_static_key()
1597 return -EPERM; in proc_do_static_key()
1638 .procname = "print-fatal-signals",
1646 .procname = "reboot-cmd",
1653 .procname = "stop-a",
1660 .procname = "scons-poweroff",
1669 .procname = "tsb-ratio",
1678 .procname = "soft-power",
1687 .procname = "unaligned-trap",
1773 .procname = "threads-max",
1920 .procname = "ignore-unaligned-usertrap",
1938 * User-space scripts rely on the existence of this file
2049 .procname = "page-cluster",
2239 * exception granted :-)