aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2006-12-08 05:39:57 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:29:03 -0500
commit6b49a257850fb8ad91f4c76bb712e9213141a34a (patch)
tree5616780832c9f13c5f21e785052c4583a180490c /kernel/sysctl.c
parent9bc9a6bd3cf559bffe962c51efb062e8b5270ca9 (diff)
[PATCH] sysctl: fix sys_sysctl interface of ipc sysctls
Currently there is a regression and the ipc sysctls don't show up in the binary sysctl namespace. This patch adds sysctl_ipc_data to read data/write from the appropriate namespace and deliver it in the expected manner. [akpm@osdl.org: warning fix] Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 10474a63a111..025fcb3c66f8 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -143,6 +143,12 @@ static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
143 void __user *oldval, size_t __user *oldlenp, 143 void __user *oldval, size_t __user *oldlenp,
144 void __user *newval, size_t newlen, void **context); 144 void __user *newval, size_t newlen, void **context);
145 145
146#ifdef CONFIG_SYSVIPC
147static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
148 void __user *oldval, size_t __user *oldlenp,
149 void __user *newval, size_t newlen, void **context);
150#endif
151
146#ifdef CONFIG_PROC_SYSCTL 152#ifdef CONFIG_PROC_SYSCTL
147static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp, 153static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
148 void __user *buffer, size_t *lenp, loff_t *ppos); 154 void __user *buffer, size_t *lenp, loff_t *ppos);
@@ -476,6 +482,7 @@ static ctl_table kern_table[] = {
476 .maxlen = sizeof (init_ipc_ns.shm_ctlmax), 482 .maxlen = sizeof (init_ipc_ns.shm_ctlmax),
477 .mode = 0644, 483 .mode = 0644,
478 .proc_handler = &proc_ipc_doulongvec_minmax, 484 .proc_handler = &proc_ipc_doulongvec_minmax,
485 .strategy = sysctl_ipc_data,
479 }, 486 },
480 { 487 {
481 .ctl_name = KERN_SHMALL, 488 .ctl_name = KERN_SHMALL,
@@ -484,6 +491,7 @@ static ctl_table kern_table[] = {
484 .maxlen = sizeof (init_ipc_ns.shm_ctlall), 491 .maxlen = sizeof (init_ipc_ns.shm_ctlall),
485 .mode = 0644, 492 .mode = 0644,
486 .proc_handler = &proc_ipc_doulongvec_minmax, 493 .proc_handler = &proc_ipc_doulongvec_minmax,
494 .strategy = sysctl_ipc_data,
487 }, 495 },
488 { 496 {
489 .ctl_name = KERN_SHMMNI, 497 .ctl_name = KERN_SHMMNI,
@@ -492,6 +500,7 @@ static ctl_table kern_table[] = {
492 .maxlen = sizeof (init_ipc_ns.shm_ctlmni), 500 .maxlen = sizeof (init_ipc_ns.shm_ctlmni),
493 .mode = 0644, 501 .mode = 0644,
494 .proc_handler = &proc_ipc_dointvec, 502 .proc_handler = &proc_ipc_dointvec,
503 .strategy = sysctl_ipc_data,
495 }, 504 },
496 { 505 {
497 .ctl_name = KERN_MSGMAX, 506 .ctl_name = KERN_MSGMAX,
@@ -500,6 +509,7 @@ static ctl_table kern_table[] = {
500 .maxlen = sizeof (init_ipc_ns.msg_ctlmax), 509 .maxlen = sizeof (init_ipc_ns.msg_ctlmax),
501 .mode = 0644, 510 .mode = 0644,
502 .proc_handler = &proc_ipc_dointvec, 511 .proc_handler = &proc_ipc_dointvec,
512 .strategy = sysctl_ipc_data,
503 }, 513 },
504 { 514 {
505 .ctl_name = KERN_MSGMNI, 515 .ctl_name = KERN_MSGMNI,
@@ -508,6 +518,7 @@ static ctl_table kern_table[] = {
508 .maxlen = sizeof (init_ipc_ns.msg_ctlmni), 518 .maxlen = sizeof (init_ipc_ns.msg_ctlmni),
509 .mode = 0644, 519 .mode = 0644,
510 .proc_handler = &proc_ipc_dointvec, 520 .proc_handler = &proc_ipc_dointvec,
521 .strategy = sysctl_ipc_data,
511 }, 522 },
512 { 523 {
513 .ctl_name = KERN_MSGMNB, 524 .ctl_name = KERN_MSGMNB,
@@ -516,6 +527,7 @@ static ctl_table kern_table[] = {
516 .maxlen = sizeof (init_ipc_ns.msg_ctlmnb), 527 .maxlen = sizeof (init_ipc_ns.msg_ctlmnb),
517 .mode = 0644, 528 .mode = 0644,
518 .proc_handler = &proc_ipc_dointvec, 529 .proc_handler = &proc_ipc_dointvec,
530 .strategy = sysctl_ipc_data,
519 }, 531 },
520 { 532 {
521 .ctl_name = KERN_SEM, 533 .ctl_name = KERN_SEM,
@@ -524,6 +536,7 @@ static ctl_table kern_table[] = {
524 .maxlen = 4*sizeof (int), 536 .maxlen = 4*sizeof (int),
525 .mode = 0644, 537 .mode = 0644,
526 .proc_handler = &proc_ipc_dointvec, 538 .proc_handler = &proc_ipc_dointvec,
539 .strategy = sysctl_ipc_data,
527 }, 540 },
528#endif 541#endif
529#ifdef CONFIG_MAGIC_SYSRQ 542#ifdef CONFIG_MAGIC_SYSRQ
@@ -2611,6 +2624,47 @@ static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
2611 return r; 2624 return r;
2612} 2625}
2613 2626
2627#ifdef CONFIG_SYSVIPC
2628/* The generic sysctl ipc data routine. */
2629static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
2630 void __user *oldval, size_t __user *oldlenp,
2631 void __user *newval, size_t newlen, void **context)
2632{
2633 size_t len;
2634 void *data;
2635
2636 /* Get out of I don't have a variable */
2637 if (!table->data || !table->maxlen)
2638 return -ENOTDIR;
2639
2640 data = get_ipc(table, 1);
2641 if (!data)
2642 return -ENOTDIR;
2643
2644 if (oldval && oldlenp) {
2645 if (get_user(len, oldlenp))
2646 return -EFAULT;
2647 if (len) {
2648 if (len > table->maxlen)
2649 len = table->maxlen;
2650 if (copy_to_user(oldval, data, len))
2651 return -EFAULT;
2652 if (put_user(len, oldlenp))
2653 return -EFAULT;
2654 }
2655 }
2656
2657 if (newval && newlen) {
2658 if (newlen > table->maxlen)
2659 newlen = table->maxlen;
2660
2661 if (copy_from_user(data, newval, newlen))
2662 return -EFAULT;
2663 }
2664 return 1;
2665}
2666#endif
2667
2614#else /* CONFIG_SYSCTL_SYSCALL */ 2668#else /* CONFIG_SYSCTL_SYSCALL */
2615 2669
2616 2670
@@ -2681,6 +2735,12 @@ static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
2681{ 2735{
2682 return -ENOSYS; 2736 return -ENOSYS;
2683} 2737}
2738static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
2739 void __user *oldval, size_t __user *oldlenp,
2740 void __user *newval, size_t newlen, void **context)
2741{
2742 return -ENOSYS;
2743}
2684#endif /* CONFIG_SYSCTL_SYSCALL */ 2744#endif /* CONFIG_SYSCTL_SYSCALL */
2685 2745
2686/* 2746/*