aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc/task_nommu.c
diff options
context:
space:
mode:
authorAl Viro <viro@ZenIV.linux.org.uk>2008-01-02 09:09:57 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-01-02 16:13:27 -0500
commit831830b5a2b5d413407adf380ef62fe17d6fcbf2 (patch)
treeb08f54f15374b5b98b0b3bea20a1d2ea8d1f50e0 /fs/proc/task_nommu.c
parentac40532ef0b8649e6f7f83859ea0de1c4ed08a19 (diff)
restrict reading from /proc/<pid>/maps to those who share ->mm or can ptrace pid
Contents of /proc/*/maps is sensitive and may become sensitive after open() (e.g. if target originally shares our ->mm and later does exec on suid-root binary). Check at read() (actually, ->start() of iterator) time that mm_struct we'd grabbed and locked is - still the ->mm of target - equal to reader's ->mm or the target is ptracable by reader. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Acked-by: Rik van Riel <riel@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/proc/task_nommu.c')
-rw-r--r--fs/proc/task_nommu.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index d8b8c7183c24..1932c2ca3457 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -165,15 +165,13 @@ static void *m_start(struct seq_file *m, loff_t *pos)
165 if (!priv->task) 165 if (!priv->task)
166 return NULL; 166 return NULL;
167 167
168 mm = get_task_mm(priv->task); 168 mm = mm_for_maps(priv->task);
169 if (!mm) { 169 if (!mm) {
170 put_task_struct(priv->task); 170 put_task_struct(priv->task);
171 priv->task = NULL; 171 priv->task = NULL;
172 return NULL; 172 return NULL;
173 } 173 }
174 174
175 down_read(&mm->mmap_sem);
176
177 /* start from the Nth VMA */ 175 /* start from the Nth VMA */
178 for (vml = mm->context.vmlist; vml; vml = vml->next) 176 for (vml = mm->context.vmlist; vml; vml = vml->next)
179 if (n-- == 0) 177 if (n-- == 0)