mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Stephen Wilson <wilsons@start.ca>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>,
	bookjovi@gmail.com, Andrew Morton <akpm@linux-foundation.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	David Rientjes <rientjes@google.com>,
	Stephen Wilson <wilsons@start.ca>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] proc: put check_mem_permission before __get_free_page in mem_read
Date: Tue, 26 Apr 2011 12:03:00 -0400	[thread overview]
Message-ID: <20110426160300.GA14478@fibrous.localdomain> (raw)
In-Reply-To: <20110426141449.F37C.A69D9226@jp.fujitsu.com>

On Tue, Apr 26, 2011 at 02:12:46PM +0900, KOSAKI Motohiro wrote:
> From 74f827ce74e1c4f846905e940edfa5f639b5a2ce Mon Sep 17 00:00:00 2001
> From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> Date: Tue, 26 Apr 2011 13:57:02 +0900
> Subject: [PATCH] [PATCH] proc: put check_mem_permission after __get_free_page in mem_write
> 
> It should be better if put check_mem_permission after __get_free_page
> in mem_write, to be same as function mem_read.
> 
> Hugh Dickins explained the reason.
> 
>     check_mem_permission gets a reference to the mm.  If we __get_free_page
>     after check_mem_permission, imagine what happens if the system is out
>     of memory, and the mm we're looking at is selected for killing by the
>     OOM killer: while we wait in __get_free_page for more memory, no memory
>     is freed from the selected mm because it cannot reach exit_mmap while
>     we hold that reference.
> 
> 
> Reported-by: Jovi Zhang <bookjovi@gmail.com>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
> Cc: Hugh Dickins <hughd@google.com>
> Cc: Stephen Wilson <wilsons@start.ca>


I completely missed the oom case as well.  This certainly appears to be
the best solution.

	Reviewed-by: Stephen Wilson <wilsons@start.ca>

-- 
steve


  parent reply	other threads:[~2011-04-26 16:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-18  0:20 bookjovi
2011-04-24 15:33 ` KOSAKI Motohiro
2011-04-25 14:31 ` Stephen Wilson
2011-04-26  3:56 ` Hugh Dickins
2011-04-26  5:12   ` KOSAKI Motohiro
2011-04-26  5:50     ` [PATCH] proc: fix pagemap_read() error case (was Re: [PATCH] proc: put check_mem_permission before __get_free_page in mem_read) KOSAKI Motohiro
2011-04-26 16:44       ` Stephen Wilson
2011-04-26 20:44       ` Hugh Dickins
2011-04-28  1:45         ` KOSAKI Motohiro
2011-04-26 16:03     ` Stephen Wilson [this message]
2011-04-26 20:19     ` [PATCH] proc: put check_mem_permission before __get_free_page in mem_read Hugh Dickins
2011-04-26  8:55   ` Jovi Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110426160300.GA14478@fibrous.localdomain \
    --to=wilsons@start.ca \
    --cc=akpm@linux-foundation.org \
    --cc=bookjovi@gmail.com \
    --cc=hughd@google.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rientjes@google.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®