Commit 1557d330 authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/sysctl-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/sysctl-2.6: (43 commits)
  security/tomoyo: Remove now unnecessary handling of security_sysctl.
  security/tomoyo: Add a special case to handle accesses through the internal proc mount.
  sysctl: Drop & in front of every proc_handler.
  sysctl: Remove CTL_NONE and CTL_UNNUMBERED
  sysctl: kill dead ctl_handler definitions.
  sysctl: Remove the last of the generic binary sysctl support
  sysctl net: Remove unused binary sysctl code
  sysctl security/tomoyo: Don't look at ctl_name
  sysctl arm: Remove binary sysctl support
  sysctl x86: Remove dead binary sysctl support
  sysctl sh: Remove dead binary sysctl support
  sysctl powerpc: Remove dead binary sysctl support
  sysctl ia64: Remove dead binary sysctl support
  sysctl s390: Remove dead sysctl binary support
  sysctl frv: Remove dead binary sysctl support
  sysctl mips/lasat: Remove dead binary sysctl support
  sysctl drivers: Remove dead binary sysctl support
  sysctl crypto: Remove dead binary sysctl support
  sysctl security/keys: Remove dead binary sysctl support
  sysctl kernel: Remove binary sysctl logic
  ...
parents 6ec22f9b c656ae95
Except for a few extremely rare exceptions user space applications do not use
the binary sysctl interface. Instead everyone uses /proc/sys/... with
readable ascii names.
Recently the kernel has started supporting setting the binary sysctl value to
CTL_UNNUMBERED so we no longer need to assign a binary sysctl path to allow
sysctls to show up in /proc/sys.
Assigning binary sysctl numbers is an endless source of conflicts in sysctl.h,
breaking of the user space ABI (because of those conflicts), and maintenance
problems. A complete pass through all of the sysctl users revealed multiple
instances where the sysctl binary interface was broken and had gone undetected
for years.
So please do not add new binary sysctl numbers. They are unneeded and
problematic.
If you really need a new binary sysctl number please first merge your sysctl
into the kernel and then as a separate patch allocate a binary sysctl number.
(ebiederm@xmission.com, June 2007)
......@@ -22,47 +22,42 @@ static unsigned int isa_membase, isa_portbase, isa_portshift;
static ctl_table ctl_isa_vars[4] = {
{
.ctl_name = BUS_ISA_MEM_BASE,
.procname = "membase",
.data = &isa_membase,
.maxlen = sizeof(isa_membase),
.mode = 0444,
.proc_handler = &proc_dointvec,
.proc_handler = proc_dointvec,
}, {
.ctl_name = BUS_ISA_PORT_BASE,
.procname = "portbase",
.data = &isa_portbase,
.maxlen = sizeof(isa_portbase),
.mode = 0444,
.proc_handler = &proc_dointvec,
.proc_handler = proc_dointvec,
}, {
.ctl_name = BUS_ISA_PORT_SHIFT,
.procname = "portshift",
.data = &isa_portshift,
.maxlen = sizeof(isa_portshift),
.mode = 0444,
.proc_handler = &proc_dointvec,
}, {0}
.proc_handler = proc_dointvec,
}, {}
};
static struct ctl_table_header *isa_sysctl_header;
static ctl_table ctl_isa[2] = {
{
.ctl_name = CTL_BUS_ISA,
.procname = "isa",
.mode = 0555,
.child = ctl_isa_vars,
}, {0}
}, {}
};
static ctl_table ctl_bus[2] = {
{
.ctl_name = CTL_BUS,
.procname = "bus",
.mode = 0555,
.child = ctl_isa,
}, {0}
}, {}
};
void __init
......
......@@ -47,10 +47,6 @@ HW_DECLARE_SPINLOCK(gpio)
EXPORT_SYMBOL(bcmring_gpio_reg_lock);
#endif
/* FIXME: temporary solution */
#define BCM_SYSCTL_REBOOT_WARM 1
#define CTL_BCM_REBOOT 112
/* sysctl */
int bcmring_arch_warm_reboot; /* do a warm reboot on hard reset */
......@@ -58,18 +54,16 @@ static struct ctl_table_header *bcmring_sysctl_header;
static struct ctl_table bcmring_sysctl_warm_reboot[] = {
{
.ctl_name = BCM_SYSCTL_REBOOT_WARM,
.procname = "warm",
.data = &bcmring_arch_warm_reboot,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec},
.proc_handler = proc_dointvec},
{}
};
static struct ctl_table bcmring_sysctl_reboot[] = {
{
.ctl_name = CTL_BCM_REBOOT,
.procname = "reboot",
.mode = 0555,
.child = bcmring_sysctl_warm_reboot},
......
......@@ -211,37 +211,6 @@ static int cmode_procctl(ctl_table *ctl, int write,
return try_set_cmode(new_cmode)?:*lenp;
}
static int cmode_sysctl(ctl_table *table,
void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen)
{
if (oldval && oldlenp) {
size_t oldlen;
if (get_user(oldlen, oldlenp))
return -EFAULT;
if (oldlen != sizeof(int))
return -EINVAL;
if (put_user(clock_cmode_current, (unsigned __user *)oldval) ||
put_user(sizeof(int), oldlenp))
return -EFAULT;
}
if (newval && newlen) {
int new_cmode;
if (newlen != sizeof(int))
return -EINVAL;
if (get_user(new_cmode, (int __user *)newval))
return -EFAULT;
return try_set_cmode(new_cmode)?:1;
}
return 1;
}
static int try_set_p0(int new_p0)
{
unsigned long flags, clkc;
......@@ -314,37 +283,6 @@ static int p0_procctl(ctl_table *ctl, int write,
return try_set_p0(new_p0)?:*lenp;
}
static int p0_sysctl(ctl_table *table,
void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen)
{
if (oldval && oldlenp) {
size_t oldlen;
if (get_user(oldlen, oldlenp))
return -EFAULT;
if (oldlen != sizeof(int))
return -EINVAL;
if (put_user(clock_p0_current, (unsigned __user *)oldval) ||
put_user(sizeof(int), oldlenp))
return -EFAULT;
}
if (newval && newlen) {
int new_p0;
if (newlen != sizeof(int))
return -EINVAL;
if (get_user(new_p0, (int __user *)newval))
return -EFAULT;
return try_set_p0(new_p0)?:1;
}
return 1;
}
static int cm_procctl(ctl_table *ctl, int write,
void __user *buffer, size_t *lenp, loff_t *fpos)
{
......@@ -358,87 +296,47 @@ static int cm_procctl(ctl_table *ctl, int write,
return try_set_cm(new_cm)?:*lenp;
}
static int cm_sysctl(ctl_table *table,
void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen)
{
if (oldval && oldlenp) {
size_t oldlen;
if (get_user(oldlen, oldlenp))
return -EFAULT;
if (oldlen != sizeof(int))
return -EINVAL;
if (put_user(clock_cm_current, (unsigned __user *)oldval) ||
put_user(sizeof(int), oldlenp))
return -EFAULT;
}
if (newval && newlen) {
int new_cm;
if (newlen != sizeof(int))
return -EINVAL;
if (get_user(new_cm, (int __user *)newval))
return -EFAULT;
return try_set_cm(new_cm)?:1;
}
return 1;
}
static struct ctl_table pm_table[] =
{
{
.ctl_name = CTL_PM_SUSPEND,
.procname = "suspend",
.data = NULL,
.maxlen = 0,
.mode = 0200,
.proc_handler = &sysctl_pm_do_suspend,
.proc_handler = sysctl_pm_do_suspend,
},
{
.ctl_name = CTL_PM_CMODE,
.procname = "cmode",
.data = &clock_cmode_current,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &cmode_procctl,
.strategy = &cmode_sysctl,
.proc_handler = cmode_procctl,
},
{
.ctl_name = CTL_PM_P0,
.procname = "p0",
.data = &clock_p0_current,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &p0_procctl,
.strategy = &p0_sysctl,
.proc_handler = p0_procctl,
},
{
.ctl_name = CTL_PM_CM,
.procname = "cm",
.data = &clock_cm_current,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &cm_procctl,
.strategy = &cm_sysctl,
.proc_handler = cm_procctl,
},
{ .ctl_name = 0}
{ }
};
static struct ctl_table pm_dir_table[] =
{
{
.ctl_name = CTL_PM,
.procname = "pm",
.mode = 0555,
.child = pm_table,
},
{ .ctl_name = 0}
{ }
};
/*
......
......@@ -176,21 +176,19 @@ static int procctl_frv_pin_cxnr(ctl_table *table, int write, struct file *filp,
static struct ctl_table frv_table[] =
{
{
.ctl_name = 1,
.procname = "cache-mode",
.data = NULL,
.maxlen = 0,
.mode = 0644,
.proc_handler = &procctl_frv_cachemode,
.proc_handler = procctl_frv_cachemode,
},
#ifdef CONFIG_MMU
{
.ctl_name = 2,
.procname = "pin-cxnr",
.data = NULL,
.maxlen = 0,
.mode = 0644,
.proc_handler = &procctl_frv_pin_cxnr
.proc_handler = procctl_frv_pin_cxnr
},
#endif
{}
......@@ -203,7 +201,6 @@ static struct ctl_table frv_table[] =
static struct ctl_table frv_dir_table[] =
{
{
.ctl_name = CTL_FRV,
.procname = "frv",
.mode = 0555,
.child = frv_table
......
......@@ -327,7 +327,7 @@ ia32_syscall_table:
data8 compat_sys_writev
data8 sys_getsid
data8 sys_fdatasync
data8 sys32_sysctl
data8 compat_sys_sysctl
data8 sys_mlock /* 150 */
data8 sys_munlock
data8 sys_mlockall
......
......@@ -1628,61 +1628,6 @@ sys32_msync (unsigned int start, unsigned int len, int flags)
return sys_msync(addr, len + (start - addr), flags);
}
struct sysctl32 {
unsigned int name;
int nlen;
unsigned int oldval;
unsigned int oldlenp;
unsigned int newval;
unsigned int newlen;
unsigned int __unused[4];
};
#ifdef CONFIG_SYSCTL_SYSCALL
asmlinkage long
sys32_sysctl (struct sysctl32 __user *args)
{
struct sysctl32 a32;
mm_segment_t old_fs = get_fs ();
void __user *oldvalp, *newvalp;
size_t oldlen;
int __user *namep;
long ret;
if (copy_from_user(&a32, args, sizeof(a32)))
return -EFAULT;
/*
* We need to pre-validate these because we have to disable address checking
* before calling do_sysctl() because of OLDLEN but we can't run the risk of the
* user specifying bad addresses here. Well, since we're dealing with 32 bit
* addresses, we KNOW that access_ok() will always succeed, so this is an
* expensive NOP, but so what...
*/
namep = (int __user *) compat_ptr(a32.name);
oldvalp = compat_ptr(a32.oldval);
newvalp = compat_ptr(a32.newval);
if ((oldvalp && get_user(oldlen, (int __user *) compat_ptr(a32.oldlenp)))
|| !access_ok(VERIFY_WRITE, namep, 0)
|| !access_ok(VERIFY_WRITE, oldvalp, 0)
|| !access_ok(VERIFY_WRITE, newvalp, 0))
return -EFAULT;
set_fs(KERNEL_DS);
lock_kernel();
ret = do_sysctl(namep, a32.nlen, oldvalp, (size_t __user *) &oldlen,
newvalp, (size_t) a32.newlen);
unlock_kernel();
set_fs(old_fs);
if (oldvalp && put_user (oldlen, (int __user *) compat_ptr(a32.oldlenp)))
return -EFAULT;
return ret;
}
#endif
asmlinkage long
sys32_newuname (struct new_utsname __user *name)
{
......
......@@ -239,32 +239,29 @@ kdump_init_notifier(struct notifier_block *self, unsigned long val, void *data)
#ifdef CONFIG_SYSCTL
static ctl_table kdump_ctl_table[] = {
{
.ctl_name = CTL_UNNUMBERED,
.procname = "kdump_on_init",
.data = &kdump_on_init,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec,
.proc_handler = proc_dointvec,
},
{
.ctl_name = CTL_UNNUMBERED,
.procname = "kdump_on_fatal_mca",
.data = &kdump_on_fatal_mca,
.maxlen = sizeof(int),
.mode = 0644,
.proc_handler = &proc_dointvec,
.proc_handler = proc_dointvec,
},
{ .ctl_name = 0 }
{ }
};
static ctl_table sys_table[] = {
{
.ctl_name = CTL_KERN,
.procname = "kernel",
.mode = 0555,
.child = kdump_ctl_table,
},
{ .ctl_name = 0 }
{ }
};
#endif
......
......@@ -522,42 +522,37 @@ EXPORT_SYMBOL(pfm_sysctl);
static ctl_table pfm_ctl_table[]={
{
.ctl_name = CTL_UNNUMBERED,
.procname = "debug",
.data = &pfm_sysctl.debug,
.maxlen = sizeof(int),
.mode = 0666,
.proc_handler = &proc_dointvec,
.proc_handler = proc_dointvec,
},
{
.ctl_name = CTL_UNNUMBERED,
.procname = "debug_ovfl",
.data = &pfm_sysctl.debug_ovfl,
.maxlen = sizeof(int),
.mode = 0666,
.proc_handler = &proc_dointvec,
.proc_handler = proc_dointvec,
},
{
.ctl_name = CTL_UNNUMBERED,
.procname = "fastctxsw",
.data = &pfm_sysctl.fastctxsw,
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = &proc_dointvec,
.proc_handler = proc_dointvec,
},
{
.ctl_name = CTL_UNNUMBERED,
.procname = "expert_mode",
.data = &pfm_sysctl.expert_mode,
.maxlen = sizeof(int),
.mode = 0600,
.proc_handler = &proc_dointvec,
.proc_handler = proc_dointvec,
},
{}
};
static ctl_table pfm_sysctl_dir[] = {
{
.ctl_name = CTL_UNNUMBERED,
.procname = "perfmon",
.mode = 0555,
.child = pfm_ctl_table,
......@@ -566,7 +561,6 @@ static ctl_table pfm_sysctl_dir[] = {
};
static ctl_table pfm_sysctl_root[] = {
{
.ctl_name = CTL_KERN,
.procname = "kernel",
.mode = 0555,
.child = pfm_sysctl_dir,
......
......@@ -265,67 +265,6 @@ SYSCALL_DEFINE5(n32_msgrcv, int, msqid, u32, msgp, size_t, msgsz,
}
#endif
struct sysctl_args32
{
compat_caddr_t name;
int nlen;
compat_caddr_t oldval;
compat_caddr_t oldlenp;
compat_caddr_t newval;
compat_size_t newlen;
unsigned int __unused[4];
};
#ifdef CONFIG_SYSCTL_SYSCALL
SYSCALL_DEFINE1(32_sysctl, struct sysctl_args32 __user *, args)
{
struct sysctl_args32 tmp;
int error;
size_t oldlen;
size_t __user *oldlenp = NULL;
unsigned long addr = (((unsigned long)&args->__unused[0]) + 7) & ~7;
if (copy_from_user(&tmp, args, sizeof(tmp)))
return -EFAULT;
if (tmp.oldval && tmp.oldlenp) {
/* Duh, this is ugly and might not work if sysctl_args
is in read-only memory, but do_sysctl does indirectly
a lot of uaccess in both directions and we'd have to
basically copy the whole sysctl.c here, and
glibc's __sysctl uses rw memory for the structure
anyway. */
if (get_user(oldlen, (u32 __user *)A(tmp.oldlenp)) ||
put_user(oldlen, (size_t __user *)addr))
return -EFAULT;
oldlenp = (size_t __user *)addr;
}
lock_kernel();
error = do_sysctl((int __user *)A(tmp.name), tmp.nlen, (void __user *)A(tmp.oldval),
oldlenp, (void __user *)A(tmp.newval), tmp.newlen);
unlock_kernel();
if (oldlenp) {
if (!error) {
if (get_user(oldlen, (size_t __user *)addr) ||
put_user(oldlen, (u32 __user *)A(tmp.oldlenp)))
error = -EFAULT;
}
copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused));
}
return error;
}
#else
SYSCALL_DEFINE1(32_sysctl, struct sysctl_args32 __user *, args)
{
return -ENOSYS;
}
#endif /* CONFIG_SYSCTL_SYSCALL */
SYSCALL_DEFINE1(32_newuname, struct new_utsname __user *, name)
{
int ret = 0;
......
......@@ -272,7 +272,7 @@ EXPORT(sysn32_call_table)
PTR sys_munlockall
PTR sys_vhangup /* 6150 */
PTR sys_pivot_root
PTR sys_32_sysctl
PTR compat_sys_sysctl
PTR sys_prctl
PTR compat_sys_adjtimex
PTR compat_sys_setrlimit /* 6155 */
......
......@@ -356,7 +356,7 @@ sys_call_table:
PTR sys_ni_syscall /* 4150 */
PTR sys_getsid
PTR sys_fdatasync
PTR sys_32_sysctl
PTR compat_sys_sysctl
PTR sys_mlock
PTR sys_munlock /* 4155 */
PTR sys_mlockall
......
......@@ -37,23 +37,6 @@
#include "ds1603.h"
#endif
/* Strategy function to write EEPROM after changing string entry */
int sysctl_lasatstring(ctl_table *table,
void *oldval, size_t *oldlenp,
void *newval, size_t newlen)
{
int r;
r = sysctl_string(table, oldval, oldlenp, newval, newlen);
if (r < 0)
return r;
if (newval && newlen)
lasat_write_eeprom_info();
return 0;
}
/* And the same for proc */
int proc_dolasatstring(ctl_table *table, int write,
......@@ -113,46 +96,6 @@ int proc_dolasatrtc(ctl_table *table, int write,
}
#endif
/* Sysctl for setting the IP addresses */
int sysctl_lasat_intvec(ctl_table *table,
void *oldval, size_t *oldlenp,
void *newval, size_t newlen)
{
int r;
r = sysctl_intvec(table, oldval, oldlenp, newval, newlen);
if (r < 0)
return r;
if (newval && newlen)
lasat_write_eeprom_info();
return 0;
}
#ifdef CONFIG_DS1603
/* Same for RTC */
int sysctl_lasat_rtc(ctl_table *table,
void *oldval, size_t *oldlenp,
void *newval, size_t newlen)
{
struct timespec ts;
int r;
read_persistent_clock(&ts);
rtctmp = ts.tv_sec;
if (rtctmp < 0)
rtctmp = 0;
r = sysctl_intvec(table, oldval, oldlenp, newval, newlen);
if (r < 0)
return r;
if (newval && newlen)
rtc_mips_set_mmss(rtctmp);
return r;
}
#endif
#ifdef CONFIG_INET
int proc_lasat_ip(ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
......@@ -214,23 +157,6 @@ int proc_lasat_ip(ctl_table *table, int write,
}
#endif
static int sysctl_lasat_prid(ctl_table *table,
void *oldval, size_t *oldlenp,
void *newval, size_t newlen)