aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/base.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2016-10-05 18:43:43 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2016-10-05 18:43:43 -0400
commitc5317167854e01dbb42d2291406ab8448d272868 (patch)
tree950045759c9f178e35a6bac398bc894c5e32589b /fs/proc/base.c
parent91fff9b347f9f69025e6557b3279cccedbcc744a (diff)
proc: switch auxv to use of __mem_open()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/proc/base.c')
-rw-r--r--fs/proc/base.c45
1 files changed, 26 insertions, 19 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index ac0df4dde823..528c1bb57bc3 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -400,23 +400,6 @@ static const struct file_operations proc_pid_cmdline_ops = {
400 .llseek = generic_file_llseek, 400 .llseek = generic_file_llseek,
401}; 401};
402 402
403static int proc_pid_auxv(struct seq_file *m, struct pid_namespace *ns,
404 struct pid *pid, struct task_struct *task)
405{
406 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ_FSCREDS);
407 if (mm && !IS_ERR(mm)) {
408 unsigned int nwords = 0;
409 do {
410 nwords += 2;
411 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
412 seq_write(m, mm->saved_auxv, nwords * sizeof(mm->saved_auxv[0]));
413 mmput(mm);
414 return 0;
415 } else
416 return PTR_ERR(mm);
417}
418
419
420#ifdef CONFIG_KALLSYMS 403#ifdef CONFIG_KALLSYMS
421/* 404/*
422 * Provides a wchan file via kallsyms in a proper one-value-per-file format. 405 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
@@ -1014,6 +997,30 @@ static const struct file_operations proc_environ_operations = {
1014 .release = mem_release, 997 .release = mem_release,
1015}; 998};
1016 999
1000static int auxv_open(struct inode *inode, struct file *file)
1001{
1002 return __mem_open(inode, file, PTRACE_MODE_READ_FSCREDS);
1003}
1004
1005static ssize_t auxv_read(struct file *file, char __user *buf,
1006 size_t count, loff_t *ppos)
1007{
1008 struct mm_struct *mm = file->private_data;
1009 unsigned int nwords = 0;
1010 do {
1011 nwords += 2;
1012 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
1013 return simple_read_from_buffer(buf, count, ppos, mm->saved_auxv,
1014 nwords * sizeof(mm->saved_auxv[0]));
1015}
1016
1017static const struct file_operations proc_auxv_operations = {
1018 .open = auxv_open,
1019 .read = auxv_read,
1020 .llseek = generic_file_llseek,
1021 .release = mem_release,
1022};
1023
1017static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count, 1024static ssize_t oom_adj_read(struct file *file, char __user *buf, size_t count,
1018 loff_t *ppos) 1025 loff_t *ppos)
1019{ 1026{
@@ -2822,7 +2829,7 @@ static const struct pid_entry tgid_base_stuff[] = {
2822 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations), 2829 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
2823#endif 2830#endif
2824 REG("environ", S_IRUSR, proc_environ_operations), 2831 REG("environ", S_IRUSR, proc_environ_operations),
2825 ONE("auxv", S_IRUSR, proc_pid_auxv), 2832 REG("auxv", S_IRUSR, proc_auxv_operations),
2826 ONE("status", S_IRUGO, proc_pid_status), 2833 ONE("status", S_IRUGO, proc_pid_status),
2827 ONE("personality", S_IRUSR, proc_pid_personality), 2834 ONE("personality", S_IRUSR, proc_pid_personality),
2828 ONE("limits", S_IRUGO, proc_pid_limits), 2835 ONE("limits", S_IRUGO, proc_pid_limits),
@@ -3210,7 +3217,7 @@ static const struct pid_entry tid_base_stuff[] = {
3210 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations), 3217 DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
3211#endif 3218#endif
3212 REG("environ", S_IRUSR, proc_environ_operations), 3219 REG("environ", S_IRUSR, proc_environ_operations),
3213 ONE("auxv", S_IRUSR, proc_pid_auxv), 3220 REG("auxv", S_IRUSR, proc_auxv_operations),
3214 ONE("status", S_IRUGO, proc_pid_status), 3221 ONE("status", S_IRUGO, proc_pid_status),
3215 ONE("personality", S_IRUSR, proc_pid_personality), 3222 ONE("personality", S_IRUSR, proc_pid_personality),
3216 ONE("limits", S_IRUGO, proc_pid_limits), 3223 ONE("limits", S_IRUGO, proc_pid_limits),