Skip to content

Commit

Permalink
pagemap: close races with suid execve
Browse files Browse the repository at this point in the history
just use mm_for_maps()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Al Viro committed Mar 23, 2011
1 parent 26ec3c6 commit ca6b0bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions fs/proc/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -2797,7 +2797,7 @@ static const struct pid_entry tgid_base_stuff[] = {
#ifdef CONFIG_PROC_PAGE_MONITOR
REG("clear_refs", S_IWUSR, proc_clear_refs_operations),
REG("smaps", S_IRUGO, proc_smaps_operations),
REG("pagemap", S_IRUSR, proc_pagemap_operations),
REG("pagemap", S_IRUGO, proc_pagemap_operations),
#endif
#ifdef CONFIG_SECURITY
DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
Expand Down Expand Up @@ -3133,7 +3133,7 @@ static const struct pid_entry tid_base_stuff[] = {
#ifdef CONFIG_PROC_PAGE_MONITOR
REG("clear_refs", S_IWUSR, proc_clear_refs_operations),
REG("smaps", S_IRUGO, proc_smaps_operations),
REG("pagemap", S_IRUSR, proc_pagemap_operations),
REG("pagemap", S_IRUGO, proc_pagemap_operations),
#endif
#ifdef CONFIG_SECURITY
DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
Expand Down
7 changes: 2 additions & 5 deletions fs/proc/task_mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
goto out;

ret = -EACCES;
if (!ptrace_may_access(task, PTRACE_MODE_READ))
mm = mm_for_maps(task);
if (!mm)
goto out_task;

ret = -EINVAL;
Expand All @@ -742,10 +743,6 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
if (!count)
goto out_task;

mm = get_task_mm(task);
if (!mm)
goto out_task;

pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
pm.buffer = kmalloc(pm.len, GFP_TEMPORARY);
ret = -ENOMEM;
Expand Down

0 comments on commit ca6b0bf

Please sign in to comment.