diff options
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r-- | kernel/sysctl.c | 116 |
1 files changed, 88 insertions, 28 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 476ac2522f18..a79ccf9d113b 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
@@ -92,13 +92,8 @@ extern char modprobe_path[]; | |||
92 | extern int sg_big_buff; | 92 | extern int sg_big_buff; |
93 | #endif | 93 | #endif |
94 | #ifdef CONFIG_SYSVIPC | 94 | #ifdef CONFIG_SYSVIPC |
95 | extern size_t shm_ctlmax; | 95 | static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp, |
96 | extern size_t shm_ctlall; | 96 | void __user *buffer, size_t *lenp, loff_t *ppos); |
97 | extern int shm_ctlmni; | ||
98 | extern int msg_ctlmax; | ||
99 | extern int msg_ctlmnb; | ||
100 | extern int msg_ctlmni; | ||
101 | extern int sem_ctls[]; | ||
102 | #endif | 97 | #endif |
103 | 98 | ||
104 | #ifdef __sparc__ | 99 | #ifdef __sparc__ |
@@ -481,58 +476,58 @@ static ctl_table kern_table[] = { | |||
481 | { | 476 | { |
482 | .ctl_name = KERN_SHMMAX, | 477 | .ctl_name = KERN_SHMMAX, |
483 | .procname = "shmmax", | 478 | .procname = "shmmax", |
484 | .data = &shm_ctlmax, | 479 | .data = NULL, |
485 | .maxlen = sizeof (size_t), | 480 | .maxlen = sizeof (size_t), |
486 | .mode = 0644, | 481 | .mode = 0644, |
487 | .proc_handler = &proc_doulongvec_minmax, | 482 | .proc_handler = &proc_do_ipc_string, |
488 | }, | 483 | }, |
489 | { | 484 | { |
490 | .ctl_name = KERN_SHMALL, | 485 | .ctl_name = KERN_SHMALL, |
491 | .procname = "shmall", | 486 | .procname = "shmall", |
492 | .data = &shm_ctlall, | 487 | .data = NULL, |
493 | .maxlen = sizeof (size_t), | 488 | .maxlen = sizeof (size_t), |
494 | .mode = 0644, | 489 | .mode = 0644, |
495 | .proc_handler = &proc_doulongvec_minmax, | 490 | .proc_handler = &proc_do_ipc_string, |
496 | }, | 491 | }, |
497 | { | 492 | { |
498 | .ctl_name = KERN_SHMMNI, | 493 | .ctl_name = KERN_SHMMNI, |
499 | .procname = "shmmni", | 494 | .procname = "shmmni", |
500 | .data = &shm_ctlmni, | 495 | .data = NULL, |
501 | .maxlen = sizeof (int), | 496 | .maxlen = sizeof (int), |
502 | .mode = 0644, | 497 | .mode = 0644, |
503 | .proc_handler = &proc_dointvec, | 498 | .proc_handler = &proc_do_ipc_string, |
504 | }, | 499 | }, |
505 | { | 500 | { |
506 | .ctl_name = KERN_MSGMAX, | 501 | .ctl_name = KERN_MSGMAX, |
507 | .procname = "msgmax", | 502 | .procname = "msgmax", |
508 | .data = &msg_ctlmax, | 503 | .data = NULL, |
509 | .maxlen = sizeof (int), | 504 | .maxlen = sizeof (int), |
510 | .mode = 0644, | 505 | .mode = 0644, |
511 | .proc_handler = &proc_dointvec, | 506 | .proc_handler = &proc_do_ipc_string, |
512 | }, | 507 | }, |
513 | { | 508 | { |
514 | .ctl_name = KERN_MSGMNI, | 509 | .ctl_name = KERN_MSGMNI, |
515 | .procname = "msgmni", | 510 | .procname = "msgmni", |
516 | .data = &msg_ctlmni, | 511 | .data = NULL, |
517 | .maxlen = sizeof (int), | 512 | .maxlen = sizeof (int), |
518 | .mode = 0644, | 513 | .mode = 0644, |
519 | .proc_handler = &proc_dointvec, | 514 | .proc_handler = &proc_do_ipc_string, |
520 | }, | 515 | }, |
521 | { | 516 | { |
522 | .ctl_name = KERN_MSGMNB, | 517 | .ctl_name = KERN_MSGMNB, |
523 | .procname = "msgmnb", | 518 | .procname = "msgmnb", |
524 | .data = &msg_ctlmnb, | 519 | .data = NULL, |
525 | .maxlen = sizeof (int), | 520 | .maxlen = sizeof (int), |
526 | .mode = 0644, | 521 | .mode = 0644, |
527 | .proc_handler = &proc_dointvec, | 522 | .proc_handler = &proc_do_ipc_string, |
528 | }, | 523 | }, |
529 | { | 524 | { |
530 | .ctl_name = KERN_SEM, | 525 | .ctl_name = KERN_SEM, |
531 | .procname = "sem", | 526 | .procname = "sem", |
532 | .data = &sem_ctls, | 527 | .data = NULL, |
533 | .maxlen = 4*sizeof (int), | 528 | .maxlen = 4*sizeof (int), |
534 | .mode = 0644, | 529 | .mode = 0644, |
535 | .proc_handler = &proc_dointvec, | 530 | .proc_handler = &proc_do_ipc_string, |
536 | }, | 531 | }, |
537 | #endif | 532 | #endif |
538 | #ifdef CONFIG_MAGIC_SYSRQ | 533 | #ifdef CONFIG_MAGIC_SYSRQ |
@@ -1832,8 +1827,9 @@ static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, | |||
1832 | return 0; | 1827 | return 0; |
1833 | } | 1828 | } |
1834 | 1829 | ||
1835 | static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, | 1830 | static int __do_proc_dointvec(void *tbl_data, ctl_table *table, |
1836 | void __user *buffer, size_t *lenp, loff_t *ppos, | 1831 | int write, struct file *filp, void __user *buffer, |
1832 | size_t *lenp, loff_t *ppos, | ||
1837 | int (*conv)(int *negp, unsigned long *lvalp, int *valp, | 1833 | int (*conv)(int *negp, unsigned long *lvalp, int *valp, |
1838 | int write, void *data), | 1834 | int write, void *data), |
1839 | void *data) | 1835 | void *data) |
@@ -1846,13 +1842,13 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, | |||
1846 | char buf[TMPBUFLEN], *p; | 1842 | char buf[TMPBUFLEN], *p; |
1847 | char __user *s = buffer; | 1843 | char __user *s = buffer; |
1848 | 1844 | ||
1849 | if (!table->data || !table->maxlen || !*lenp || | 1845 | if (!tbl_data || !table->maxlen || !*lenp || |
1850 | (*ppos && !write)) { | 1846 | (*ppos && !write)) { |
1851 | *lenp = 0; | 1847 | *lenp = 0; |
1852 | return 0; | 1848 | return 0; |
1853 | } | 1849 | } |
1854 | 1850 | ||
1855 | i = (int *) table->data; | 1851 | i = (int *) tbl_data; |
1856 | vleft = table->maxlen / sizeof(*i); | 1852 | vleft = table->maxlen / sizeof(*i); |
1857 | left = *lenp; | 1853 | left = *lenp; |
1858 | 1854 | ||
@@ -1941,6 +1937,16 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, | |||
1941 | #undef TMPBUFLEN | 1937 | #undef TMPBUFLEN |
1942 | } | 1938 | } |
1943 | 1939 | ||
1940 | static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, | ||
1941 | void __user *buffer, size_t *lenp, loff_t *ppos, | ||
1942 | int (*conv)(int *negp, unsigned long *lvalp, int *valp, | ||
1943 | int write, void *data), | ||
1944 | void *data) | ||
1945 | { | ||
1946 | return __do_proc_dointvec(table->data, table, write, filp, | ||
1947 | buffer, lenp, ppos, conv, data); | ||
1948 | } | ||
1949 | |||
1944 | /** | 1950 | /** |
1945 | * proc_dointvec - read a vector of integers | 1951 | * proc_dointvec - read a vector of integers |
1946 | * @table: the sysctl table | 1952 | * @table: the sysctl table |
@@ -2074,7 +2080,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, | |||
2074 | do_proc_dointvec_minmax_conv, ¶m); | 2080 | do_proc_dointvec_minmax_conv, ¶m); |
2075 | } | 2081 | } |
2076 | 2082 | ||
2077 | static int do_proc_doulongvec_minmax(ctl_table *table, int write, | 2083 | static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write, |
2078 | struct file *filp, | 2084 | struct file *filp, |
2079 | void __user *buffer, | 2085 | void __user *buffer, |
2080 | size_t *lenp, loff_t *ppos, | 2086 | size_t *lenp, loff_t *ppos, |
@@ -2088,13 +2094,13 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write, | |||
2088 | char buf[TMPBUFLEN], *p; | 2094 | char buf[TMPBUFLEN], *p; |
2089 | char __user *s = buffer; | 2095 | char __user *s = buffer; |
2090 | 2096 | ||
2091 | if (!table->data || !table->maxlen || !*lenp || | 2097 | if (!data || !table->maxlen || !*lenp || |
2092 | (*ppos && !write)) { | 2098 | (*ppos && !write)) { |
2093 | *lenp = 0; | 2099 | *lenp = 0; |
2094 | return 0; | 2100 | return 0; |
2095 | } | 2101 | } |
2096 | 2102 | ||
2097 | i = (unsigned long *) table->data; | 2103 | i = (unsigned long *) data; |
2098 | min = (unsigned long *) table->extra1; | 2104 | min = (unsigned long *) table->extra1; |
2099 | max = (unsigned long *) table->extra2; | 2105 | max = (unsigned long *) table->extra2; |
2100 | vleft = table->maxlen / sizeof(unsigned long); | 2106 | vleft = table->maxlen / sizeof(unsigned long); |
@@ -2179,6 +2185,17 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write, | |||
2179 | #undef TMPBUFLEN | 2185 | #undef TMPBUFLEN |
2180 | } | 2186 | } |
2181 | 2187 | ||
2188 | static int do_proc_doulongvec_minmax(ctl_table *table, int write, | ||
2189 | struct file *filp, | ||
2190 | void __user *buffer, | ||
2191 | size_t *lenp, loff_t *ppos, | ||
2192 | unsigned long convmul, | ||
2193 | unsigned long convdiv) | ||
2194 | { | ||
2195 | return __do_proc_doulongvec_minmax(table->data, table, write, | ||
2196 | filp, buffer, lenp, ppos, convmul, convdiv); | ||
2197 | } | ||
2198 | |||
2182 | /** | 2199 | /** |
2183 | * proc_doulongvec_minmax - read a vector of long integers with min/max values | 2200 | * proc_doulongvec_minmax - read a vector of long integers with min/max values |
2184 | * @table: the sysctl table | 2201 | * @table: the sysctl table |
@@ -2367,6 +2384,49 @@ int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp, | |||
2367 | do_proc_dointvec_ms_jiffies_conv, NULL); | 2384 | do_proc_dointvec_ms_jiffies_conv, NULL); |
2368 | } | 2385 | } |
2369 | 2386 | ||
2387 | #ifdef CONFIG_SYSVIPC | ||
2388 | static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp, | ||
2389 | void __user *buffer, size_t *lenp, loff_t *ppos) | ||
2390 | { | ||
2391 | void *data; | ||
2392 | struct ipc_namespace *ns; | ||
2393 | |||
2394 | ns = current->nsproxy->ipc_ns; | ||
2395 | |||
2396 | switch (table->ctl_name) { | ||
2397 | case KERN_SHMMAX: | ||
2398 | data = &ns->shm_ctlmax; | ||
2399 | goto proc_minmax; | ||
2400 | case KERN_SHMALL: | ||
2401 | data = &ns->shm_ctlall; | ||
2402 | goto proc_minmax; | ||
2403 | case KERN_SHMMNI: | ||
2404 | data = &ns->shm_ctlmni; | ||
2405 | break; | ||
2406 | case KERN_MSGMAX: | ||
2407 | data = &ns->msg_ctlmax; | ||
2408 | break; | ||
2409 | case KERN_MSGMNI: | ||
2410 | data = &ns->msg_ctlmni; | ||
2411 | break; | ||
2412 | case KERN_MSGMNB: | ||
2413 | data = &ns->msg_ctlmnb; | ||
2414 | break; | ||
2415 | case KERN_SEM: | ||
2416 | data = &ns->sem_ctls; | ||
2417 | break; | ||
2418 | default: | ||
2419 | return -EINVAL; | ||
2420 | } | ||
2421 | |||
2422 | return __do_proc_dointvec(data, table, write, filp, buffer, | ||
2423 | lenp, ppos, NULL, NULL); | ||
2424 | proc_minmax: | ||
2425 | return __do_proc_doulongvec_minmax(data, table, write, filp, buffer, | ||
2426 | lenp, ppos, 1l, 1l); | ||
2427 | } | ||
2428 | #endif | ||
2429 | |||
2370 | #else /* CONFIG_PROC_FS */ | 2430 | #else /* CONFIG_PROC_FS */ |
2371 | 2431 | ||
2372 | int proc_dostring(ctl_table *table, int write, struct file *filp, | 2432 | int proc_dostring(ctl_table *table, int write, struct file *filp, |