aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/task_nommu.c
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2014-10-09 18:25:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-09 22:25:49 -0400
commit27692cd56e2aa6924b49f4361247d707a023484a (patch)
tree285d080f84f97f4cf46e90522b6121bf9dac84c0 /fs/proc/task_nommu.c
parentce34fddb5bafb424a4aaa9f403feb7dbe776c7d1 (diff)
fs/proc/task_nommu.c: shift mm_access() from m_start() to proc_maps_open()
Copy-and-paste the changes from "fs/proc/task_mmu.c: shift mm_access() from m_start() to proc_maps_open()" into task_nommu.c. Change maps_open() to initialize priv->mm using proc_mem_open(), m_start() can rely on atomic_inc_not_zero(mm_users) like task_mmu.c does. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Oleg Nesterov <oleg@redhat.com> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Cyrill Gorcunov <gorcunov@openvz.org> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Acked-by: Greg Ungerer <gerg@uclinux.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/task_nommu.c')
-rw-r--r--fs/proc/task_nommu.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 98c95d2833ea..9019f1de3f72 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -216,11 +216,11 @@ static void *m_start(struct seq_file *m, loff_t *pos)
216 if (!priv->task) 216 if (!priv->task)
217 return ERR_PTR(-ESRCH); 217 return ERR_PTR(-ESRCH);
218 218
219 mm = mm_access(priv->task, PTRACE_MODE_READ); 219 mm = priv->mm;
220 if (!mm || IS_ERR(mm)) { 220 if (!mm || !atomic_inc_not_zero(&mm->mm_users)) {
221 put_task_struct(priv->task); 221 put_task_struct(priv->task);
222 priv->task = NULL; 222 priv->task = NULL;
223 return mm; 223 return NULL;
224 } 224 }
225 down_read(&mm->mmap_sem); 225 down_read(&mm->mmap_sem);
226 226
@@ -270,14 +270,34 @@ static int maps_open(struct inode *inode, struct file *file,
270{ 270{
271 struct proc_maps_private *priv; 271 struct proc_maps_private *priv;
272 272
273 priv = __seq_open_private(file, ops, sizeof(struct proc_maps_private)); 273 priv = __seq_open_private(file, ops, sizeof(*priv));
274 if (!priv) 274 if (!priv)
275 return -ENOMEM; 275 return -ENOMEM;
276 276
277 priv->pid = proc_pid(inode); 277 priv->pid = proc_pid(inode);
278 priv->mm = proc_mem_open(inode, PTRACE_MODE_READ);
279 if (IS_ERR(priv->mm)) {
280 int err = PTR_ERR(priv->mm);
281
282 seq_release_private(inode, file);
283 return err;
284 }
285
278 return 0; 286 return 0;
279} 287}
280 288
289
290static int map_release(struct inode *inode, struct file *file)
291{
292 struct seq_file *seq = file->private_data;
293 struct proc_maps_private *priv = seq->private;
294
295 if (priv->mm)
296 mmdrop(priv->mm);
297
298 return seq_release_private(inode, file);
299}
300
281static int pid_maps_open(struct inode *inode, struct file *file) 301static int pid_maps_open(struct inode *inode, struct file *file)
282{ 302{
283 return maps_open(inode, file, &proc_pid_maps_ops); 303 return maps_open(inode, file, &proc_pid_maps_ops);
@@ -292,13 +312,13 @@ const struct file_operations proc_pid_maps_operations = {
292 .open = pid_maps_open, 312 .open = pid_maps_open,
293 .read = seq_read, 313 .read = seq_read,
294 .llseek = seq_lseek, 314 .llseek = seq_lseek,
295 .release = seq_release_private, 315 .release = map_release,
296}; 316};
297 317
298const struct file_operations proc_tid_maps_operations = { 318const struct file_operations proc_tid_maps_operations = {
299 .open = tid_maps_open, 319 .open = tid_maps_open,
300 .read = seq_read, 320 .read = seq_read,
301 .llseek = seq_lseek, 321 .llseek = seq_lseek,
302 .release = seq_release_private, 322 .release = map_release,
303}; 323};
304 324