]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/proc/task_mmu.c
Hibernation: Introduce begin() and end() callbacks
[linux-2.6-omap-h63xx.git] / fs / proc / task_mmu.c
index 4008c060f7ef1b2b9ddc51154d30e1ec865906a5..8043a3eab52ce49f14f0b23f863b8fb77c6916ba 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/mount.h>
 #include <linux/seq_file.h>
 #include <linux/highmem.h>
+#include <linux/ptrace.h>
 #include <linux/pagemap.h>
 #include <linux/mempolicy.h>
 
@@ -142,6 +143,9 @@ static int show_map_internal(struct seq_file *m, void *v, struct mem_size_stats
        dev_t dev = 0;
        int len;
 
+       if (maps_protect && !ptrace_may_attach(task))
+               return -EACCES;
+
        if (file) {
                struct inode *inode = vma->vm_file->f_path.dentry->d_inode;
                dev = inode->i_sb->s_dev;
@@ -393,12 +397,11 @@ static void *m_start(struct seq_file *m, loff_t *pos)
        if (!priv->task)
                return NULL;
 
-       mm = get_task_mm(priv->task);
+       mm = mm_for_maps(priv->task);
        if (!mm)
                return NULL;
 
        priv->tail_vma = tail_vma = get_gate_vma(priv->task);
-       down_read(&mm->mmap_sem);
 
        /* Start with last addr hint */
        if (last_addr && (vma = find_vma(mm, last_addr))) {
@@ -512,11 +515,22 @@ const struct file_operations proc_maps_operations = {
 #ifdef CONFIG_NUMA
 extern int show_numa_map(struct seq_file *m, void *v);
 
+static int show_numa_map_checked(struct seq_file *m, void *v)
+{
+       struct proc_maps_private *priv = m->private;
+       struct task_struct *task = priv->task;
+
+       if (maps_protect && !ptrace_may_attach(task))
+               return -EACCES;
+
+       return show_numa_map(m, v);
+}
+
 static struct seq_operations proc_pid_numa_maps_op = {
         .start  = m_start,
         .next   = m_next,
         .stop   = m_stop,
-        .show   = show_numa_map
+        .show   = show_numa_map_checked
 };
 
 static int numa_maps_open(struct inode *inode, struct file *file)