Re: [PATCH] proc: put check_mem_permission before __get_free_pagein mem_read
From: Stephen Wilson
Date: Tue Apr 26 2011 - 12:03:50 EST
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@xxxxxxxxxxxxxx>
> 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@xxxxxxxxx>
> Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@xxxxxxxxxxxxxx>
> Cc: Hugh Dickins <hughd@xxxxxxxxxx>
> Cc: Stephen Wilson <wilsons@xxxxxxxx>
I completely missed the oom case as well. This certainly appears to be
the best solution.
Reviewed-by: Stephen Wilson <wilsons@xxxxxxxx>
--
steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/