forked from Minki/linux
676cb49573
- Valentin Schneider makes crash-kexec work properly when invoked from an NMI-time panic. - ntfs bugfixes from Hawkins Jiawei - Jiebin Sun improves IPC msg scalability by replacing atomic_t's with percpu counters. - nilfs2 cleanups from Minghao Chi - lots of other single patches all over the tree! -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTTMBEPP41GrTpTJgfdBJ7gKXxAjgUCY0Yf0gAKCRDdBJ7gKXxA joapAQDT1d1zu7T8yf9cQXkYnZVuBKCjxKE/IsYvqaq1a42MjQD/SeWZg0wV05B8 DhJPj9nkEp6R3Rj3Mssip+3vNuceAQM= =lUQY -----END PGP SIGNATURE----- Merge tag 'mm-nonmm-stable-2022-10-11' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull non-MM updates from Andrew Morton: - hfs and hfsplus kmap API modernization (Fabio Francesco) - make crash-kexec work properly when invoked from an NMI-time panic (Valentin Schneider) - ntfs bugfixes (Hawkins Jiawei) - improve IPC msg scalability by replacing atomic_t's with percpu counters (Jiebin Sun) - nilfs2 cleanups (Minghao Chi) - lots of other single patches all over the tree! * tag 'mm-nonmm-stable-2022-10-11' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (71 commits) include/linux/entry-common.h: remove has_signal comment of arch_do_signal_or_restart() prototype proc: test how it holds up with mapping'less process mailmap: update Frank Rowand email address ia64: mca: use strscpy() is more robust and safer init/Kconfig: fix unmet direct dependencies ia64: update config files nilfs2: replace WARN_ONs by nilfs_error for checkpoint acquisition failure fork: remove duplicate included header files init/main.c: remove unnecessary (void*) conversions proc: mark more files as permanent nilfs2: remove the unneeded result variable nilfs2: delete unnecessary checks before brelse() checkpatch: warn for non-standard fixes tag style usr/gen_init_cpio.c: remove unnecessary -1 values from int file ipc/msg: mitigate the lock contention with percpu counter percpu: add percpu_counter_add_local and percpu_counter_sub_local fs/ocfs2: fix repeated words in comments relay: use kvcalloc to alloc page array in relay_alloc_page_array proc: make config PROC_CHILDREN depend on PROC_FS fs: uninline inode_maybe_inc_iversion() ...
154 lines
3.5 KiB
C
154 lines
3.5 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (C) 2007
|
|
*
|
|
* Author: Eric Biederman <ebiederm@xmision.com>
|
|
*/
|
|
|
|
#include <linux/export.h>
|
|
#include <linux/uts.h>
|
|
#include <linux/utsname.h>
|
|
#include <linux/random.h>
|
|
#include <linux/sysctl.h>
|
|
#include <linux/wait.h>
|
|
#include <linux/rwsem.h>
|
|
|
|
#ifdef CONFIG_PROC_SYSCTL
|
|
|
|
static void *get_uts(struct ctl_table *table)
|
|
{
|
|
char *which = table->data;
|
|
struct uts_namespace *uts_ns;
|
|
|
|
uts_ns = current->nsproxy->uts_ns;
|
|
which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
|
|
|
|
return which;
|
|
}
|
|
|
|
/*
|
|
* 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(struct ctl_table *table, int write,
|
|
void *buffer, size_t *lenp, loff_t *ppos)
|
|
{
|
|
struct ctl_table uts_table;
|
|
int r;
|
|
char tmp_data[__NEW_UTS_LEN + 1];
|
|
|
|
memcpy(&uts_table, table, sizeof(uts_table));
|
|
uts_table.data = tmp_data;
|
|
|
|
/*
|
|
* Buffer the value in tmp_data so that proc_dostring() can be called
|
|
* without holding any locks.
|
|
* We also need to read the original value in the write==1 case to
|
|
* support partial writes.
|
|
*/
|
|
down_read(&uts_sem);
|
|
memcpy(tmp_data, get_uts(table), sizeof(tmp_data));
|
|
up_read(&uts_sem);
|
|
r = proc_dostring(&uts_table, write, buffer, lenp, ppos);
|
|
|
|
if (write) {
|
|
/*
|
|
* Write back the new value.
|
|
* Note that, since we dropped uts_sem, the result can
|
|
* theoretically be incorrect if there are two parallel writes
|
|
* at non-zero offsets to the same sysctl.
|
|
*/
|
|
add_device_randomness(tmp_data, sizeof(tmp_data));
|
|
down_write(&uts_sem);
|
|
memcpy(get_uts(table), tmp_data, sizeof(tmp_data));
|
|
up_write(&uts_sem);
|
|
proc_sys_poll_notify(table->poll);
|
|
}
|
|
|
|
return r;
|
|
}
|
|
#else
|
|
#define proc_do_uts_string NULL
|
|
#endif
|
|
|
|
static DEFINE_CTL_TABLE_POLL(hostname_poll);
|
|
static DEFINE_CTL_TABLE_POLL(domainname_poll);
|
|
|
|
static struct ctl_table uts_kern_table[] = {
|
|
{
|
|
.procname = "arch",
|
|
.data = init_uts_ns.name.machine,
|
|
.maxlen = sizeof(init_uts_ns.name.machine),
|
|
.mode = 0444,
|
|
.proc_handler = proc_do_uts_string,
|
|
},
|
|
{
|
|
.procname = "ostype",
|
|
.data = init_uts_ns.name.sysname,
|
|
.maxlen = sizeof(init_uts_ns.name.sysname),
|
|
.mode = 0444,
|
|
.proc_handler = proc_do_uts_string,
|
|
},
|
|
{
|
|
.procname = "osrelease",
|
|
.data = init_uts_ns.name.release,
|
|
.maxlen = sizeof(init_uts_ns.name.release),
|
|
.mode = 0444,
|
|
.proc_handler = proc_do_uts_string,
|
|
},
|
|
{
|
|
.procname = "version",
|
|
.data = init_uts_ns.name.version,
|
|
.maxlen = sizeof(init_uts_ns.name.version),
|
|
.mode = 0444,
|
|
.proc_handler = proc_do_uts_string,
|
|
},
|
|
{
|
|
.procname = "hostname",
|
|
.data = init_uts_ns.name.nodename,
|
|
.maxlen = sizeof(init_uts_ns.name.nodename),
|
|
.mode = 0644,
|
|
.proc_handler = proc_do_uts_string,
|
|
.poll = &hostname_poll,
|
|
},
|
|
{
|
|
.procname = "domainname",
|
|
.data = init_uts_ns.name.domainname,
|
|
.maxlen = sizeof(init_uts_ns.name.domainname),
|
|
.mode = 0644,
|
|
.proc_handler = proc_do_uts_string,
|
|
.poll = &domainname_poll,
|
|
},
|
|
{}
|
|
};
|
|
|
|
static struct ctl_table uts_root_table[] = {
|
|
{
|
|
.procname = "kernel",
|
|
.mode = 0555,
|
|
.child = uts_kern_table,
|
|
},
|
|
{}
|
|
};
|
|
|
|
#ifdef CONFIG_PROC_SYSCTL
|
|
/*
|
|
* Notify userspace about a change in a certain entry of uts_kern_table,
|
|
* identified by the parameter proc.
|
|
*/
|
|
void uts_proc_notify(enum uts_proc proc)
|
|
{
|
|
struct ctl_table *table = &uts_kern_table[proc];
|
|
|
|
proc_sys_poll_notify(table->poll);
|
|
}
|
|
#endif
|
|
|
|
static int __init utsname_sysctl_init(void)
|
|
{
|
|
register_sysctl_table(uts_root_table);
|
|
return 0;
|
|
}
|
|
|
|
device_initcall(utsname_sysctl_init);
|