Commit a0c9f240 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'proc-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc

* 'proc-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/adobriyan/proc:
  proc: remove write-only variable in proc_pident_lookup()
  proc: fix sparse warning
  proc: add /proc/*/stack
  proc: remove '##' usage
  proc: remove useless WARN_ONs
  proc: stop using BKL
parents 5bb47b9f 230e40fb
...@@ -140,6 +140,7 @@ Table 1-1: Process specific entries in /proc ...@@ -140,6 +140,7 @@ Table 1-1: Process specific entries in /proc
statm Process memory status information statm Process memory status information
status Process status in human readable form status Process status in human readable form
wchan If CONFIG_KALLSYMS is set, a pre-decoded wchan wchan If CONFIG_KALLSYMS is set, a pre-decoded wchan
stack Report full stack trace, enable via CONFIG_STACKTRACE
smaps Extension based on maps, the rss size for each mapped file smaps Extension based on maps, the rss size for each mapped file
.............................................................................. ..............................................................................
......
...@@ -32,7 +32,8 @@ static void save_raw_context_stack(struct stack_trace *trace, ...@@ -32,7 +32,8 @@ static void save_raw_context_stack(struct stack_trace *trace,
} }
} }
static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs) static void save_context_stack(struct stack_trace *trace,
struct task_struct *tsk, struct pt_regs *regs)
{ {
unsigned long sp = regs->regs[29]; unsigned long sp = regs->regs[29];
#ifdef CONFIG_KALLSYMS #ifdef CONFIG_KALLSYMS
...@@ -41,7 +42,7 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs) ...@@ -41,7 +42,7 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
if (raw_show_trace || !__kernel_text_address(pc)) { if (raw_show_trace || !__kernel_text_address(pc)) {
unsigned long stack_page = unsigned long stack_page =
(unsigned long)task_stack_page(current); (unsigned long)task_stack_page(tsk);
if (stack_page && sp >= stack_page && if (stack_page && sp >= stack_page &&
sp <= stack_page + THREAD_SIZE - 32) sp <= stack_page + THREAD_SIZE - 32)
save_raw_context_stack(trace, sp); save_raw_context_stack(trace, sp);
...@@ -54,7 +55,7 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs) ...@@ -54,7 +55,7 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
trace->entries[trace->nr_entries++] = pc; trace->entries[trace->nr_entries++] = pc;
if (trace->nr_entries >= trace->max_entries) if (trace->nr_entries >= trace->max_entries)
break; break;
pc = unwind_stack(current, &sp, pc, &ra); pc = unwind_stack(tsk, &sp, pc, &ra);
} while (pc); } while (pc);
#else #else
save_raw_context_stack(trace, sp); save_raw_context_stack(trace, sp);
...@@ -65,13 +66,24 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs) ...@@ -65,13 +66,24 @@ static void save_context_stack(struct stack_trace *trace, struct pt_regs *regs)
* Save stack-backtrace addresses into a stack_trace buffer. * Save stack-backtrace addresses into a stack_trace buffer.
*/ */
void save_stack_trace(struct stack_trace *trace) void save_stack_trace(struct stack_trace *trace)
{
save_stack_trace_tsk(current, trace);
}
EXPORT_SYMBOL_GPL(save_stack_trace);
void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
{ {
struct pt_regs dummyregs; struct pt_regs dummyregs;
struct pt_regs *regs = &dummyregs; struct pt_regs *regs = &dummyregs;
WARN_ON(trace->nr_entries || !trace->max_entries); WARN_ON(trace->nr_entries || !trace->max_entries);
if (tsk != current) {
regs->regs[29] = tsk->thread.reg29;
regs->regs[31] = 0;
regs->cp0_epc = tsk->thread.reg31;
} else
prepare_frametrace(regs); prepare_frametrace(regs);
save_context_stack(trace, regs); save_context_stack(trace, tsk, regs);
} }
EXPORT_SYMBOL_GPL(save_stack_trace); EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/rcupdate.h> #include <linux/rcupdate.h>
#include <linux/kallsyms.h> #include <linux/kallsyms.h>
#include <linux/stacktrace.h>
#include <linux/resource.h> #include <linux/resource.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mount.h> #include <linux/mount.h>
...@@ -109,25 +110,22 @@ struct pid_entry { ...@@ -109,25 +110,22 @@ struct pid_entry {
.op = OP, \ .op = OP, \
} }
#define DIR(NAME, MODE, OTYPE) \ #define DIR(NAME, MODE, iops, fops) \
NOD(NAME, (S_IFDIR|(MODE)), \ NOD(NAME, (S_IFDIR|(MODE)), &iops, &fops, {} )
&proc_##OTYPE##_inode_operations, &proc_##OTYPE##_operations, \ #define LNK(NAME, get_link) \
{} )
#define LNK(NAME, OTYPE) \
NOD(NAME, (S_IFLNK|S_IRWXUGO), \ NOD(NAME, (S_IFLNK|S_IRWXUGO), \
&proc_pid_link_inode_operations, NULL, \ &proc_pid_link_inode_operations, NULL, \
{ .proc_get_link = &proc_##OTYPE##_link } ) { .proc_get_link = get_link } )
#define REG(NAME, MODE, OTYPE) \ #define REG(NAME, MODE, fops) \
NOD(NAME, (S_IFREG|(MODE)), NULL, \ NOD(NAME, (S_IFREG|(MODE)), NULL, &fops, {})
&proc_##OTYPE##_operations, {}) #define INF(NAME, MODE, read) \
#define INF(NAME, MODE, OTYPE) \
NOD(NAME, (S_IFREG|(MODE)), \ NOD(NAME, (S_IFREG|(MODE)), \
NULL, &proc_info_file_operations, \ NULL, &proc_info_file_operations, \
{ .proc_read = &proc_##OTYPE } ) { .proc_read = read } )
#define ONE(NAME, MODE, OTYPE) \ #define ONE(NAME, MODE, show) \
NOD(NAME, (S_IFREG|(MODE)), \ NOD(NAME, (S_IFREG|(MODE)), \
NULL, &proc_single_file_operations, \ NULL, &proc_single_file_operations, \
{ .proc_show = &proc_##OTYPE } ) { .proc_show = show } )
/* /*
* Count the number of hardlinks for the pid_entry table, excluding the . * Count the number of hardlinks for the pid_entry table, excluding the .
...@@ -308,9 +306,9 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer) ...@@ -308,9 +306,9 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
struct mm_struct *mm = get_task_mm(task); struct mm_struct *mm = get_task_mm(task);
if (mm) { if (mm) {
unsigned int nwords = 0; unsigned int nwords = 0;
do do {
nwords += 2; nwords += 2;
while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */ } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
res = nwords * sizeof(mm->saved_auxv[0]); res = nwords * sizeof(mm->saved_auxv[0]);
if (res > PAGE_SIZE) if (res > PAGE_SIZE)
res = PAGE_SIZE; res = PAGE_SIZE;
...@@ -340,6 +338,37 @@ static int proc_pid_wchan(struct task_struct *task, char *buffer) ...@@ -340,6 +338,37 @@ static int proc_pid_wchan(struct task_struct *task, char *buffer)
} }
#endif /* CONFIG_KALLSYMS */ #endif /* CONFIG_KALLSYMS */
#ifdef CONFIG_STACKTRACE
#define MAX_STACK_TRACE_DEPTH 64
static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
struct pid *pid, struct task_struct *task)
{
struct stack_trace trace;
unsigned long *entries;
int i;
entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries), GFP_KERNEL);
if (!entries)
return -ENOMEM;
trace.nr_entries = 0;
trace.max_entries = MAX_STACK_TRACE_DEPTH;
trace.entries = entries;
trace.skip = 0;
save_stack_trace_tsk(task, &trace);
for (i = 0; i < trace.nr_entries; i++) {
seq_printf(m, "[<%p>] %pS\n",
(void *)entries[i], (void *)entries[i]);
}
kfree(entries);
return 0;
}
#endif
#ifdef CONFIG_SCHEDSTATS #ifdef CONFIG_SCHEDSTATS
/* /*
* Provides /proc/PID/schedstat * Provides /proc/PID/schedstat
...@@ -1186,8 +1215,6 @@ static int sched_show(struct seq_file *m, void *v) ...@@ -1186,8 +1215,6 @@ static int sched_show(struct seq_file *m, void *v)
struct inode *inode = m->private; struct inode *inode = m->private;
struct task_struct *p; struct task_struct *p;
WARN_ON(!inode);
p = get_proc_task(inode); p = get_proc_task(inode);
if (!p) if (!p)
return -ESRCH; return -ESRCH;
...@@ -1205,8 +1232,6 @@ sched_write(struct file *file, const char __user *buf, ...@@ -1205,8 +1232,6 @@ sched_write(struct file *file, const char __user *buf,
struct inode *inode = file->f_path.dentry->d_inode; struct inode *inode = file->f_path.dentry->d_inode;
struct task_struct *p; struct task_struct *p;
WARN_ON(!inode);
p = get_proc_task(inode); p = get_proc_task(inode);
if (!p) if (!p)
return -ESRCH; return -ESRCH;
...@@ -1974,13 +1999,11 @@ static struct dentry *proc_pident_lookup(struct inode *dir, ...@@ -1974,13 +1999,11 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
const struct pid_entry *ents, const struct pid_entry *ents,
unsigned int nents) unsigned int nents)
{ {
struct inode *inode;
struct dentry *error; struct dentry *error;
struct task_struct *task = get_proc_task(dir); struct task_struct *task = get_proc_task(dir);
const struct pid_entry *p, *last; const struct pid_entry *p, *last;
error = ERR_PTR(-ENOENT); error = ERR_PTR(-ENOENT);
inode = NULL;
if (!task) if (!task)
goto out_no_task; goto out_no_task;
...@@ -2136,12 +2159,12 @@ static const struct file_operations proc_pid_attr_operations = { ...@@ -2136,12 +2159,12 @@ static const struct file_operations proc_pid_attr_operations = {
}; };
static const struct pid_entry attr_dir_stuff[] = { static const struct pid_entry attr_dir_stuff[] = {
REG("current", S_IRUGO|S_IWUGO, pid_attr), REG("current", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
REG("prev", S_IRUGO, pid_attr), REG("prev", S_IRUGO, proc_pid_attr_operations),
REG("exec", S_IRUGO|S_IWUGO, pid_attr), REG("exec", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
REG("fscreate", S_IRUGO|S_IWUGO, pid_attr), REG("fscreate", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
REG("keycreate", S_IRUGO|S_IWUGO, pid_attr), REG("keycreate", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
REG("sockcreate", S_IRUGO|S_IWUGO, pid_attr), REG("sockcreate", S_IRUGO|S_IWUGO, proc_pid_attr_operations),
}; };
static int proc_attr_dir_readdir(struct file * filp, static int proc_attr_dir_readdir(struct file * filp,
...@@ -2461,74 +2484,77 @@ static const struct file_operations proc_task_operations; ...@@ -2461,74 +2484,77 @@ static const struct file_operations proc_task_operations;
static const struct inode_operations proc_task_inode_operations; static const struct inode_operations proc_task_inode_operations;
static const struct pid_entry tgid_base_stuff[] = { static const struct pid_entry tgid_base_stuff[] = {
DIR("task", S_IRUGO|S_IXUGO, task), DIR("task", S_IRUGO|S_IXUGO, proc_task_inode_operations, proc_task_operations),
DIR("fd", S_IRUSR|S_IXUSR, fd), DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), DIR("fdinfo", S_IRUSR|S_IXUSR, proc_fdinfo_inode_operations, proc_fdinfo_operations),
#ifdef CONFIG_NET #ifdef CONFIG_NET
DIR("net", S_IRUGO|S_IXUGO, net), DIR("net", S_IRUGO|S_IXUGO, proc_net_inode_operations, proc_net_operations),
#endif #endif
REG("environ", S_IRUSR, environ), REG("environ", S_IRUSR, proc_environ_operations),
INF("auxv", S_IRUSR, pid_auxv), INF("auxv", S_IRUSR, proc_pid_auxv),
ONE("status", S_IRUGO, pid_status), ONE("status", S_IRUGO, proc_pid_status),
ONE("personality", S_IRUSR, pid_personality), ONE("personality", S_IRUSR, proc_pid_personality),
INF("limits", S_IRUSR, pid_limits), INF("limits", S_IRUSR, proc_pid_limits),
#ifdef CONFIG_SCHED_DEBUG #ifdef CONFIG_SCHED_DEBUG
REG("sched", S_IRUGO|S_IWUSR, pid_sched), REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
#endif #endif
#ifdef CONFIG_HAVE_ARCH_TRACEHOOK #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
INF("syscall", S_IRUSR, pid_syscall), INF("syscall", S_IRUSR, proc_pid_syscall),
#endif #endif
INF("cmdline", S_IRUGO, pid_cmdline), INF("cmdline", S_IRUGO, proc_pid_cmdline),
ONE("stat", S_IRUGO, tgid_stat), ONE("stat", S_IRUGO, proc_tgid_stat),
ONE("statm", S_IRUGO, pid_statm), ONE("statm", S_IRUGO, proc_pid_statm),
REG("maps", S_IRUGO, maps), REG("maps", S_IRUGO, proc_maps_operations),
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
REG("numa_maps", S_IRUGO, numa_maps), REG("numa_maps", S_IRUGO, proc_numa_maps_operations),
#endif #endif
REG("mem", S_IRUSR|S_IWUSR, mem), REG("mem", S_IRUSR|S_IWUSR, proc_mem_operations),
LNK("cwd", cwd), LNK("cwd", proc_cwd_link),
LNK("root", root), LNK("root", proc_root_link),
LNK("exe", exe), LNK("exe", proc_exe_link),
REG("mounts", S_IRUGO, mounts), REG("mounts", S_IRUGO, proc_mounts_operations),
REG("mountinfo", S_IRUGO, mountinfo), REG("mountinfo", S_IRUGO, proc_mountinfo_operations),
REG("mountstats", S_IRUSR, mountstats), REG("mountstats", S_IRUSR, proc_mountstats_operations),
#ifdef CONFIG_PROC_PAGE_MONITOR #ifdef CONFIG_PROC_PAGE_MONITOR
REG("clear_refs", S_IWUSR, clear_refs), REG("clear_refs", S_IWUSR, proc_clear_refs_operations),
REG("smaps", S_IRUGO, smaps), REG("smaps", S_IRUGO, proc_smaps_operations),
REG("pagemap", S_IRUSR, pagemap), REG("pagemap", S_IRUSR, proc_pagemap_operations),
#endif #endif
#ifdef CONFIG_SECURITY #ifdef CONFIG_SECURITY
DIR("attr", S_IRUGO|S_IXUGO, attr_dir), DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
#endif #endif
#ifdef CONFIG_KALLSYMS #ifdef CONFIG_KALLSYMS
INF("wchan", S_IRUGO, pid_wchan), INF("wchan", S_IRUGO, proc_pid_wchan),
#endif
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif #endif
#ifdef CONFIG_SCHEDSTATS #ifdef CONFIG_SCHEDSTATS
INF("schedstat", S_IRUGO, pid_schedstat), INF("schedstat", S_IRUGO, proc_pid_schedstat),
#endif #endif
#ifdef CONFIG_LATENCYTOP #ifdef CONFIG_LATENCYTOP
REG("latency", S_IRUGO, lstats), REG("latency", S_IRUGO, proc_lstats_operations),
#endif #endif
#ifdef CONFIG_PROC_PID_CPUSET #ifdef CONFIG_PROC_PID_CPUSET
REG("cpuset", S_IRUGO, cpuset), REG("cpuset", S_IRUGO, proc_cpuset_operations),
#endif #endif
#ifdef CONFIG_CGROUPS #ifdef CONFIG_CGROUPS
REG("cgroup", S_IRUGO, cgroup), REG("cgroup", S_IRUGO, proc_cgroup_operations),
#endif #endif
INF("oom_score", S_IRUGO, oom_score), INF("oom_score", S_IRUGO, proc_oom_score),
REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust), REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
#ifdef CONFIG_AUDITSYSCALL #ifdef CONFIG_AUDITSYSCALL
REG("loginuid", S_IWUSR|S_IRUGO, loginuid), REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
REG("sessionid", S_IRUGO, sessionid), REG("sessionid", S_IRUGO, proc_sessionid_operations),
#endif #endif
#ifdef CONFIG_FAULT_INJECTION #ifdef CONFIG_FAULT_INJECTION
REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject), REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations),
#endif #endif
#if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE) #if defined(USE_ELF_CORE_DUMP) && defined(CONFIG_ELF_CORE)
REG("coredump_filter", S_IRUGO|S_IWUSR, coredump_filter), REG("coredump_filter", S_IRUGO|S_IWUSR, proc_coredump_filter_operations),
#endif #endif
#ifdef CONFIG_TASK_IO_ACCOUNTING #ifdef CONFIG_TASK_IO_ACCOUNTING
INF("io", S_IRUGO, tgid_io_accounting), INF("io", S_IRUGO, proc_tgid_io_accounting),
#endif #endif
}; };
...@@ -2801,66 +2827,69 @@ out_no_task: ...@@ -2801,66 +2827,69 @@ out_no_task:
* Tasks * Tasks
*/ */
static const struct pid_entry tid_base_stuff[] = { static const struct pid_entry tid_base_stuff[] = {
DIR("fd", S_IRUSR|S_IXUSR, fd), DIR("fd", S_IRUSR|S_IXUSR, proc_fd_inode_operations, proc_fd_operations),
DIR("fdinfo", S_IRUSR|S_IXUSR, fdinfo), DIR("fdinfo", S_IRUSR|S_IXUSR, proc_fdinfo_inode_operations, proc_fd_operations),
REG("environ", S_IRUSR, environ), REG("environ", S_IRUSR, proc_environ_operations),
INF("auxv", S_IRUSR, pid_auxv), INF("auxv", S_IRUSR, proc_pid_auxv),
ONE("status", S_IRUGO, pid_status), ONE("status", S_IRUGO, proc_pid_status),
ONE("personality", S_IRUSR, pid_personality), ONE("personality", S_IRUSR, proc_pid_personality),
INF("limits", S_IRUSR, pid_limits), INF("limits", S_IRUSR, proc_pid_limits),
#ifdef CONFIG_SCHED_DEBUG #ifdef CONFIG_SCHED_DEBUG
REG("sched", S_IRUGO|S_IWUSR, pid_sched), REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
#endif #endif
#ifdef CONFIG_HAVE_ARCH_TRACEHOOK #ifdef CONFIG_HAVE_ARCH_TRACEHOOK
INF("syscall", S_IRUSR, pid_syscall), INF("syscall", S_IRUSR, proc_pid_syscall),
#endif #endif
INF("cmdline", S_IRUGO, pid_cmdline), INF("cmdline", S_IRUGO, proc_pid_cmdline),
ONE("stat", S_IRUGO, tid_stat), ONE("stat", S_IRUGO, proc_tid_stat),
ONE("statm", S_IRUGO, pid_statm), ONE("statm", S_IRUGO, proc_pid_statm),
REG("maps", S_IRUGO, maps), REG("maps", S_IRUGO, proc_maps_operations),
#ifdef CONFIG_NUMA #ifdef CONFIG_NUMA
REG("numa_maps", S_IRUGO, numa_maps), REG("numa_maps", S_IRUGO, proc_numa_maps_operations),
#endif #endif
REG("mem", S_IRUSR|S_IWUSR, mem), REG("mem", S_IRUSR|S_IWUSR, proc_mem_operations),
LNK("cwd", cwd), LNK("cwd", proc_cwd_link),
LNK("root", root), LNK("root", proc_root_link),
LNK("exe", exe), LNK("exe", proc_exe_link),
REG("mounts", S_IRUGO, mounts), REG("mounts", S_IRUGO, proc_mounts_operations),
REG("mountinfo", S_IRUGO, mountinfo), REG("mountinfo", S_IRUGO, proc_mountinfo_operations),
#ifdef CONFIG_PROC_PAGE_MONITOR #ifdef CONFIG_PROC_PAGE_MONITOR
REG("clear_refs", S_IWUSR, clear_refs), REG("clear_refs", S_IWUSR, proc_clear_refs_operations),
REG("smaps", S_IRUGO, smaps), REG("smaps", S_IRUGO, proc_smaps_operations),
REG("pagemap", S_IRUSR, pagemap), REG("pagemap", S_IRUSR, proc_pagemap_operations),
#endif #endif
#ifdef CONFIG_SECURITY #ifdef CONFIG_SECURITY
DIR("attr", S_IRUGO|S_IXUGO, attr_dir), DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
#endif #endif
#ifdef CONFIG_KALLSYMS #ifdef CONFIG_KALLSYMS
INF("wchan", S_IRUGO, pid_wchan), INF("wchan", S_IRUGO, proc_pid_wchan),
#endif
#ifdef CONFIG_STACKTRACE
ONE("stack", S_IRUSR, proc_pid_stack),
#endif #endif
#ifdef CONFIG_SCHEDSTATS #ifdef CONFIG_SCHEDSTATS
INF("schedstat", S_IRUGO, pid_schedstat), INF("schedstat", S_IRUGO, proc_pid_schedstat),
#endif #endif
#ifdef CONFIG_LATENCYTOP #ifdef CONFIG_LATENCYTOP
REG("latency", S_IRUGO, lstats), REG("latency", S_IRUGO, proc_lstats_operations),
#endif #endif
#ifdef CONFIG_PROC_PID_CPUSET #ifdef CONFIG_PROC_PID_CPUSET
REG("cpuset", S_IRUGO, cpuset), REG("cpuset", S_IRUGO, proc_cpuset_operations),
#endif #endif
#ifdef CONFIG_CGROUPS #ifdef CONFIG_CGROUPS
REG("cgroup", S_IRUGO, cgroup), REG("cgroup", S_IRUGO, proc_cgroup_operations),
#endif #endif
INF("oom_score", S_IRUGO, oom_score), INF("oom_score", S_IRUGO, proc_oom_score),
REG("oom_adj", S_IRUGO|S_IWUSR, oom_adjust), REG("oom_adj", S_IRUGO|S_IWUSR, proc_oom_adjust_operations),
#ifdef CONFIG_AUDITSYSCALL #ifdef CONFIG_AUDITSYSCALL
REG("loginuid", S_IWUSR|S_IRUGO, loginuid), REG("loginuid", S_IWUSR|S_IRUGO, proc_loginuid_operations),
REG("sessionid", S_IRUSR, sessionid), REG("sessionid", S_IRUSR, proc_sessionid_operations),
#endif #endif
#ifdef CONFIG_FAULT_INJECTION #ifdef CONFIG_FAULT_INJECTION
REG("make-it-fail", S_IRUGO|S_IWUSR, fault_inject), REG("make-it-fail", S_IRUGO|S_IWUSR, proc_fault_inject_operations),
#endif #endif
#ifdef CONFIG_TASK_IO_ACCOUNTING #ifdef CONFIG_TASK_IO_ACCOUNTING
INF("io", S_IRUGO, tid_io_accounting), INF("io", S_IRUGO, proc_tid_io_accounting),
#endif #endif
}; };
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/smp_lock.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/namei.h> #include <linux/namei.h>
...@@ -379,7 +378,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, ...@@ -379,7 +378,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
struct inode *inode = NULL; struct inode *inode = NULL;
int error = -ENOENT; int error = -ENOENT;
lock_kernel();
spin_lock(&proc_subdir_lock); spin_lock(&proc_subdir_lock);
for (de = de->subdir; de ; de = de->next) { for (de = de->subdir; de ; de = de->next) {
if (de->namelen != dentry->d_name.len) if (de->namelen != dentry->d_name.len)
...@@ -397,7 +395,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir, ...@@ -397,7 +395,6 @@ struct dentry *proc_lookup_de(struct proc_dir_entry *de, struct inode *dir,
} }
spin_unlock(&proc_subdir_lock); spin_unlock(&proc_subdir_lock);
out_unlock: out_unlock:
unlock_kernel();
if (inode) { if (inode) {
dentry->d_op = &proc_dentry_operations; dentry->d_op = &proc_dentry_operations;
...@@ -432,8 +429,6 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent, ...@@ -432,8 +429,6 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
struct inode *inode = filp->f_path.dentry->d_inode; struct inode *inode = filp->f_path.dentry->d_inode;
int ret = 0; int ret = 0;
lock_kernel();
ino = inode->i_ino; ino = inode->i_ino;
i = filp->f_pos; i = filp->f_pos;
switch (i) { switch (i) {
...@@ -487,7 +482,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent, ...@@ -487,7 +482,7 @@ int proc_readdir_de(struct proc_dir_entry *de, struct file *filp, void *dirent,
spin_unlock(&proc_subdir_lock); spin_unlock(&proc_subdir_lock);
} }
ret = 1; ret = 1;
out: unlock_kernel(); out:
return ret; return ret;
} }
...@@ -504,6 +499,7 @@ int proc_readdir(struct file *filp, void *dirent, filldir_t filldir) ...@@ -504,6 +499,7 @@ int proc_readdir(struct file *filp, void *dirent, filldir_t filldir)
* the /proc directory. * the /proc directory.
*/ */
static const struct file_operations proc_dir_operations = { static const struct file_operations proc_dir_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir, .read = generic_read_dir,
.readdir = proc_readdir, .readdir = proc_readdir,
}; };
......
...@@ -35,16 +35,13 @@ struct proc_dir_entry *de_get(struct proc_dir_entry *de) ...@@ -35,16 +35,13 @@ struct proc_dir_entry *de_get(struct proc_dir_entry *de)
*/ */
void de_put(struct proc_dir_entry *de) void de_put(struct proc_dir_entry *de)
{ {
lock_kernel();
if (!atomic_read(&de->count)) { if (!atomic_read(&de->count)) {
printk("de_put: entry %s already free!\n", de->name); printk("de_put: entry %s already free!\n", de->name);
unlock_kernel();
return; return;
} }
if (atomic_dec_and_test(&de->count)) if (atomic_dec_and_test(&de->count))
free_proc_entry(de); free_proc_entry(de);
unlock_kernel();
} }
/* /*
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/smp_lock.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/nsproxy.h> #include <linux/nsproxy.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
...@@ -172,6 +171,7 @@ static int proc_tgid_net_readdir(struct file *filp, void *dirent, ...@@ -172,6 +171,7 @@ static int proc_tgid_net_readdir(struct file *filp, void *dirent,
} }
const struct file_operations proc_net_operations = { const struct file_operations proc_net_operations = {
.llseek = generic_file_llseek,
.read = generic_read_dir, .read = generic_read_dir,
.readdir = proc_tgid_net_readdir, .readdir = proc_tgid_net_readdir,
}; };
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/smp_lock.h>
#include <linux/mount.h> #include <linux/mount.h>
#include <linux/pid_namespace.h> #include <linux/pid_namespace.h>
...@@ -162,17 +161,12 @@ static int proc_root_readdir(struct file * filp, ...@@ -162,17 +161,12 @@ static int proc_root_readdir(struct file * filp,
unsigned int nr = filp->f_pos; unsigned int nr = filp->f_pos;
int ret; int ret;
lock_kernel();
if (nr < FIRST_PROCESS_ENTRY) { if (nr < FIRST_PROCESS_ENTRY) {
int error = proc_readdir(filp, dirent, filldir); int error = proc_readdir(filp, dirent, filldir);
if (error <= 0) { if (error <= 0)
unlock_kernel();
return error; return error;
}
filp->f_pos = FIRST_PROCESS_ENTRY; filp->f_pos = FIRST_PROCESS_ENTRY;
} }
unlock_kernel();
ret = proc_pid_readdir(filp, dirent, filldir); ret = proc_pid_readdir(filp, dirent, filldir);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment