aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sysctl.c138
1 files changed, 119 insertions, 19 deletions
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 8f3f00d5ee52..476ac2522f18 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -139,7 +139,7 @@ static int parse_table(int __user *, int, void __user *, size_t __user *,
139 void __user *, size_t, ctl_table *, void **); 139 void __user *, size_t, ctl_table *, void **);
140#endif 140#endif
141 141
142static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 142static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
143 void __user *buffer, size_t *lenp, loff_t *ppos); 143 void __user *buffer, size_t *lenp, loff_t *ppos);
144 144
145static ctl_table root_table[]; 145static ctl_table root_table[];
@@ -229,51 +229,100 @@ static ctl_table root_table[] = {
229}; 229};
230 230
231static ctl_table kern_table[] = { 231static ctl_table kern_table[] = {
232#ifndef CONFIG_UTS_NS
232 { 233 {
233 .ctl_name = KERN_OSTYPE, 234 .ctl_name = KERN_OSTYPE,
234 .procname = "ostype", 235 .procname = "ostype",
235 .data = system_utsname.sysname, 236 .data = init_uts_ns.name.sysname,
236 .maxlen = sizeof(system_utsname.sysname), 237 .maxlen = sizeof(init_uts_ns.name.sysname),
237 .mode = 0444, 238 .mode = 0444,
238 .proc_handler = &proc_doutsstring, 239 .proc_handler = &proc_do_uts_string,
239 .strategy = &sysctl_string, 240 .strategy = &sysctl_string,
240 }, 241 },
241 { 242 {
242 .ctl_name = KERN_OSRELEASE, 243 .ctl_name = KERN_OSRELEASE,
243 .procname = "osrelease", 244 .procname = "osrelease",
244 .data = system_utsname.release, 245 .data = init_uts_ns.name.release,
245 .maxlen = sizeof(system_utsname.release), 246 .maxlen = sizeof(init_uts_ns.name.release),
246 .mode = 0444, 247 .mode = 0444,
247 .proc_handler = &proc_doutsstring, 248 .proc_handler = &proc_do_uts_string,
248 .strategy = &sysctl_string, 249 .strategy = &sysctl_string,
249 }, 250 },
250 { 251 {
251 .ctl_name = KERN_VERSION, 252 .ctl_name = KERN_VERSION,
252 .procname = "version", 253 .procname = "version",
253 .data = system_utsname.version, 254 .data = init_uts_ns.name.version,
254 .maxlen = sizeof(system_utsname.version), 255 .maxlen = sizeof(init_uts_ns.name.version),
255 .mode = 0444, 256 .mode = 0444,
256 .proc_handler = &proc_doutsstring, 257 .proc_handler = &proc_do_uts_string,
257 .strategy = &sysctl_string, 258 .strategy = &sysctl_string,
258 }, 259 },
259 { 260 {
260 .ctl_name = KERN_NODENAME, 261 .ctl_name = KERN_NODENAME,
261 .procname = "hostname", 262 .procname = "hostname",
262 .data = system_utsname.nodename, 263 .data = init_uts_ns.name.nodename,
263 .maxlen = sizeof(system_utsname.nodename), 264 .maxlen = sizeof(init_uts_ns.name.nodename),
264 .mode = 0644, 265 .mode = 0644,
265 .proc_handler = &proc_doutsstring, 266 .proc_handler = &proc_do_uts_string,
266 .strategy = &sysctl_string, 267 .strategy = &sysctl_string,
267 }, 268 },
268 { 269 {
269 .ctl_name = KERN_DOMAINNAME, 270 .ctl_name = KERN_DOMAINNAME,
270 .procname = "domainname", 271 .procname = "domainname",
271 .data = system_utsname.domainname, 272 .data = init_uts_ns.name.domainname,
272 .maxlen = sizeof(system_utsname.domainname), 273 .maxlen = sizeof(init_uts_ns.name.domainname),
273 .mode = 0644, 274 .mode = 0644,
274 .proc_handler = &proc_doutsstring, 275 .proc_handler = &proc_do_uts_string,
275 .strategy = &sysctl_string, 276 .strategy = &sysctl_string,
276 }, 277 },
278#else /* !CONFIG_UTS_NS */
279 {
280 .ctl_name = KERN_OSTYPE,
281 .procname = "ostype",
282 .data = NULL,
283 /* could maybe use __NEW_UTS_LEN here? */
284 .maxlen = FIELD_SIZEOF(struct new_utsname, sysname),
285 .mode = 0444,
286 .proc_handler = &proc_do_uts_string,
287 .strategy = &sysctl_string,
288 },
289 {
290 .ctl_name = KERN_OSRELEASE,
291 .procname = "osrelease",
292 .data = NULL,
293 .maxlen = FIELD_SIZEOF(struct new_utsname, release),
294 .mode = 0444,
295 .proc_handler = &proc_do_uts_string,
296 .strategy = &sysctl_string,
297 },
298 {
299 .ctl_name = KERN_VERSION,
300 .procname = "version",
301 .data = NULL,
302 .maxlen = FIELD_SIZEOF(struct new_utsname, version),
303 .mode = 0444,
304 .proc_handler = &proc_do_uts_string,
305 .strategy = &sysctl_string,
306 },
307 {
308 .ctl_name = KERN_NODENAME,
309 .procname = "hostname",
310 .data = NULL,
311 .maxlen = FIELD_SIZEOF(struct new_utsname, nodename),
312 .mode = 0644,
313 .proc_handler = &proc_do_uts_string,
314 .strategy = &sysctl_string,
315 },
316 {
317 .ctl_name = KERN_DOMAINNAME,
318 .procname = "domainname",
319 .data = NULL,
320 .maxlen = FIELD_SIZEOF(struct new_utsname, domainname),
321 .mode = 0644,
322 .proc_handler = &proc_do_uts_string,
323 .strategy = &sysctl_string,
324 },
325#endif /* !CONFIG_UTS_NS */
277 { 326 {
278 .ctl_name = KERN_PANIC, 327 .ctl_name = KERN_PANIC,
279 .procname = "panic", 328 .procname = "panic",
@@ -1704,7 +1753,8 @@ int proc_dostring(ctl_table *table, int write, struct file *filp,
1704 * to observe. Should this be in kernel/sys.c ???? 1753 * to observe. Should this be in kernel/sys.c ????
1705 */ 1754 */
1706 1755
1707static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 1756#ifndef CONFIG_UTS_NS
1757static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
1708 void __user *buffer, size_t *lenp, loff_t *ppos) 1758 void __user *buffer, size_t *lenp, loff_t *ppos)
1709{ 1759{
1710 int r; 1760 int r;
@@ -1720,6 +1770,48 @@ static int proc_doutsstring(ctl_table *table, int write, struct file *filp,
1720 } 1770 }
1721 return r; 1771 return r;
1722} 1772}
1773#else /* !CONFIG_UTS_NS */
1774static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
1775 void __user *buffer, size_t *lenp, loff_t *ppos)
1776{
1777 int r;
1778 struct uts_namespace* uts_ns = current->nsproxy->uts_ns;
1779 char* which;
1780
1781 switch (table->ctl_name) {
1782 case KERN_OSTYPE:
1783 which = uts_ns->name.sysname;
1784 break;
1785 case KERN_NODENAME:
1786 which = uts_ns->name.nodename;
1787 break;
1788 case KERN_OSRELEASE:
1789 which = uts_ns->name.release;
1790 break;
1791 case KERN_VERSION:
1792 which = uts_ns->name.version;
1793 break;
1794 case KERN_DOMAINNAME:
1795 which = uts_ns->name.domainname;
1796 break;
1797 default:
1798 r = -EINVAL;
1799 goto out;
1800 }
1801
1802 if (!write) {
1803 down_read(&uts_sem);
1804 r=_proc_do_string(which,table->maxlen,0,filp,buffer,lenp, ppos);
1805 up_read(&uts_sem);
1806 } else {
1807 down_write(&uts_sem);
1808 r=_proc_do_string(which,table->maxlen,1,filp,buffer,lenp, ppos);
1809 up_write(&uts_sem);
1810 }
1811 out:
1812 return r;
1813}
1814#endif /* !CONFIG_UTS_NS */
1723 1815
1724static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp, 1816static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1725 int *valp, 1817 int *valp,
@@ -2283,12 +2375,20 @@ int proc_dostring(ctl_table *table, int write, struct file *filp,
2283 return -ENOSYS; 2375 return -ENOSYS;
2284} 2376}
2285 2377
2286static int proc_doutsstring(ctl_table *table, int write, struct file *filp, 2378static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
2287 void __user *buffer, size_t *lenp, loff_t *ppos) 2379 void __user *buffer, size_t *lenp, loff_t *ppos)
2288{ 2380{
2289 return -ENOSYS; 2381 return -ENOSYS;
2290} 2382}
2291 2383
2384#ifdef CONFIG_SYSVIPC
2385static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
2386 void __user *buffer, size_t *lenp, loff_t *ppos)
2387{
2388 return -ENOSYS;
2389}
2390#endif
2391
2292int proc_dointvec(ctl_table *table, int write, struct file *filp, 2392int proc_dointvec(ctl_table *table, int write, struct file *filp,
2293 void __user *buffer, size_t *lenp, loff_t *ppos) 2393 void __user *buffer, size_t *lenp, loff_t *ppos)
2294{ 2394{