Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 48381
b: refs/heads/master
c: 39732ac
h: refs/heads/master
i:
  48379: 4f69a99
v: v3
  • Loading branch information
Eric W. Biederman authored and Linus Torvalds committed Feb 14, 2007
1 parent d3fad79 commit 74156c8
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 118 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b04c3afb2b6e2f902b41bb62b73684d92d7e6c34
refs/heads/master: 39732acd968a007036ff3c504f1e6748024ef548
1 change: 1 addition & 0 deletions trunk/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ obj-$(CONFIG_GENERIC_HARDIRQS) += irq/
obj-$(CONFIG_SECCOMP) += seccomp.o
obj-$(CONFIG_RCU_TORTURE_TEST) += rcutorture.o
obj-$(CONFIG_RELAY) += relay.o
obj-$(CONFIG_SYSCTL) += utsname_sysctl.o
obj-$(CONFIG_UTS_NS) += utsname.o
obj-$(CONFIG_TASK_DELAY_ACCT) += delayacct.o
obj-$(CONFIG_TASKSTATS) += taskstats.o tsacct.o
Expand Down
117 changes: 0 additions & 117 deletions trunk/kernel/sysctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,6 @@ static int parse_table(int __user *, int, void __user *, size_t __user *,
void __user *, size_t, ctl_table *);
#endif

static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos);

static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen);

#ifdef CONFIG_SYSVIPC
static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
void __user *oldval, size_t __user *oldlenp,
Expand Down Expand Up @@ -176,29 +169,6 @@ extern ctl_table inotify_table[];
int sysctl_legacy_va_layout;
#endif


static void *get_uts(ctl_table *table, int write)
{
char *which = table->data;
#ifdef CONFIG_UTS_NS
struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
#endif
if (!write)
down_read(&uts_sem);
else
down_write(&uts_sem);
return which;
}

static void put_uts(ctl_table *table, int write, void *which)
{
if (!write)
up_read(&uts_sem);
else
up_write(&uts_sem);
}

#ifdef CONFIG_SYSVIPC
static void *get_ipc(ctl_table *table, int write)
{
Expand Down Expand Up @@ -277,51 +247,6 @@ static ctl_table root_table[] = {
};

static ctl_table kern_table[] = {
{
.ctl_name = KERN_OSTYPE,
.procname = "ostype",
.data = init_uts_ns.name.sysname,
.maxlen = sizeof(init_uts_ns.name.sysname),
.mode = 0444,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_uts_string,
},
{
.ctl_name = KERN_OSRELEASE,
.procname = "osrelease",
.data = init_uts_ns.name.release,
.maxlen = sizeof(init_uts_ns.name.release),
.mode = 0444,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_uts_string,
},
{
.ctl_name = KERN_VERSION,
.procname = "version",
.data = init_uts_ns.name.version,
.maxlen = sizeof(init_uts_ns.name.version),
.mode = 0444,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_uts_string,
},
{
.ctl_name = KERN_NODENAME,
.procname = "hostname",
.data = init_uts_ns.name.nodename,
.maxlen = sizeof(init_uts_ns.name.nodename),
.mode = 0644,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_uts_string,
},
{
.ctl_name = KERN_DOMAINNAME,
.procname = "domainname",
.data = init_uts_ns.name.domainname,
.maxlen = sizeof(init_uts_ns.name.domainname),
.mode = 0644,
.proc_handler = &proc_do_uts_string,
.strategy = &sysctl_uts_string,
},
{
.ctl_name = KERN_PANIC,
.procname = "panic",
Expand Down Expand Up @@ -1759,21 +1684,6 @@ int proc_dostring(ctl_table *table, int write, struct file *filp,
buffer, lenp, ppos);
}

/*
* Special case of dostring for the UTS structure. This has locks
* to observe. Should this be in kernel/sys.c ????
*/

static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
int r;
void *which;
which = get_uts(table, write);
r = _proc_do_string(which, table->maxlen,write,filp,buffer,lenp, ppos);
put_uts(table, write, which);
return r;
}

static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
int *valp,
Expand Down Expand Up @@ -2410,12 +2320,6 @@ int proc_dostring(ctl_table *table, int write, struct file *filp,
return -ENOSYS;
}

static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
return -ENOSYS;
}

#ifdef CONFIG_SYSVIPC
static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos)
Expand Down Expand Up @@ -2645,21 +2549,6 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
}


