1 #include <linux/stat.h>
2 #include <linux/sysctl.h>
3 #include "../fs/xfs/linux-2.6/xfs_sysctl.h"
4 #include <linux/sunrpc/debug.h>
5 #include <linux/string.h>
7 #include <linux/syscalls.h>
8 #include <linux/namei.h>
9 #include <linux/mount.h>
11 #include <linux/nsproxy.h>
12 #include <linux/pid_namespace.h>
13 #include <linux/file.h>
14 #include <linux/ctype.h>
15 #include <linux/smp_lock.h>
17 static int deprecated_sysctl_warning(struct __sysctl_args *args);
19 #ifdef CONFIG_SYSCTL_SYSCALL
21 /* Perform the actual read/write of a sysctl table entry. */
22 static int do_sysctl_strategy(struct ctl_table_root *root,
23 struct ctl_table *table,
24 void __user *oldval, size_t __user *oldlenp,
25 void __user *newval, size_t newlen)
33 if (sysctl_perm(root, table, op))
36 if (table->strategy) {
37 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
44 /* If there is no strategy routine, or if the strategy returns
45 * zero, proceed with automatic r/w */
46 if (table->data && table->maxlen) {
47 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
54 static int parse_table(int __user *name, int nlen,
55 void __user *oldval, size_t __user *oldlenp,
56 void __user *newval, size_t newlen,
57 struct ctl_table_root *root,
58 struct ctl_table *table)
64 if (get_user(n, name))
66 for ( ; table->ctl_name || table->procname; table++) {
69 if (n == table->ctl_name) {
72 if (sysctl_perm(root, table, MAY_EXEC))
79 error = do_sysctl_strategy(root, table,
88 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
89 void __user *newval, size_t newlen)
91 struct ctl_table_header *head;
94 if (nlen <= 0 || nlen >= CTL_MAXNAME)
98 if (!oldlenp || get_user(old_len, oldlenp))
102 for (head = sysctl_head_next(NULL); head;
103 head = sysctl_head_next(head)) {
104 error = parse_table(name, nlen, oldval, oldlenp,
106 head->root, head->ctl_table);
107 if (error != -ENOTDIR) {
108 sysctl_head_finish(head);
115 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
117 struct __sysctl_args tmp;
120 if (copy_from_user(&tmp, args, sizeof(tmp)))
123 error = deprecated_sysctl_warning(&tmp);
128 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
129 tmp.newval, tmp.newlen);
135 #else /* CONFIG_SYSCTL_SYSCALL */
137 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
139 struct __sysctl_args tmp;
142 if (copy_from_user(&tmp, args, sizeof(tmp)))
145 error = deprecated_sysctl_warning(&tmp);
147 /* If no error reading the parameters then just -ENOSYS ... */
154 #endif /* CONFIG_SYSCTL_SYSCALL */
156 static int deprecated_sysctl_warning(struct __sysctl_args *args)
158 static int msg_count;
159 int name[CTL_MAXNAME];
162 /* Check args->nlen. */
163 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
166 /* Read in the sysctl name for better debug message logging */
167 for (i = 0; i < args->nlen; i++)
168 if (get_user(name[i], args->name + i))
171 /* Ignore accesses to kernel.version */
172 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
178 "warning: process `%s' used the deprecated sysctl "
179 "system call with ", current->comm);
180 for (i = 0; i < args->nlen; i++)
181 printk("%d.", name[i]);