Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit dce9c1df authored by Tetsuo Handa's avatar Tetsuo Handa Committed by Dyneteve
Browse files

UPSTREAM: mm/oom_kill.c: fix potentially killing unrelated process



At the for_each_process() loop in oom_kill_process(), we are comparing
address of OOM victim's mm without holding a reference to that mm.  If
there are a lot of processes to compare or a lot of "Kill process %d (%s)
sharing same memory" messages to print, for_each_process() loop could take
very long time.

It is possible that meanwhile the OOM victim exits and releases its mm,
and then mm is allocated with the same address and assigned to some
unrelated process.  When we hit such race, the unrelated process will be
killed by error.  To make sure that the OOM victim's mm does not go away
until for_each_process() loop finishes, get a reference on the OOM
victim's mm before calling task_unlock(victim).

[oleg@redhat.com: several fixes]
Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Cc: David Rientjes <rientjes@google.com>
Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>

BUG=chromium:727707
TEST=Build and boot Caroline, try to load it to start ooming

(cherry picked from commit 880b768937e90c433c0c8254a22b1eb63df005a4)
Signed-off-by: default avatarDmitry Torokhov <dtor@chromium.org>
Change-Id: If1ae193d756ee952aa253b91ca794d4a6926bd3d
Reviewed-on: https://chromium-review.googlesource.com/521811


Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
parent 43de1e4b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment