From: Al Viro Date: Thu, 21 Jul 2011 13:13:44 +0000 (+0100) Subject: close race in /proc/*/environ, CVE-2011-1020 X-Git-Url: http://git.alex.org.uk close race in /proc/*/environ, CVE-2011-1020 Switch to mm_for_maps(). Maybe we ought to make it r--r--r--, since we do checks on IO anyway... Signed-off-by: Al Viro (cherry picked from commit d6f64b89d7ff22ce05896ab4a93a653e8d0b123d) CVE-2011-1020 BugLink: http://bugs.launchpad.net/bugs/813026 Signed-off-by: Andy Whitcroft Acked-by: Stefan Bader Signed-off-by: Tim Gardner --- diff --git a/fs/proc/base.c b/fs/proc/base.c index e406d56..3803523 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -919,20 +919,18 @@ static ssize_t environ_read(struct file *file, char __user *buf, if (!task) goto out_no_task; - if (!ptrace_may_access(task, PTRACE_MODE_READ)) - goto out; - ret = -ENOMEM; page = (char *)__get_free_page(GFP_TEMPORARY); if (!page) goto out; - ret = 0; - mm = get_task_mm(task); - if (!mm) + mm = mm_for_maps(task); + ret = PTR_ERR(mm); + if (!mm || IS_ERR(mm)) goto out_free; + ret = 0; while (count > 0) { int this_len, retval, max_len;