/* The generic string strategy routine: */
static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen)
{
struct ctl_table uts_table;
int r, write;
write = newval && newlen;
memcpy(&uts_table, table, sizeof(uts_table));
uts_table.data = get_uts(table, write);
r = sysctl_string(&uts_table, name, nlen,
oldval, oldlenp, newval, newlen);
put_uts(table, write, uts_table.data);
return r;
}

#ifdef CONFIG_SYSVIPC
/* The generic sysctl ipc data routine. */
Expand Down Expand Up @@ -2766,12 +2655,6 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
return -ENOSYS;
}

static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen)
{
return -ENOSYS;
}
#ifdef CONFIG_SYSVIPC
static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
void __user *oldval, size_t __user *oldlenp,
Expand Down
146 changes: 146 additions & 0 deletions trunk/kernel/utsname_sysctl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
* Copyright (C) 2007
*
* Author: Eric Biederman <ebiederm@xmision.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation, version 2 of the
* License.
*/

#include <linux/module.h>
#include <linux/uts.h>
#include <linux/utsname.h>
#include <linux/version.h>
#include <linux/sysctl.h>

static void *get_uts(ctl_table *table, int write)
{
char *which = table->data;
#ifdef CONFIG_UTS_NS
struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
#endif
if (!write)
down_read(&uts_sem);
else
down_write(&uts_sem);
return which;
}

static void put_uts(ctl_table *table, int write, void *which)
{
if (!write)
up_read(&uts_sem);
else
up_write(&uts_sem);
}

#ifdef CONFIG_PROC_FS
/*
* Special case of dostring for the UTS structure. This has locks
* to observe. Should this be in kernel/sys.c ????
*/
static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
struct ctl_table uts_table;
int r;
memcpy(&uts_table, table, sizeof(uts_table));
uts_table.data = get_uts(table, write);
r = proc_dostring(&uts_table,write,filp,buffer,lenp, ppos);
put_uts(table, write, uts_table.data);
return r;
}
#else
#define proc_do_uts_string NULL
#endif


#ifdef CONFIG_SYSCTL_SYSCALL
/* The generic string strategy routine: */
static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
void __user *oldval, size_t __user *oldlenp,
void __user *newval, size_t newlen)
{
struct ctl_table uts_table;
int r, write;
write = newval && newlen;
memcpy(&uts_table, table, sizeof(uts_table));
uts_table.data = get_uts(table, write);
r = sysctl_string(&uts_table, name, nlen,
oldval, oldlenp, newval, newlen);
put_uts(table, write, uts_table.data);
return r;
}
#else
#define sysctl_uts_string NULL
#endif

static struct ctl_table uts_kern_table[] = {
{
.ctl_name = KERN_OSTYPE,
.procname = "ostype",
.data = init_uts_ns.name.sysname,
.maxlen = sizeof(init_uts_ns.name.sysname),
.mode = 0444,
.proc_handler = proc_do_uts_string,
.strategy = sysctl_uts_string,
},
{
.ctl_name = KERN_OSRELEASE,
.procname = "osrelease",
.data = init_uts_ns.name.release,
.maxlen = sizeof(init_uts_ns.name.release),
.mode = 0444,
.proc_handler = proc_do_uts_string,
.strategy = sysctl_uts_string,
},
{
.ctl_name = KERN_VERSION,
.procname = "version",
.data = init_uts_ns.name.version,
.maxlen = sizeof(init_uts_ns.name.version),
.mode = 0444,
.proc_handler = proc_do_uts_string,
.strategy = sysctl_uts_string,
},
{
.ctl_name = KERN_NODENAME,
.procname = "hostname",
.data = init_uts_ns.name.nodename,
.maxlen = sizeof(init_uts_ns.name.nodename),
.mode = 0644,
.proc_handler = proc_do_uts_string,
.strategy = sysctl_uts_string,
},
{
.ctl_name = KERN_DOMAINNAME,
.procname = "domainname",
.data = init_uts_ns.name.domainname,
.maxlen = sizeof(init_uts_ns.name.domainname),
.mode = 0644,
.proc_handler = proc_do_uts_string,
.strategy = sysctl_uts_string,
},
{}
};

static struct ctl_table uts_root_table[] = {
{
.ctl_name = CTL_KERN,
.procname = "kernel",
.mode = 0555,
.child = uts_kern_table,
},
{}
};

static int __init utsname_sysctl_init(void)
{
register_sysctl_table(uts_root_table, 0);
return 0;
}

__initcall(utsname_sysctl_init);

0 comments on commit 74156c8

Please sign in to comment.