提交 c4b8b769 编写于 作者: E Eric W. Biederman 提交者: Linus Torvalds

[PATCH] sysctl: implement sysctl_uts_string()

The problem: When using sys_sysctl we don't read the proper values for the
variables exported from the uts namespace, nor do we do the proper locking.

This patch introduces sysctl_uts_string which properly fetches the values and
does the proper locking.
Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 cf9f151c
...@@ -137,6 +137,10 @@ static int parse_table(int __user *, int, void __user *, size_t __user *, ...@@ -137,6 +137,10 @@ static int parse_table(int __user *, int, void __user *, size_t __user *,
static int proc_do_uts_string(ctl_table *table, int write, struct file *filp, static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos); 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, void **context);
#ifdef CONFIG_PROC_SYSCTL #ifdef CONFIG_PROC_SYSCTL
static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp, static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
void __user *buffer, size_t *lenp, loff_t *ppos); void __user *buffer, size_t *lenp, loff_t *ppos);
...@@ -258,7 +262,7 @@ static ctl_table kern_table[] = { ...@@ -258,7 +262,7 @@ static ctl_table kern_table[] = {
.maxlen = sizeof(init_uts_ns.name.sysname), .maxlen = sizeof(init_uts_ns.name.sysname),
.mode = 0444, .mode = 0444,
.proc_handler = &proc_do_uts_string, .proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string, .strategy = &sysctl_uts_string,
}, },
{ {
.ctl_name = KERN_OSRELEASE, .ctl_name = KERN_OSRELEASE,
...@@ -267,7 +271,7 @@ static ctl_table kern_table[] = { ...@@ -267,7 +271,7 @@ static ctl_table kern_table[] = {
.maxlen = sizeof(init_uts_ns.name.release), .maxlen = sizeof(init_uts_ns.name.release),
.mode = 0444, .mode = 0444,
.proc_handler = &proc_do_uts_string, .proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string, .strategy = &sysctl_uts_string,
}, },
{ {
.ctl_name = KERN_VERSION, .ctl_name = KERN_VERSION,
...@@ -276,7 +280,7 @@ static ctl_table kern_table[] = { ...@@ -276,7 +280,7 @@ static ctl_table kern_table[] = {
.maxlen = sizeof(init_uts_ns.name.version), .maxlen = sizeof(init_uts_ns.name.version),
.mode = 0444, .mode = 0444,
.proc_handler = &proc_do_uts_string, .proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string, .strategy = &sysctl_uts_string,
}, },
{ {
.ctl_name = KERN_NODENAME, .ctl_name = KERN_NODENAME,
...@@ -285,7 +289,7 @@ static ctl_table kern_table[] = { ...@@ -285,7 +289,7 @@ static ctl_table kern_table[] = {
.maxlen = sizeof(init_uts_ns.name.nodename), .maxlen = sizeof(init_uts_ns.name.nodename),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_do_uts_string, .proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string, .strategy = &sysctl_uts_string,
}, },
{ {
.ctl_name = KERN_DOMAINNAME, .ctl_name = KERN_DOMAINNAME,
...@@ -294,7 +298,7 @@ static ctl_table kern_table[] = { ...@@ -294,7 +298,7 @@ static ctl_table kern_table[] = {
.maxlen = sizeof(init_uts_ns.name.domainname), .maxlen = sizeof(init_uts_ns.name.domainname),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_do_uts_string, .proc_handler = &proc_do_uts_string,
.strategy = &sysctl_string, .strategy = &sysctl_uts_string,
}, },
{ {
.ctl_name = KERN_PANIC, .ctl_name = KERN_PANIC,
...@@ -2598,6 +2602,23 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, ...@@ -2598,6 +2602,23 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
return 1; return 1;
} }
/* 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, void **context)
{
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, context);
put_uts(table, write, uts_table.data);
return r;
}
#else /* CONFIG_SYSCTL_SYSCALL */ #else /* CONFIG_SYSCTL_SYSCALL */
...@@ -2662,6 +2683,12 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen, ...@@ -2662,6 +2683,12 @@ int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
return -ENOSYS; 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, void **context)
{
return -ENOSYS;
}
#endif /* CONFIG_SYSCTL_SYSCALL */ #endif /* CONFIG_SYSCTL_SYSCALL */
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册