Skip to content

Commit ca6b0bf

Browse files
author
Al Viro
committed
pagemap: close races with suid execve
just use mm_for_maps() Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 26ec3c6 commit ca6b0bf

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

‎fs/proc/base.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2797,7 +2797,7 @@ static const struct pid_entry tgid_base_stuff[] = {
27972797
#ifdef CONFIG_PROC_PAGE_MONITOR
27982798
REG("clear_refs", S_IWUSR, proc_clear_refs_operations),
27992799
REG("smaps", S_IRUGO, proc_smaps_operations),
2800-
REG("pagemap", S_IRUSR, proc_pagemap_operations),
2800+
REG("pagemap", S_IRUGO, proc_pagemap_operations),
28012801
#endif
28022802
#ifdef CONFIG_SECURITY
28032803
DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
@@ -3133,7 +3133,7 @@ static const struct pid_entry tid_base_stuff[] = {
31333133
#ifdef CONFIG_PROC_PAGE_MONITOR
31343134
REG("clear_refs", S_IWUSR, proc_clear_refs_operations),
31353135
REG("smaps", S_IRUGO, proc_smaps_operations),
3136-
REG("pagemap", S_IRUSR, proc_pagemap_operations),
3136+
REG("pagemap", S_IRUGO, proc_pagemap_operations),
31373137
#endif
31383138
#ifdef CONFIG_SECURITY
31393139
DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),

‎fs/proc/task_mmu.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,8 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
729729
goto out;
730730

731731
ret = -EACCES;
732-
if (!ptrace_may_access(task, PTRACE_MODE_READ))
732+
mm = mm_for_maps(task);
733+
if (!mm)
733734
goto out_task;
734735

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

745-
mm = get_task_mm(task);
746-
if (!mm)
747-
goto out_task;
748-
749746
pm.len = PM_ENTRY_BYTES * (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
750747
pm.buffer = kmalloc(pm.len, GFP_TEMPORARY);
751748
ret = -ENOMEM;

0 commit comments

Comments
 (0)