aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/array.c8
-rw-r--r--fs/proc/base.c4
-rw-r--r--fs/proc/inode.c9
-rw-r--r--fs/proc/namespaces.c4
-rw-r--r--fs/proc/self.c24
-rw-r--r--fs/proc/thread_self.c22
6 files changed, 37 insertions, 34 deletions
diff --git a/fs/proc/array.c b/fs/proc/array.c
index fd02a9ebfc30..3f57dac31ba6 100644
--- a/fs/proc/array.c
+++ b/fs/proc/array.c
@@ -126,6 +126,14 @@ static inline const char *get_task_state(struct task_struct *tsk)
126{ 126{
127 unsigned int state = (tsk->state | tsk->exit_state) & TASK_REPORT; 127 unsigned int state = (tsk->state | tsk->exit_state) & TASK_REPORT;
128 128
129 /*
130 * Parked tasks do not run; they sit in __kthread_parkme().
131 * Without this check, we would report them as running, which is
132 * clearly wrong, so we report them as sleeping instead.
133 */
134 if (tsk->state == TASK_PARKED)
135 state = TASK_INTERRUPTIBLE;
136
129 BUILD_BUG_ON(1 + ilog2(TASK_REPORT) != ARRAY_SIZE(task_state_array)-1); 137 BUILD_BUG_ON(1 + ilog2(TASK_REPORT) != ARRAY_SIZE(task_state_array)-1);
130 138
131 return task_state_array[fls(state)]; 139 return task_state_array[fls(state)];
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 093ca14f5701..286a422f440e 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1380,7 +1380,7 @@ static int proc_exe_link(struct dentry *dentry, struct path *exe_path)
1380 return -ENOENT; 1380 return -ENOENT;
1381} 1381}
1382 1382
1383static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd) 1383static const char *proc_pid_follow_link(struct dentry *dentry, void **cookie)
1384{ 1384{
1385 struct inode *inode = d_inode(dentry); 1385 struct inode *inode = d_inode(dentry);
1386 struct path path; 1386 struct path path;
@@ -1394,7 +1394,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
1394 if (error) 1394 if (error)
1395 goto out; 1395 goto out;
1396 1396
1397 nd_jump_link(nd, &path); 1397 nd_jump_link(&path);
1398 return NULL; 1398 return NULL;
1399out: 1399out:
1400 return ERR_PTR(error); 1400 return ERR_PTR(error);
diff --git a/fs/proc/inode.c b/fs/proc/inode.c
index 8272aaba1bb0..afe232b9df6e 100644
--- a/fs/proc/inode.c
+++ b/fs/proc/inode.c
@@ -23,7 +23,6 @@
23#include <linux/slab.h> 23#include <linux/slab.h>
24#include <linux/mount.h> 24#include <linux/mount.h>
25#include <linux/magic.h> 25#include <linux/magic.h>
26#include <linux/namei.h>
27 26
28#include <asm/uaccess.h> 27#include <asm/uaccess.h>
29 28
@@ -394,16 +393,16 @@ static const struct file_operations proc_reg_file_ops_no_compat = {
394}; 393};
395#endif 394#endif
396 395
397static void *proc_follow_link(struct dentry *dentry, struct nameidata *nd) 396static const char *proc_follow_link(struct dentry *dentry, void **cookie)
398{ 397{
399 struct proc_dir_entry *pde = PDE(d_inode(dentry)); 398 struct proc_dir_entry *pde = PDE(d_inode(dentry));
400 if (unlikely(!use_pde(pde))) 399 if (unlikely(!use_pde(pde)))
401 return ERR_PTR(-EINVAL); 400 return ERR_PTR(-EINVAL);
402 nd_set_link(nd, pde->data); 401 *cookie = pde;
403 return pde; 402 return pde->data;
404} 403}
405 404
406static void proc_put_link(struct dentry *dentry, struct nameidata *nd, void *p) 405static void proc_put_link(struct inode *unused, void *p)
407{ 406{
408 unuse_pde(p); 407 unuse_pde(p);
409} 408}
diff --git a/fs/proc/namespaces.c b/fs/proc/namespaces.c
index e512642dbbdc..f6e8354b8cea 100644
--- a/fs/proc/namespaces.c
+++ b/fs/proc/namespaces.c
@@ -30,7 +30,7 @@ static const struct proc_ns_operations *ns_entries[] = {
30 &mntns_operations, 30 &mntns_operations,
31}; 31};
32 32
33static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd) 33static const char *proc_ns_follow_link(struct dentry *dentry, void **cookie)
34{ 34{
35 struct inode *inode = d_inode(dentry); 35 struct inode *inode = d_inode(dentry);
36 const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops; 36 const struct proc_ns_operations *ns_ops = PROC_I(inode)->ns_ops;
@@ -45,7 +45,7 @@ static void *proc_ns_follow_link(struct dentry *dentry, struct nameidata *nd)
45 if (ptrace_may_access(task, PTRACE_MODE_READ)) { 45 if (ptrace_may_access(task, PTRACE_MODE_READ)) {
46 error = ns_get_path(&ns_path, task, ns_ops); 46 error = ns_get_path(&ns_path, task, ns_ops);
47 if (!error) 47 if (!error)
48 nd_jump_link(nd, &ns_path); 48 nd_jump_link(&ns_path);
49 } 49 }
50 put_task_struct(task); 50 put_task_struct(task);
51 return error; 51 return error;
diff --git a/fs/proc/self.c b/fs/proc/self.c
index 6195b4a7c3b1..113b8d061fc0 100644
--- a/fs/proc/self.c
+++ b/fs/proc/self.c
@@ -1,5 +1,4 @@
1#include <linux/sched.h> 1#include <linux/sched.h>
2#include <linux/namei.h>
3#include <linux/slab.h> 2#include <linux/slab.h>
4#include <linux/pid_namespace.h> 3#include <linux/pid_namespace.h>
5#include "internal.h" 4#include "internal.h"
@@ -19,21 +18,20 @@ static int proc_self_readlink(struct dentry *dentry, char __user *buffer,
19 return readlink_copy(buffer, buflen, tmp); 18 return readlink_copy(buffer, buflen, tmp);
20} 19}
21 20
22static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd) 21static const char *proc_self_follow_link(struct dentry *dentry, void **cookie)
23{ 22{
24 struct pid_namespace *ns = dentry->d_sb->s_fs_info; 23 struct pid_namespace *ns = dentry->d_sb->s_fs_info;
25 pid_t tgid = task_tgid_nr_ns(current, ns); 24 pid_t tgid = task_tgid_nr_ns(current, ns);
26 char *name = ERR_PTR(-ENOENT); 25 char *name;
27 if (tgid) { 26
28 /* 11 for max length of signed int in decimal + NULL term */ 27 if (!tgid)
29 name = kmalloc(12, GFP_KERNEL); 28 return ERR_PTR(-ENOENT);
30 if (!name) 29 /* 11 for max length of signed int in decimal + NULL term */
31 name = ERR_PTR(-ENOMEM); 30 name = kmalloc(12, GFP_KERNEL);
32 else 31 if (!name)
33 sprintf(name, "%d", tgid); 32 return ERR_PTR(-ENOMEM);
34 } 33 sprintf(name, "%d", tgid);
35 nd_set_link(nd, name); 34 return *cookie = name;
36 return NULL;
37} 35}
38 36
39static const struct inode_operations proc_self_inode_operations = { 37static const struct inode_operations proc_self_inode_operations = {
diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
index a8371993b4fb..947b0f4fd0a1 100644
--- a/fs/proc/thread_self.c
+++ b/fs/proc/thread_self.c
@@ -1,5 +1,4 @@
1#include <linux/sched.h> 1#include <linux/sched.h>
2#include <linux/namei.h>
3#include <linux/slab.h> 2#include <linux/slab.h>
4#include <linux/pid_namespace.h> 3#include <linux/pid_namespace.h>
5#include "internal.h" 4#include "internal.h"
@@ -20,21 +19,20 @@ static int proc_thread_self_readlink(struct dentry *dentry, char __user *buffer,
20 return readlink_copy(buffer, buflen, tmp); 19 return readlink_copy(buffer, buflen, tmp);
21} 20}
22 21
23static void *proc_thread_self_follow_link(struct dentry *dentry, struct nameidata *nd) 22static const char *proc_thread_self_follow_link(struct dentry *dentry, void **cookie)
24{ 23{
25 struct pid_namespace *ns = dentry->d_sb->s_fs_info; 24 struct pid_namespace *ns = dentry->d_sb->s_fs_info;
26 pid_t tgid = task_tgid_nr_ns(current, ns); 25 pid_t tgid = task_tgid_nr_ns(current, ns);
27 pid_t pid = task_pid_nr_ns(current, ns); 26 pid_t pid = task_pid_nr_ns(current, ns);
28 char *name = ERR_PTR(-ENOENT); 27 char *name;
29 if (pid) { 28
30 name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL); 29 if (!pid)
31 if (!name) 30 return ERR_PTR(-ENOENT);
32 name = ERR_PTR(-ENOMEM); 31 name = kmalloc(PROC_NUMBUF + 6 + PROC_NUMBUF, GFP_KERNEL);
33 else 32 if (!name)
34 sprintf(name, "%d/task/%d", tgid, pid); 33 return ERR_PTR(-ENOMEM);
35 } 34 sprintf(name, "%d/task/%d", tgid, pid);
36 nd_set_link(nd, name); 35 return *cookie = name;
37 return NULL;
38} 36}
39 37
40static const struct inode_operations proc_thread_self_inode_operations = { 38static const struct inode_operations proc_thread_self_inode_operations = {