All of lore.kernel.org
 help / color / mirror / Atom feed
* + proc-put-check_mem_permission-before-__get_free_page-in-mem_read.patch added to -mm tree
@ 2011-04-25 20:11 akpm
  2011-04-25 22:01 ` Alexey Dobriyan
  0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2011-04-25 20:11 UTC (permalink / raw)
  To: mm-commits; +Cc: bookjovi, adobriyan, kosaki.motohiro, wilsons


The patch titled
     proc: put check_mem_permission before __get_free_page in mem_read
has been added to the -mm tree.  Its filename is
     proc-put-check_mem_permission-before-__get_free_page-in-mem_read.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
out what to do about this

The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/

------------------------------------------------------
Subject: proc: put check_mem_permission before __get_free_page in mem_read
From: Jovi Zhang <bookjovi@gmail.com>

It would be better to put check_mem_permission() before __get_free_page()
in mem_read(), to be same as mem_write().

Signed-off-by: Jovi Zhang <bookjovi@gmail.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Reviewed-by: Stephen Wilson <wilsons@start.ca>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/proc/base.c |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff -puN fs/proc/base.c~proc-put-check_mem_permission-before-__get_free_page-in-mem_read fs/proc/base.c
--- a/fs/proc/base.c~proc-put-check_mem_permission-before-__get_free_page-in-mem_read
+++ a/fs/proc/base.c
@@ -831,23 +831,21 @@ static ssize_t mem_read(struct file * fi
 	if (!task)
 		goto out_no_task;
 
-	ret = -ENOMEM;
-	page = (char *)__get_free_page(GFP_TEMPORARY);
-	if (!page)
-		goto out;
-
 	mm = check_mem_permission(task);
 	ret = PTR_ERR(mm);
 	if (IS_ERR(mm))
-		goto out_free;
+		goto out_task;
 
 	ret = -EIO;
- 
 	if (file->private_data != (void*)((long)current->self_exec_id))
-		goto out_put;
+		goto out_mm;
+
+	ret = -ENOMEM;
+	page = (char *)__get_free_page(GFP_TEMPORARY);
+	if (!page)
+		goto out_mm;
 
 	ret = 0;
- 
 	while (count > 0) {
 		int this_len, retval;
 
@@ -870,12 +868,10 @@ static ssize_t mem_read(struct file * fi
 		count -= retval;
 	}
 	*ppos = src;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-25 22:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-25 20:11 + proc-put-check_mem_permission-before-__get_free_page-in-mem_read.patch added to -mm tree akpm
2011-04-25 22:01 ` Alexey Dobriyan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.