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.
75 const int sysctl_vals[] = { 0, 1, 2, 3, 4, 100, 200, 1000, 3000, INT_MAX, 65535, -1 };
90 * enum sysctl_writes_mode - supported sysctl write modes
109 SYSCTL_WRITES_LEGACY = -1,
127 size_t len; in _proc_do_string() local
138 len = strlen(data); in _proc_do_string()
139 if (len > maxlen - 1) in _proc_do_string()
140 len = maxlen - 1; in _proc_do_string()
142 if (*ppos > len) in _proc_do_string()
144 len = *ppos; in _proc_do_string()
147 len = 0; in _proc_do_string()
152 while ((p - buffer) < *lenp && len < maxlen - 1) { in _proc_do_string()
156 data[len++] = c; in _proc_do_string()
158 data[len] = 0; in _proc_do_string()
160 len = strlen(data); in _proc_do_string()
161 if (len > maxlen) in _proc_do_string()
162 len = maxlen; in _proc_do_string()
164 if (*ppos > len) { in _proc_do_string()
170 len -= *ppos; in _proc_do_string()
172 if (len > *lenp) in _proc_do_string()
173 len = *lenp; in _proc_do_string()
174 if (len) in _proc_do_string()
175 memcpy(buffer, data, len); in _proc_do_string()
176 if (len < *lenp) { in _proc_do_string()
177 buffer[len] = '\n'; in _proc_do_string()
178 len++; in _proc_do_string()
180 *lenp = len; in _proc_do_string()
181 *ppos += len; in _proc_do_string()
190 "warning, set kernel.sysctl_writes_strict = -1\n", in warn_sysctl_write()
191 current->comm, table->procname); in warn_sysctl_write()
195 * proc_first_pos_non_zero_ignore - check if first position is allowed
199 * Returns true if the first position is non-zero and the sysctl_writes_strict
221 * proc_dostring - read a string sysctl
230 * string is truncated. The copied string is %NULL-terminated.
243 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp, in proc_dostring()
252 (*size)--; in proc_skip_spaces()
262 (*size)--; in proc_skip_char()
268 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
291 return -ERANGE; in strtoul_lenient()
304 * proc_get_long - reads an ASCII formatted integer from a user buffer
315 * the amount of bytes read. If @tr is non-NULL and a trailing
316 * character exists (size is non-zero after returning from this
324 ssize_t len = *size; in proc_get_long() local
326 if (len <= 0) in proc_get_long()
327 return -EINVAL; in proc_get_long()
329 if (len > TMPBUFLEN - 1) in proc_get_long()
330 len = TMPBUFLEN - 1; in proc_get_long()
332 memcpy(tmp, *buf, len); in proc_get_long()
334 tmp[len] = 0; in proc_get_long()
336 if (*p == '-' && *size > 1) { in proc_get_long()
342 return -EINVAL; in proc_get_long()
345 return -EINVAL; in proc_get_long()
347 len = p - tmp; in proc_get_long()
352 if (len == TMPBUFLEN - 1) in proc_get_long()
353 return -EINVAL; in proc_get_long()
355 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len)) in proc_get_long()
356 return -EINVAL; in proc_get_long()
358 if (tr && (len < *size)) in proc_get_long()
361 *buf += len; in proc_get_long()
362 *size -= len; in proc_get_long()
368 * proc_put_long - converts an integer to a decimal ASCII formatted string
380 int len; in proc_put_long() local
383 sprintf(p, "%s%lu", neg ? "-" : "", val); in proc_put_long()
384 len = strlen(tmp); in proc_put_long()
385 if (len > *size) in proc_put_long()
386 len = *size; in proc_put_long()
387 memcpy(*buf, tmp, len); in proc_put_long()
388 *size -= len; in proc_put_long()
389 *buf += len; in proc_put_long()
399 (*size)--; in proc_put_char()
412 return -EINVAL; in do_proc_dointvec_conv()
413 WRITE_ONCE(*valp, -*lvalp); in do_proc_dointvec_conv()
416 return -EINVAL; in do_proc_dointvec_conv()
423 *lvalp = -(unsigned long)val; in do_proc_dointvec_conv()
438 return -EINVAL; in do_proc_douintvec_conv()
460 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { in __do_proc_dointvec()
466 vleft = table->maxlen / sizeof(*i); in __do_proc_dointvec()
476 if (left > PAGE_SIZE - 1) in __do_proc_dointvec()
477 left = PAGE_SIZE - 1; in __do_proc_dointvec()
481 for (; left && vleft--; i++, first=0) { in __do_proc_dointvec()
496 err = -EINVAL; in __do_proc_dointvec()
501 err = -EINVAL; in __do_proc_dointvec()
515 return err ? : -EINVAL; in __do_proc_dointvec()
516 *lenp -= left; in __do_proc_dointvec()
528 return __do_proc_dointvec(table->data, table, write, in do_proc_dointvec()
552 if (left > PAGE_SIZE - 1) in do_proc_douintvec_w()
553 left = PAGE_SIZE - 1; in do_proc_douintvec_w()
557 err = -EINVAL; in do_proc_douintvec_w()
565 err = -EINVAL; in do_proc_douintvec_w()
570 err = -EINVAL; in do_proc_douintvec_w()
579 return -EINVAL; in do_proc_douintvec_w()
603 err = -EINVAL; in do_proc_douintvec_r()
614 *lenp -= left; in do_proc_douintvec_r()
630 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) { in __do_proc_douintvec()
636 vleft = table->maxlen / sizeof(*i); in __do_proc_douintvec()
644 return -EINVAL; in __do_proc_douintvec()
663 return __do_proc_douintvec(table->data, table, write, in do_proc_douintvec()
668 * proc_dobool - read/write a bool
678 * table->data must point to a bool variable and table->maxlen must
687 bool *data = table->data; in proc_dobool()
691 if (table->maxlen != sizeof(bool)) in proc_dobool()
692 return -EINVAL; in proc_dobool()
708 * proc_dointvec - read a vector of integers
715 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
727 * proc_douintvec - read a vector of unsigned integers
734 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
758 return -EPERM; in proc_taint()
775 return -EINVAL; in proc_taint()
790 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
791 * @min: pointer to minimum allowable value
799 int *min; member
811 * bounds-check it before touching *valp. in do_proc_dointvec_minmax_conv()
820 if ((param->min && *param->min > tmp) || in do_proc_dointvec_minmax_conv()
821 (param->max && *param->max < tmp)) in do_proc_dointvec_minmax_conv()
822 return -EINVAL; in do_proc_dointvec_minmax_conv()
830 * proc_dointvec_minmax - read a vector of integers with min/max values
837 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
841 * table->extra1 (min) and table->extra2 (max).
843 * Returns 0 on success or -EINVAL on write when the range check fails.
849 .min = (int *) table->extra1, in proc_dointvec_minmax()
850 .max = (int *) table->extra2, in proc_dointvec_minmax()
857 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
858 * @min: pointer to minimum allowable value
866 unsigned int *min; member
877 /* write via temporary local uint for bounds-checking */ in do_proc_douintvec_minmax_conv()
885 if ((param->min && *param->min > tmp) || in do_proc_douintvec_minmax_conv()
886 (param->max && *param->max < tmp)) in do_proc_douintvec_minmax_conv()
887 return -ERANGE; in do_proc_douintvec_minmax_conv()
896 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
903 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
908 * table->extra1 (min) and table->extra2 (max). There is a final sanity
912 * Returns 0 on success or -ERANGE on write when the range check fails.
918 .min = (unsigned int *) table->extra1, in proc_douintvec_minmax()
919 .max = (unsigned int *) table->extra2, in proc_douintvec_minmax()
926 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
933 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
938 * table->extra1 (min) and table->extra2 (max).
946 unsigned int min = 0, max = 255U, val; in proc_dou8vec_minmax() local
947 u8 *data = table->data; in proc_dou8vec_minmax()
949 .min = &min, in proc_dou8vec_minmax()
955 if (table->maxlen != sizeof(u8)) in proc_dou8vec_minmax()
956 return -EINVAL; in proc_dou8vec_minmax()
958 if (table->extra1) in proc_dou8vec_minmax()
959 min = *(unsigned int *) table->extra1; in proc_dou8vec_minmax()
960 if (table->extra2) in proc_dou8vec_minmax()
961 max = *(unsigned int *) table->extra2; in proc_dou8vec_minmax()
1003 unsigned long *i, *min, *max; in __do_proc_doulongvec_minmax() local
1008 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) { in __do_proc_doulongvec_minmax()
1014 min = table->extra1; in __do_proc_doulongvec_minmax()
1015 max = table->extra2; in __do_proc_doulongvec_minmax()
1016 vleft = table->maxlen / sizeof(unsigned long); in __do_proc_doulongvec_minmax()
1023 if (left > PAGE_SIZE - 1) in __do_proc_doulongvec_minmax()
1024 left = PAGE_SIZE - 1; in __do_proc_doulongvec_minmax()
1028 for (; left && vleft--; i++, first = 0) { in __do_proc_doulongvec_minmax()
1042 err = -EINVAL; in __do_proc_doulongvec_minmax()
1047 if ((min && val < *min) || (max && val > *max)) { in __do_proc_doulongvec_minmax()
1048 err = -EINVAL; in __do_proc_doulongvec_minmax()
1065 return err ? : -EINVAL; in __do_proc_doulongvec_minmax()
1066 *lenp -= left; in __do_proc_doulongvec_minmax()
1076 return __do_proc_doulongvec_minmax(table->data, table, write, in do_proc_doulongvec_minmax()
1081 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1088 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1092 * table->extra1 (min) and table->extra2 (max).
1103 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1110 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1115 * table->extra1 (min) and table->extra2 (max).
1135 WRITE_ONCE(*valp, -*lvalp * HZ); in do_proc_dointvec_jiffies_conv()
1143 lval = -(unsigned long)val; in do_proc_dointvec_jiffies_conv()
1160 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp); in do_proc_dointvec_userhz_jiffies_conv()
1166 lval = -(unsigned long)val; in do_proc_dointvec_userhz_jiffies_conv()
1181 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp); in do_proc_dointvec_ms_jiffies_conv()
1191 lval = -(unsigned long)val; in do_proc_dointvec_ms_jiffies_conv()
1208 * bounds-check it before touching *valp. in do_proc_dointvec_ms_jiffies_minmax_conv()
1217 if ((param->min && *param->min > tmp) || in do_proc_dointvec_ms_jiffies_minmax_conv()
1218 (param->max && *param->max < tmp)) in do_proc_dointvec_ms_jiffies_minmax_conv()
1219 return -EINVAL; in do_proc_dointvec_ms_jiffies_minmax_conv()
1226 * proc_dointvec_jiffies - read a vector of integers as seconds
1233 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1251 .min = (int *) table->extra1, in proc_dointvec_ms_jiffies_minmax()
1252 .max = (int *) table->extra2, in proc_dointvec_ms_jiffies_minmax()
1259 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1266 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1281 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1288 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1318 return -ESRCH; in proc_do_cad_pid()
1325 * proc_do_large_bitmap - read/write from/to a large bitmap
1332 * The bitmap is stored at table->data and the bitmap length (in bits)
1333 * in table->maxlen.
1335 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1346 unsigned long bitmap_len = table->maxlen; in proc_do_large_bitmap()
1347 unsigned long *bitmap = *(unsigned long **) table->data; in proc_do_large_bitmap()
1349 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c; in proc_do_large_bitmap()
1360 if (left > PAGE_SIZE - 1) { in proc_do_large_bitmap()
1361 left = PAGE_SIZE - 1; in proc_do_large_bitmap()
1363 skipped = *lenp - left; in proc_do_large_bitmap()
1368 return -ENOMEM; in proc_do_large_bitmap()
1375 /* In case we stop parsing mid-number, we can reset */ in proc_do_large_bitmap()
1381 * only one char is left (may be a "-"), then stop here, in proc_do_large_bitmap()
1392 err = -EINVAL; in proc_do_large_bitmap()
1399 left--; in proc_do_large_bitmap()
1402 if (c == '-') { in proc_do_large_bitmap()
1419 err = -EINVAL; in proc_do_large_bitmap()
1424 left--; in proc_do_large_bitmap()
1428 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1); in proc_do_large_bitmap()
1441 bit_a + 1) - 1; in proc_do_large_bitmap()
1447 proc_put_char(&buffer, &left, '-'); in proc_do_large_bitmap()
1463 *lenp -= left; in proc_do_large_bitmap()
1476 return -ENOSYS; in proc_dostring()
1482 return -ENOSYS; in proc_dobool()
1488 return -ENOSYS; in proc_dointvec()
1494 return -ENOSYS; in proc_douintvec()
1500 return -ENOSYS; in proc_dointvec_minmax()
1506 return -ENOSYS; in proc_douintvec_minmax()
1512 return -ENOSYS; in proc_dou8vec_minmax()
1518 return -ENOSYS; in proc_dointvec_jiffies()
1524 return -ENOSYS; in proc_dointvec_ms_jiffies_minmax()
1530 return -ENOSYS; in proc_dointvec_userhz_jiffies()
1536 return -ENOSYS; in proc_dointvec_ms_jiffies()
1542 return -ENOSYS; in proc_doulongvec_minmax()
1548 return -ENOSYS; in proc_doulongvec_ms_jiffies_minmax()
1554 return -ENOSYS; in proc_do_large_bitmap()
1563 struct static_key *key = (struct static_key *)table->data; in proc_do_static_key()
1569 .mode = table->mode, in proc_do_static_key()
1575 return -EPERM; in proc_do_static_key()
1616 .procname = "print-fatal-signals",
1624 .procname = "reboot-cmd",
1631 .procname = "stop-a",
1638 .procname = "scons-poweroff",
1647 .procname = "tsb-ratio",
1656 .procname = "soft-power",
1665 .procname = "unaligned-trap",
1751 .procname = "threads-max",
1824 .procname = "ignore-unaligned-usertrap",
1880 * exception granted :-)