aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/sysctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/sysctl.c')
-rw-r--r--kernel/sysctl.c276
1 files changed, 154 insertions, 122 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index dde3d53e8adc..067554bda8b7 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -24,7 +24,7 @@
24#include <linux/slab.h> 24#include <linux/slab.h>
25#include <linux/sysctl.h> 25#include <linux/sysctl.h>
26#include <linux/proc_fs.h> 26#include <linux/proc_fs.h>
27#include <linux/capability.h> 27#include <linux/security.h>
28#include <linux/ctype.h> 28#include <linux/ctype.h>
29#include <linux/utsname.h> 29#include <linux/utsname.h>
30#include <linux/smp_lock.h> 30#include <linux/smp_lock.h>
@@ -55,6 +55,8 @@
55#include <asm/stacktrace.h> 55#include <asm/stacktrace.h>
56#endif 56#endif
57 57
58static int deprecated_sysctl_warning(struct __sysctl_args *args);
59
58#if defined(CONFIG_SYSCTL) 60#if defined(CONFIG_SYSCTL)
59 61
60/* External variables not in a header file. */ 62/* External variables not in a header file. */
@@ -142,32 +144,29 @@ extern int max_lock_depth;
142 144
143#ifdef CONFIG_SYSCTL_SYSCALL 145#ifdef CONFIG_SYSCTL_SYSCALL
144static int parse_table(int __user *, int, void __user *, size_t __user *, 146static int parse_table(int __user *, int, void __user *, size_t __user *,
145 void __user *, size_t, ctl_table *); 147 void __user *, size_t, struct ctl_table *);
146#endif 148#endif
147 149
148 150
149#ifdef CONFIG_PROC_SYSCTL 151#ifdef CONFIG_PROC_SYSCTL
150static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp, 152static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
151 void __user *buffer, size_t *lenp, loff_t *ppos); 153 void __user *buffer, size_t *lenp, loff_t *ppos);
152static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp, 154static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
153 void __user *buffer, size_t *lenp, loff_t *ppos); 155 void __user *buffer, size_t *lenp, loff_t *ppos);
154#endif 156#endif
155 157
156static ctl_table root_table[]; 158static struct ctl_table root_table[];
157static struct ctl_table_header root_table_header = 159static struct ctl_table_header root_table_header =
158 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) }; 160 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
159 161
160static ctl_table kern_table[]; 162static struct ctl_table kern_table[];
161static ctl_table vm_table[]; 163static struct ctl_table vm_table[];
162static ctl_table fs_table[]; 164static struct ctl_table fs_table[];
163static ctl_table debug_table[]; 165static struct ctl_table debug_table[];
164static ctl_table dev_table[]; 166static struct ctl_table dev_table[];
165extern ctl_table random_table[]; 167extern struct ctl_table random_table[];
166#ifdef CONFIG_UNIX98_PTYS
167extern ctl_table pty_table[];
168#endif
169#ifdef CONFIG_INOTIFY_USER 168#ifdef CONFIG_INOTIFY_USER
170extern ctl_table inotify_table[]; 169extern struct ctl_table inotify_table[];
171#endif 170#endif
172 171
173#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT 172#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
@@ -179,7 +178,7 @@ extern int lock_stat;
179 178
180/* The default sysctl tables: */ 179/* The default sysctl tables: */
181 180
182static ctl_table root_table[] = { 181static struct ctl_table root_table[] = {
183 { 182 {
184 .ctl_name = CTL_KERN, 183 .ctl_name = CTL_KERN,
185 .procname = "kernel", 184 .procname = "kernel",
@@ -232,7 +231,7 @@ static unsigned long min_wakeup_granularity_ns; /* 0 usecs */
232static unsigned long max_wakeup_granularity_ns = 1000000000; /* 1 second */ 231static unsigned long max_wakeup_granularity_ns = 1000000000; /* 1 second */
233#endif 232#endif
234 233
235static ctl_table kern_table[] = { 234static struct ctl_table kern_table[] = {
236#ifdef CONFIG_SCHED_DEBUG 235#ifdef CONFIG_SCHED_DEBUG
237 { 236 {
238 .ctl_name = CTL_UNNUMBERED, 237 .ctl_name = CTL_UNNUMBERED,
@@ -365,7 +364,6 @@ static ctl_table kern_table[] = {
365 }, 364 },
366#ifdef CONFIG_PROC_SYSCTL 365#ifdef CONFIG_PROC_SYSCTL
367 { 366 {
368 .ctl_name = KERN_TAINTED,
369 .procname = "tainted", 367 .procname = "tainted",
370 .data = &tainted, 368 .data = &tainted,
371 .maxlen = sizeof(int), 369 .maxlen = sizeof(int),
@@ -373,14 +371,15 @@ static ctl_table kern_table[] = {
373 .proc_handler = &proc_dointvec_taint, 371 .proc_handler = &proc_dointvec_taint,
374 }, 372 },
375#endif 373#endif
374#ifdef CONFIG_SECURITY_CAPABILITIES
376 { 375 {
377 .ctl_name = KERN_CAP_BSET,
378 .procname = "cap-bound", 376 .procname = "cap-bound",
379 .data = &cap_bset, 377 .data = &cap_bset,
380 .maxlen = sizeof(kernel_cap_t), 378 .maxlen = sizeof(kernel_cap_t),
381 .mode = 0600, 379 .mode = 0600,
382 .proc_handler = &proc_dointvec_bset, 380 .proc_handler = &proc_dointvec_bset,
383 }, 381 },
382#endif /* def CONFIG_SECURITY_CAPABILITIES */
384#ifdef CONFIG_BLK_DEV_INITRD 383#ifdef CONFIG_BLK_DEV_INITRD
385 { 384 {
386 .ctl_name = KERN_REALROOTDEV, 385 .ctl_name = KERN_REALROOTDEV,
@@ -514,7 +513,6 @@ static ctl_table kern_table[] = {
514#endif 513#endif
515#ifdef CONFIG_PROC_SYSCTL 514#ifdef CONFIG_PROC_SYSCTL
516 { 515 {
517 .ctl_name = KERN_CADPID,
518 .procname = "cad_pid", 516 .procname = "cad_pid",
519 .data = NULL, 517 .data = NULL,
520 .maxlen = sizeof (int), 518 .maxlen = sizeof (int),
@@ -536,14 +534,6 @@ static ctl_table kern_table[] = {
536 .mode = 0555, 534 .mode = 0555,
537 .child = random_table, 535 .child = random_table,
538 }, 536 },
539#ifdef CONFIG_UNIX98_PTYS
540 {
541 .ctl_name = KERN_PTY,
542 .procname = "pty",
543 .mode = 0555,
544 .child = pty_table,
545 },
546#endif
547 { 537 {
548 .ctl_name = KERN_OVERFLOWUID, 538 .ctl_name = KERN_OVERFLOWUID,
549 .procname = "overflowuid", 539 .procname = "overflowuid",
@@ -650,7 +640,6 @@ static ctl_table kern_table[] = {
650 .proc_handler = &proc_dointvec, 640 .proc_handler = &proc_dointvec,
651 }, 641 },
652 { 642 {
653 .ctl_name = KERN_NMI_WATCHDOG,
654 .procname = "nmi_watchdog", 643 .procname = "nmi_watchdog",
655 .data = &nmi_watchdog_enabled, 644 .data = &nmi_watchdog_enabled,
656 .maxlen = sizeof (int), 645 .maxlen = sizeof (int),
@@ -706,7 +695,6 @@ static ctl_table kern_table[] = {
706#endif 695#endif
707#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86) 696#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
708 { 697 {
709 .ctl_name = KERN_ACPI_VIDEO_FLAGS,
710 .procname = "acpi_video_flags", 698 .procname = "acpi_video_flags",
711 .data = &acpi_realmode_flags, 699 .data = &acpi_realmode_flags,
712 .maxlen = sizeof (unsigned long), 700 .maxlen = sizeof (unsigned long),
@@ -783,7 +771,7 @@ static ctl_table kern_table[] = {
783 { .ctl_name = 0 } 771 { .ctl_name = 0 }
784}; 772};
785 773
786static ctl_table vm_table[] = { 774static struct ctl_table vm_table[] = {
787 { 775 {
788 .ctl_name = VM_OVERCOMMIT_MEMORY, 776 .ctl_name = VM_OVERCOMMIT_MEMORY,
789 .procname = "overcommit_memory", 777 .procname = "overcommit_memory",
@@ -847,7 +835,6 @@ static ctl_table vm_table[] = {
847 .extra2 = &one_hundred, 835 .extra2 = &one_hundred,
848 }, 836 },
849 { 837 {
850 .ctl_name = VM_DIRTY_WB_CS,
851 .procname = "dirty_writeback_centisecs", 838 .procname = "dirty_writeback_centisecs",
852 .data = &dirty_writeback_interval, 839 .data = &dirty_writeback_interval,
853 .maxlen = sizeof(dirty_writeback_interval), 840 .maxlen = sizeof(dirty_writeback_interval),
@@ -855,7 +842,6 @@ static ctl_table vm_table[] = {
855 .proc_handler = &dirty_writeback_centisecs_handler, 842 .proc_handler = &dirty_writeback_centisecs_handler,
856 }, 843 },
857 { 844 {
858 .ctl_name = VM_DIRTY_EXPIRE_CS,
859 .procname = "dirty_expire_centisecs", 845 .procname = "dirty_expire_centisecs",
860 .data = &dirty_expire_interval, 846 .data = &dirty_expire_interval,
861 .maxlen = sizeof(dirty_expire_interval), 847 .maxlen = sizeof(dirty_expire_interval),
@@ -883,7 +869,6 @@ static ctl_table vm_table[] = {
883 }, 869 },
884#ifdef CONFIG_HUGETLB_PAGE 870#ifdef CONFIG_HUGETLB_PAGE
885 { 871 {
886 .ctl_name = VM_HUGETLB_PAGES,
887 .procname = "nr_hugepages", 872 .procname = "nr_hugepages",
888 .data = &max_huge_pages, 873 .data = &max_huge_pages,
889 .maxlen = sizeof(unsigned long), 874 .maxlen = sizeof(unsigned long),
@@ -1093,12 +1078,12 @@ static ctl_table vm_table[] = {
1093}; 1078};
1094 1079
1095#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE) 1080#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1096static ctl_table binfmt_misc_table[] = { 1081static struct ctl_table binfmt_misc_table[] = {
1097 { .ctl_name = 0 } 1082 { .ctl_name = 0 }
1098}; 1083};
1099#endif 1084#endif
1100 1085
1101static ctl_table fs_table[] = { 1086static struct ctl_table fs_table[] = {
1102 { 1087 {
1103 .ctl_name = FS_NRINODE, 1088 .ctl_name = FS_NRINODE,
1104 .procname = "inode-nr", 1089 .procname = "inode-nr",
@@ -1116,7 +1101,6 @@ static ctl_table fs_table[] = {
1116 .proc_handler = &proc_dointvec, 1101 .proc_handler = &proc_dointvec,
1117 }, 1102 },
1118 { 1103 {
1119 .ctl_name = FS_NRFILE,
1120 .procname = "file-nr", 1104 .procname = "file-nr",
1121 .data = &files_stat, 1105 .data = &files_stat,
1122 .maxlen = 3*sizeof(int), 1106 .maxlen = 3*sizeof(int),
@@ -1192,7 +1176,6 @@ static ctl_table fs_table[] = {
1192 .extra2 = &two, 1176 .extra2 = &two,
1193 }, 1177 },
1194 { 1178 {
1195 .ctl_name = FS_AIO_NR,
1196 .procname = "aio-nr", 1179 .procname = "aio-nr",
1197 .data = &aio_nr, 1180 .data = &aio_nr,
1198 .maxlen = sizeof(aio_nr), 1181 .maxlen = sizeof(aio_nr),
@@ -1200,7 +1183,6 @@ static ctl_table fs_table[] = {
1200 .proc_handler = &proc_doulongvec_minmax, 1183 .proc_handler = &proc_doulongvec_minmax,
1201 }, 1184 },
1202 { 1185 {
1203 .ctl_name = FS_AIO_MAX_NR,
1204 .procname = "aio-max-nr", 1186 .procname = "aio-max-nr",
1205 .data = &aio_max_nr, 1187 .data = &aio_max_nr,
1206 .maxlen = sizeof(aio_max_nr), 1188 .maxlen = sizeof(aio_max_nr),
@@ -1239,7 +1221,7 @@ static ctl_table fs_table[] = {
1239 { .ctl_name = 0 } 1221 { .ctl_name = 0 }
1240}; 1222};
1241 1223
1242static ctl_table debug_table[] = { 1224static struct ctl_table debug_table[] = {
1243#if defined(CONFIG_X86) || defined(CONFIG_PPC) 1225#if defined(CONFIG_X86) || defined(CONFIG_PPC)
1244 { 1226 {
1245 .ctl_name = CTL_UNNUMBERED, 1227 .ctl_name = CTL_UNNUMBERED,
@@ -1253,7 +1235,7 @@ static ctl_table debug_table[] = {
1253 { .ctl_name = 0 } 1235 { .ctl_name = 0 }
1254}; 1236};
1255 1237
1256static ctl_table dev_table[] = { 1238static struct ctl_table dev_table[] = {
1257 { .ctl_name = 0 } 1239 { .ctl_name = 0 }
1258}; 1240};
1259 1241
@@ -1369,10 +1351,15 @@ asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1369 if (copy_from_user(&tmp, args, sizeof(tmp))) 1351 if (copy_from_user(&tmp, args, sizeof(tmp)))
1370 return -EFAULT; 1352 return -EFAULT;
1371 1353
1354 error = deprecated_sysctl_warning(&tmp);
1355 if (error)
1356 goto out;
1357
1372 lock_kernel(); 1358 lock_kernel();
1373 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp, 1359 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1374 tmp.newval, tmp.newlen); 1360 tmp.newval, tmp.newlen);
1375 unlock_kernel(); 1361 unlock_kernel();
1362out:
1376 return error; 1363 return error;
1377} 1364}
1378#endif /* CONFIG_SYSCTL_SYSCALL */ 1365#endif /* CONFIG_SYSCTL_SYSCALL */
@@ -1393,7 +1380,7 @@ static int test_perm(int mode, int op)
1393 return -EACCES; 1380 return -EACCES;
1394} 1381}
1395 1382
1396int sysctl_perm(ctl_table *table, int op) 1383int sysctl_perm(struct ctl_table *table, int op)
1397{ 1384{
1398 int error; 1385 int error;
1399 error = security_sysctl(table, op); 1386 error = security_sysctl(table, op);
@@ -1406,7 +1393,7 @@ int sysctl_perm(ctl_table *table, int op)
1406static int parse_table(int __user *name, int nlen, 1393static int parse_table(int __user *name, int nlen,
1407 void __user *oldval, size_t __user *oldlenp, 1394 void __user *oldval, size_t __user *oldlenp,
1408 void __user *newval, size_t newlen, 1395 void __user *newval, size_t newlen,
1409 ctl_table *table) 1396 struct ctl_table *table)
1410{ 1397{
1411 int n; 1398 int n;
1412repeat: 1399repeat:
@@ -1437,13 +1424,12 @@ repeat:
1437} 1424}
1438 1425
1439/* Perform the actual read/write of a sysctl table entry. */ 1426/* Perform the actual read/write of a sysctl table entry. */
1440int do_sysctl_strategy (ctl_table *table, 1427int do_sysctl_strategy (struct ctl_table *table,
1441 int __user *name, int nlen, 1428 int __user *name, int nlen,
1442 void __user *oldval, size_t __user *oldlenp, 1429 void __user *oldval, size_t __user *oldlenp,
1443 void __user *newval, size_t newlen) 1430 void __user *newval, size_t newlen)
1444{ 1431{
1445 int op = 0, rc; 1432 int op = 0, rc;
1446 size_t len;
1447 1433
1448 if (oldval) 1434 if (oldval)
1449 op |= 004; 1435 op |= 004;
@@ -1464,25 +1450,10 @@ int do_sysctl_strategy (ctl_table *table,
1464 /* If there is no strategy routine, or if the strategy returns 1450 /* If there is no strategy routine, or if the strategy returns
1465 * zero, proceed with automatic r/w */ 1451 * zero, proceed with automatic r/w */
1466 if (table->data && table->maxlen) { 1452 if (table->data && table->maxlen) {
1467 if (oldval && oldlenp) { 1453 rc = sysctl_data(table, name, nlen, oldval, oldlenp,
1468 if (get_user(len, oldlenp)) 1454 newval, newlen);
1469 return -EFAULT; 1455 if (rc < 0)
1470 if (len) { 1456 return rc;
1471 if (len > table->maxlen)
1472 len = table->maxlen;
1473 if(copy_to_user(oldval, table->data, len))
1474 return -EFAULT;
1475 if(put_user(len, oldlenp))
1476 return -EFAULT;
1477 }
1478 }
1479 if (newval && newlen) {
1480 len = newlen;
1481 if (len > table->maxlen)
1482 len = table->maxlen;
1483 if(copy_from_user(table->data, newval, len))
1484 return -EFAULT;
1485 }
1486 } 1457 }
1487 return 0; 1458 return 0;
1488} 1459}
@@ -1499,7 +1470,9 @@ static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1499 1470
1500static __init int sysctl_init(void) 1471static __init int sysctl_init(void)
1501{ 1472{
1473 int err;
1502 sysctl_set_parent(NULL, root_table); 1474 sysctl_set_parent(NULL, root_table);
1475 err = sysctl_check_table(root_table);
1503 return 0; 1476 return 0;
1504} 1477}
1505 1478
@@ -1512,7 +1485,7 @@ core_initcall(sysctl_init);
1512 * Register a sysctl table hierarchy. @table should be a filled in ctl_table 1485 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1513 * array. An entry with a ctl_name of 0 terminates the table. 1486 * array. An entry with a ctl_name of 0 terminates the table.
1514 * 1487 *
1515 * The members of the &ctl_table structure are used as follows: 1488 * The members of the &struct ctl_table structure are used as follows:
1516 * 1489 *
1517 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number 1490 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1518 * must be unique within that level of sysctl 1491 * must be unique within that level of sysctl
@@ -1573,7 +1546,7 @@ core_initcall(sysctl_init);
1573 * This routine returns %NULL on a failure to register, and a pointer 1546 * This routine returns %NULL on a failure to register, and a pointer
1574 * to the table header on success. 1547 * to the table header on success.
1575 */ 1548 */
1576struct ctl_table_header *register_sysctl_table(ctl_table * table) 1549struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1577{ 1550{
1578 struct ctl_table_header *tmp; 1551 struct ctl_table_header *tmp;
1579 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL); 1552 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
@@ -1584,6 +1557,10 @@ struct ctl_table_header *register_sysctl_table(ctl_table * table)
1584 tmp->used = 0; 1557 tmp->used = 0;
1585 tmp->unregistering = NULL; 1558 tmp->unregistering = NULL;
1586 sysctl_set_parent(NULL, table); 1559 sysctl_set_parent(NULL, table);
1560 if (sysctl_check_table(tmp->ctl_table)) {
1561 kfree(tmp);
1562 return NULL;
1563 }
1587 spin_lock(&sysctl_lock); 1564 spin_lock(&sysctl_lock);
1588 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry); 1565 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
1589 spin_unlock(&sysctl_lock); 1566 spin_unlock(&sysctl_lock);
@@ -1607,7 +1584,7 @@ void unregister_sysctl_table(struct ctl_table_header * header)
1607} 1584}
1608 1585
1609#else /* !CONFIG_SYSCTL */ 1586#else /* !CONFIG_SYSCTL */
1610struct ctl_table_header *register_sysctl_table(ctl_table * table) 1587struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1611{ 1588{
1612 return NULL; 1589 return NULL;
1613} 1590}
@@ -1700,7 +1677,7 @@ static int _proc_do_string(void* data, int maxlen, int write,
1700 * 1677 *
1701 * Returns 0 on success. 1678 * Returns 0 on success.
1702 */ 1679 */
1703int proc_dostring(ctl_table *table, int write, struct file *filp, 1680int proc_dostring(struct ctl_table *table, int write, struct file *filp,
1704 void __user *buffer, size_t *lenp, loff_t *ppos) 1681 void __user *buffer, size_t *lenp, loff_t *ppos)
1705{ 1682{
1706 return _proc_do_string(table->data, table->maxlen, write, filp, 1683 return _proc_do_string(table->data, table->maxlen, write, filp,
@@ -1727,7 +1704,7 @@ static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1727 return 0; 1704 return 0;
1728} 1705}
1729 1706
1730static int __do_proc_dointvec(void *tbl_data, ctl_table *table, 1707static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
1731 int write, struct file *filp, void __user *buffer, 1708 int write, struct file *filp, void __user *buffer,
1732 size_t *lenp, loff_t *ppos, 1709 size_t *lenp, loff_t *ppos,
1733 int (*conv)(int *negp, unsigned long *lvalp, int *valp, 1710 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
@@ -1837,7 +1814,7 @@ static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
1837#undef TMPBUFLEN 1814#undef TMPBUFLEN
1838} 1815}
1839 1816
1840static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, 1817static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
1841 void __user *buffer, size_t *lenp, loff_t *ppos, 1818 void __user *buffer, size_t *lenp, loff_t *ppos,
1842 int (*conv)(int *negp, unsigned long *lvalp, int *valp, 1819 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1843 int write, void *data), 1820 int write, void *data),
@@ -1861,7 +1838,7 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1861 * 1838 *
1862 * Returns 0 on success. 1839 * Returns 0 on success.
1863 */ 1840 */
1864int proc_dointvec(ctl_table *table, int write, struct file *filp, 1841int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
1865 void __user *buffer, size_t *lenp, loff_t *ppos) 1842 void __user *buffer, size_t *lenp, loff_t *ppos)
1866{ 1843{
1867 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 1844 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
@@ -1897,11 +1874,12 @@ static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1897 return 0; 1874 return 0;
1898} 1875}
1899 1876
1877#ifdef CONFIG_SECURITY_CAPABILITIES
1900/* 1878/*
1901 * init may raise the set. 1879 * init may raise the set.
1902 */ 1880 */
1903 1881
1904int proc_dointvec_bset(ctl_table *table, int write, struct file *filp, 1882int proc_dointvec_bset(struct ctl_table *table, int write, struct file *filp,
1905 void __user *buffer, size_t *lenp, loff_t *ppos) 1883 void __user *buffer, size_t *lenp, loff_t *ppos)
1906{ 1884{
1907 int op; 1885 int op;
@@ -1914,11 +1892,12 @@ int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1914 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 1892 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1915 do_proc_dointvec_bset_conv,&op); 1893 do_proc_dointvec_bset_conv,&op);
1916} 1894}
1895#endif /* def CONFIG_SECURITY_CAPABILITIES */
1917 1896
1918/* 1897/*
1919 * Taint values can only be increased 1898 * Taint values can only be increased
1920 */ 1899 */
1921static int proc_dointvec_taint(ctl_table *table, int write, struct file *filp, 1900static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
1922 void __user *buffer, size_t *lenp, loff_t *ppos) 1901 void __user *buffer, size_t *lenp, loff_t *ppos)
1923{ 1902{
1924 int op; 1903 int op;
@@ -1977,7 +1956,7 @@ static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1977 * 1956 *
1978 * Returns 0 on success. 1957 * Returns 0 on success.
1979 */ 1958 */
1980int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, 1959int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
1981 void __user *buffer, size_t *lenp, loff_t *ppos) 1960 void __user *buffer, size_t *lenp, loff_t *ppos)
1982{ 1961{
1983 struct do_proc_dointvec_minmax_conv_param param = { 1962 struct do_proc_dointvec_minmax_conv_param param = {
@@ -1988,7 +1967,7 @@ int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
1988 do_proc_dointvec_minmax_conv, &param); 1967 do_proc_dointvec_minmax_conv, &param);
1989} 1968}
1990 1969
1991static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write, 1970static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
1992 struct file *filp, 1971 struct file *filp,
1993 void __user *buffer, 1972 void __user *buffer,
1994 size_t *lenp, loff_t *ppos, 1973 size_t *lenp, loff_t *ppos,
@@ -2093,7 +2072,7 @@ static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
2093#undef TMPBUFLEN 2072#undef TMPBUFLEN
2094} 2073}
2095 2074
2096static int do_proc_doulongvec_minmax(ctl_table *table, int write, 2075static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2097 struct file *filp, 2076 struct file *filp,
2098 void __user *buffer, 2077 void __user *buffer,
2099 size_t *lenp, loff_t *ppos, 2078 size_t *lenp, loff_t *ppos,
@@ -2121,7 +2100,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write,
2121 * 2100 *
2122 * Returns 0 on success. 2101 * Returns 0 on success.
2123 */ 2102 */
2124int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, 2103int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
2125 void __user *buffer, size_t *lenp, loff_t *ppos) 2104 void __user *buffer, size_t *lenp, loff_t *ppos)
2126{ 2105{
2127 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l); 2106 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
@@ -2145,7 +2124,7 @@ int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2145 * 2124 *
2146 * Returns 0 on success. 2125 * Returns 0 on success.
2147 */ 2126 */
2148int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write, 2127int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2149 struct file *filp, 2128 struct file *filp,
2150 void __user *buffer, 2129 void __user *buffer,
2151 size_t *lenp, loff_t *ppos) 2130 size_t *lenp, loff_t *ppos)
@@ -2238,7 +2217,7 @@ static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2238 * 2217 *
2239 * Returns 0 on success. 2218 * Returns 0 on success.
2240 */ 2219 */
2241int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp, 2220int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
2242 void __user *buffer, size_t *lenp, loff_t *ppos) 2221 void __user *buffer, size_t *lenp, loff_t *ppos)
2243{ 2222{
2244 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 2223 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
@@ -2261,7 +2240,7 @@ int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2261 * 2240 *
2262 * Returns 0 on success. 2241 * Returns 0 on success.
2263 */ 2242 */
2264int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp, 2243int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
2265 void __user *buffer, size_t *lenp, loff_t *ppos) 2244 void __user *buffer, size_t *lenp, loff_t *ppos)
2266{ 2245{
2267 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos, 2246 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
@@ -2285,14 +2264,14 @@ int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2285 * 2264 *
2286 * Returns 0 on success. 2265 * Returns 0 on success.
2287 */ 2266 */
2288int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp, 2267int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
2289 void __user *buffer, size_t *lenp, loff_t *ppos) 2268 void __user *buffer, size_t *lenp, loff_t *ppos)
2290{ 2269{
2291 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos, 2270 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2292 do_proc_dointvec_ms_jiffies_conv, NULL); 2271 do_proc_dointvec_ms_jiffies_conv, NULL);
2293} 2272}
2294 2273
2295static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp, 2274static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
2296 void __user *buffer, size_t *lenp, loff_t *ppos) 2275 void __user *buffer, size_t *lenp, loff_t *ppos)
2297{ 2276{
2298 struct pid *new_pid; 2277 struct pid *new_pid;
@@ -2316,55 +2295,55 @@ static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
2316 2295
2317#else /* CONFIG_PROC_FS */ 2296#else /* CONFIG_PROC_FS */
2318 2297
2319int proc_dostring(ctl_table *table, int write, struct file *filp, 2298int proc_dostring(struct ctl_table *table, int write, struct file *filp,
2320 void __user *buffer, size_t *lenp, loff_t *ppos) 2299 void __user *buffer, size_t *lenp, loff_t *ppos)
2321{ 2300{
2322 return -ENOSYS; 2301 return -ENOSYS;
2323} 2302}
2324 2303
2325int proc_dointvec(ctl_table *table, int write, struct file *filp, 2304int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2326 void __user *buffer, size_t *lenp, loff_t *ppos) 2305 void __user *buffer, size_t *lenp, loff_t *ppos)
2327{ 2306{
2328 return -ENOSYS; 2307 return -ENOSYS;
2329} 2308}
2330 2309
2331int proc_dointvec_bset(ctl_table *table, int write, struct file *filp, 2310int proc_dointvec_bset(struct ctl_table *table, int write, struct file *filp,
2332 void __user *buffer, size_t *lenp, loff_t *ppos) 2311 void __user *buffer, size_t *lenp, loff_t *ppos)
2333{ 2312{
2334 return -ENOSYS; 2313 return -ENOSYS;
2335} 2314}
2336 2315
2337int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp, 2316int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
2338 void __user *buffer, size_t *lenp, loff_t *ppos) 2317 void __user *buffer, size_t *lenp, loff_t *ppos)
2339{ 2318{
2340 return -ENOSYS; 2319 return -ENOSYS;
2341} 2320}
2342 2321
2343int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp, 2322int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
2344 void __user *buffer, size_t *lenp, loff_t *ppos) 2323 void __user *buffer, size_t *lenp, loff_t *ppos)
2345{ 2324{
2346 return -ENOSYS; 2325 return -ENOSYS;
2347} 2326}
2348 2327
2349int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp, 2328int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
2350 void __user *buffer, size_t *lenp, loff_t *ppos) 2329 void __user *buffer, size_t *lenp, loff_t *ppos)
2351{ 2330{
2352 return -ENOSYS; 2331 return -ENOSYS;
2353} 2332}
2354 2333
2355int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp, 2334int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
2356 void __user *buffer, size_t *lenp, loff_t *ppos) 2335 void __user *buffer, size_t *lenp, loff_t *ppos)
2357{ 2336{
2358 return -ENOSYS; 2337 return -ENOSYS;
2359} 2338}
2360 2339
2361int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, 2340int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
2362 void __user *buffer, size_t *lenp, loff_t *ppos) 2341 void __user *buffer, size_t *lenp, loff_t *ppos)
2363{ 2342{
2364 return -ENOSYS; 2343 return -ENOSYS;
2365} 2344}
2366 2345
2367int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write, 2346int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2368 struct file *filp, 2347 struct file *filp,
2369 void __user *buffer, 2348 void __user *buffer,
2370 size_t *lenp, loff_t *ppos) 2349 size_t *lenp, loff_t *ppos)
@@ -2381,8 +2360,42 @@ int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2381 * General sysctl support routines 2360 * General sysctl support routines
2382 */ 2361 */
2383 2362
2363/* The generic sysctl data routine (used if no strategy routine supplied) */
2364int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2365 void __user *oldval, size_t __user *oldlenp,
2366 void __user *newval, size_t newlen)
2367{
2368 size_t len;
2369
2370 /* Get out of I don't have a variable */
2371 if (!table->data || !table->maxlen)
2372 return -ENOTDIR;
2373
2374 if (oldval && oldlenp) {
2375 if (get_user(len, oldlenp))
2376 return -EFAULT;
2377 if (len) {
2378 if (len > table->maxlen)
2379 len = table->maxlen;
2380 if (copy_to_user(oldval, table->data, len))
2381 return -EFAULT;
2382 if (put_user(len, oldlenp))
2383 return -EFAULT;
2384 }
2385 }
2386
2387 if (newval && newlen) {
2388 if (newlen > table->maxlen)
2389 newlen = table->maxlen;
2390
2391 if (copy_from_user(table->data, newval, newlen))
2392 return -EFAULT;
2393 }
2394 return 1;
2395}
2396
2384/* The generic string strategy routine: */ 2397/* The generic string strategy routine: */
2385int sysctl_string(ctl_table *table, int __user *name, int nlen, 2398int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
2386 void __user *oldval, size_t __user *oldlenp, 2399 void __user *oldval, size_t __user *oldlenp,
2387 void __user *newval, size_t newlen) 2400 void __user *newval, size_t newlen)
2388{ 2401{
@@ -2428,7 +2441,7 @@ int sysctl_string(ctl_table *table, int __user *name, int nlen,
2428 * are between the minimum and maximum values given in the arrays 2441 * are between the minimum and maximum values given in the arrays
2429 * table->extra1 and table->extra2, respectively. 2442 * table->extra1 and table->extra2, respectively.
2430 */ 2443 */
2431int sysctl_intvec(ctl_table *table, int __user *name, int nlen, 2444int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
2432 void __user *oldval, size_t __user *oldlenp, 2445 void __user *oldval, size_t __user *oldlenp,
2433 void __user *newval, size_t newlen) 2446 void __user *newval, size_t newlen)
2434{ 2447{
@@ -2464,7 +2477,7 @@ int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2464} 2477}
2465 2478
2466/* Strategy function to convert jiffies to seconds */ 2479/* Strategy function to convert jiffies to seconds */
2467int sysctl_jiffies(ctl_table *table, int __user *name, int nlen, 2480int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
2468 void __user *oldval, size_t __user *oldlenp, 2481 void __user *oldval, size_t __user *oldlenp,
2469 void __user *newval, size_t newlen) 2482 void __user *newval, size_t newlen)
2470{ 2483{
@@ -2498,7 +2511,7 @@ int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2498} 2511}
2499 2512
2500/* Strategy function to convert jiffies to seconds */ 2513/* Strategy function to convert jiffies to seconds */
2501int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, 2514int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
2502 void __user *oldval, size_t __user *oldlenp, 2515 void __user *oldval, size_t __user *oldlenp,
2503 void __user *newval, size_t newlen) 2516 void __user *newval, size_t newlen)
2504{ 2517{
@@ -2538,59 +2551,50 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2538 2551
2539asmlinkage long sys_sysctl(struct __sysctl_args __user *args) 2552asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2540{ 2553{
2541 static int msg_count;
2542 struct __sysctl_args tmp; 2554 struct __sysctl_args tmp;
2543 int name[CTL_MAXNAME]; 2555 int error;
2544 int i;
2545 2556
2546 /* Read in the sysctl name for better debug message logging */
2547 if (copy_from_user(&tmp, args, sizeof(tmp))) 2557 if (copy_from_user(&tmp, args, sizeof(tmp)))
2548 return -EFAULT; 2558 return -EFAULT;
2549 if (tmp.nlen <= 0 || tmp.nlen >= CTL_MAXNAME)
2550 return -ENOTDIR;
2551 for (i = 0; i < tmp.nlen; i++)
2552 if (get_user(name[i], tmp.name + i))
2553 return -EFAULT;
2554 2559
2555 /* Ignore accesses to kernel.version */ 2560 error = deprecated_sysctl_warning(&tmp);
2556 if ((tmp.nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
2557 goto out;
2558 2561
2559 if (msg_count < 5) { 2562 /* If no error reading the parameters then just -ENOSYS ... */
2560 msg_count++; 2563 if (!error)
2561 printk(KERN_INFO 2564 error = -ENOSYS;
2562 "warning: process `%s' used the removed sysctl " 2565
2563 "system call with ", current->comm); 2566 return error;
2564 for (i = 0; i < tmp.nlen; i++) 2567}
2565 printk("%d.", name[i]); 2568
2566 printk("\n"); 2569int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2567 } 2570 void __user *oldval, size_t __user *oldlenp,
2568out: 2571 void __user *newval, size_t newlen)
2572{
2569 return -ENOSYS; 2573 return -ENOSYS;
2570} 2574}
2571 2575
2572int sysctl_string(ctl_table *table, int __user *name, int nlen, 2576int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
2573 void __user *oldval, size_t __user *oldlenp, 2577 void __user *oldval, size_t __user *oldlenp,
2574 void __user *newval, size_t newlen) 2578 void __user *newval, size_t newlen)
2575{ 2579{
2576 return -ENOSYS; 2580 return -ENOSYS;
2577} 2581}
2578 2582
2579int sysctl_intvec(ctl_table *table, int __user *name, int nlen, 2583int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
2580 void __user *oldval, size_t __user *oldlenp, 2584 void __user *oldval, size_t __user *oldlenp,
2581 void __user *newval, size_t newlen) 2585 void __user *newval, size_t newlen)
2582{ 2586{
2583 return -ENOSYS; 2587 return -ENOSYS;
2584} 2588}
2585 2589
2586int sysctl_jiffies(ctl_table *table, int __user *name, int nlen, 2590int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
2587 void __user *oldval, size_t __user *oldlenp, 2591 void __user *oldval, size_t __user *oldlenp,
2588 void __user *newval, size_t newlen) 2592 void __user *newval, size_t newlen)
2589{ 2593{
2590 return -ENOSYS; 2594 return -ENOSYS;
2591} 2595}
2592 2596
2593int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, 2597int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
2594 void __user *oldval, size_t __user *oldlenp, 2598 void __user *oldval, size_t __user *oldlenp,
2595 void __user *newval, size_t newlen) 2599 void __user *newval, size_t newlen)
2596{ 2600{
@@ -2599,6 +2603,33 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2599 2603
2600#endif /* CONFIG_SYSCTL_SYSCALL */ 2604#endif /* CONFIG_SYSCTL_SYSCALL */
2601 2605
2606static int deprecated_sysctl_warning(struct __sysctl_args *args)
2607{
2608 static int msg_count;
2609 int name[CTL_MAXNAME];
2610 int i;
2611
2612 /* Read in the sysctl name for better debug message logging */
2613 for (i = 0; i < args->nlen; i++)
2614 if (get_user(name[i], args->name + i))
2615 return -EFAULT;
2616
2617 /* Ignore accesses to kernel.version */
2618 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
2619 return 0;
2620
2621 if (msg_count < 5) {
2622 msg_count++;
2623 printk(KERN_INFO
2624 "warning: process `%s' used the deprecated sysctl "
2625 "system call with ", current->comm);
2626 for (i = 0; i < args->nlen; i++)
2627 printk("%d.", name[i]);
2628 printk("\n");
2629 }
2630 return 0;
2631}
2632
2602/* 2633/*
2603 * No sense putting this after each symbol definition, twice, 2634 * No sense putting this after each symbol definition, twice,
2604 * exception granted :-) 2635 * exception granted :-)
@@ -2616,4 +2647,5 @@ EXPORT_SYMBOL(sysctl_intvec);
2616EXPORT_SYMBOL(sysctl_jiffies); 2647EXPORT_SYMBOL(sysctl_jiffies);
2617EXPORT_SYMBOL(sysctl_ms_jiffies); 2648EXPORT_SYMBOL(sysctl_ms_jiffies);
2618EXPORT_SYMBOL(sysctl_string); 2649EXPORT_SYMBOL(sysctl_string);
2650EXPORT_SYMBOL(sysctl_data);
2619EXPORT_SYMBOL(unregister_sysctl_table); 2651EXPORT_SYMBOL(unregister_sysctl_table);