lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 6 Oct 2015 18:28:04 +0200
From:	Oleg Nesterov <>
To:	Andrew Morton <>
Cc:	David Rientjes <>,
	Kyle Walker <>,
	Michal Hocko <>,
	Stanislav Kozina <>,
	Tetsuo Handa <>,
Subject: [PATCH -mm] mmoom-fix-potentially-killing-unrelated-process-fix

oom_kill_process() does atomic_inc(&mm->mm_users) to ensure that
this ->mm can't go away and this is wrong, change it to rely on
->mm_count and mmdrop().

Firstly, we do not want to delay exit_mmap/etc if the victim exits
before we do mmput(), but this is minor.

More importantly, we simply can not do mmput() in oom_kill_process(),
this can deadlock if (for example) the caller holds i_mmap_rwsem and
mmput() actually leads to exit_mmap(); the victim can have this file
mmaped and in this case unmap_vmas/free_pgtables paths will take the
same lock for writing. And at least huge_pmd_share() does pmd_alloc()
under i_mmap_rwsem because VM_HUGETLB memory is not reclaimable.

Signed-off-by: Oleg Nesterov <>
 mm/oom_kill.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 034d219..52abb78 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -571,7 +571,7 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
 	/* Get a reference to safely compare mm after task_unlock(victim) */
 	mm = victim->mm;
-	atomic_inc(&mm->mm_users);
+	atomic_inc(&mm->mm_count);
 	 * We should send SIGKILL before setting TIF_MEMDIE in order to prevent
 	 * the OOM victim from depleting the memory reserves from the user
@@ -609,7 +609,7 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
-	mmput(mm);
+	mmdrop(mm);
 #undef K

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

Powered by blists - more mailing lists