diff options
author | Oleg Nesterov <oleg@redhat.com> | 2014-10-10 00:25:26 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-10 04:25:48 +0200 |
commit | 29a40ace841cba9b661711f042d1821cdc4ad47c (patch) | |
tree | b04f8e2de4a4fd8e19889c2adfaef02235c678ec /fs/proc/internal.h | |
parent | proc: introduce proc_mem_open() (diff) | |
download | linux-29a40ace841cba9b661711f042d1821cdc4ad47c.tar.xz linux-29a40ace841cba9b661711f042d1821cdc4ad47c.zip |
fs/proc/task_mmu.c: shift mm_access() from m_start() to proc_maps_open()
A simple test-case from Kirill Shutemov
cat /proc/self/maps >/dev/null
chmod +x /proc/self/net/packet
exec /proc/self/net/packet
makes lockdep unhappy, cat/exec take seq_file->lock + cred_guard_mutex in
the opposite order.
It's a false positive and probably we should not allow "chmod +x" on proc
files. Still I think that we should avoid mm_access() and cred_guard_mutex
in sys_read() paths, security checking should happen at open time. Besides,
this doesn't even look right if the task changes its ->mm between m_stop()
and m_start().
Add the new "mm_struct *mm" member into struct proc_maps_private and change
proc_maps_open() to initialize it using proc_mem_open(). Change m_start() to
use priv->mm if atomic_inc_not_zero(mm_users) succeeds or return NULL (eof)
otherwise.
The only complication is that proc_maps_open() users should additionally do
mmdrop() in fop->release(), add the new proc_map_release() helper for that.
Note: this is the user-visible change, if the task execs after open("maps")
the new ->mm won't be visible via this file. I hope this is fine, and this
matches /proc/pid/mem bahaviour.
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: "Kirill A. Shutemov" <kirill@shutemov.name>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/internal.h')
-rw-r--r-- | fs/proc/internal.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/proc/internal.h b/fs/proc/internal.h index 3c685563406f..d27182854a28 100644 --- a/fs/proc/internal.h +++ b/fs/proc/internal.h @@ -270,6 +270,7 @@ extern int proc_remount(struct super_block *, int *, char *); struct proc_maps_private { struct pid *pid; struct task_struct *task; + struct mm_struct *mm; #ifdef CONFIG_MMU struct vm_area_struct *tail_vma; #endif |