lists.openwall.net   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  linux-cve-announce  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]
Message-Id: <1456752417-9626-7-git-send-email-mhocko@kernel.org>
Date:	Mon, 29 Feb 2016 14:26:45 +0100
From:	Michal Hocko <mhocko@...nel.org>
To:	LKML <linux-kernel@...r.kernel.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>, <linux-mm@...ck.org>,
	Alex Deucher <alexander.deucher@....com>,
	Alex Thorlton <athorlton@....com>,
	Andrea Arcangeli <aarcange@...hat.com>,
	Andy Lutomirski <luto@...capital.net>,
	Benjamin LaHaise <bcrl@...ck.org>,
	Christian König <christian.koenig@....com>,
	Daniel Vetter <daniel.vetter@...el.com>,
	Dave Hansen <dave.hansen@...ux.intel.com>,
	David Airlie <airlied@...ux.ie>,
	Davidlohr Bueso <dave@...olabs.net>,
	David Rientjes <rientjes@...gle.com>,
	"H . Peter Anvin" <hpa@...or.com>, Hugh Dickins <hughd@...gle.com>,
	Ingo Molnar <mingo@...nel.org>,
	Johannes Weiner <hannes@...xchg.org>,
	"Kirill A . Shutemov" <kirill.shutemov@...ux.intel.com>,
	Konstantin Khlebnikov <koct9i@...il.com>,
	linux-arch@...r.kernel.org, Mel Gorman <mgorman@...e.de>,
	Oleg Nesterov <oleg@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Petr Cermak <petrcermak@...omium.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Michal Hocko <mhocko@...e.com>
Subject: [PATCH 06/18] mm: make vm_brk killable

From: Michal Hocko <mhocko@...e.com>

Now that all the callers handle vm_brk failure we can change it
wait for mmap_sem killable to help oom_reaper to not get blocked
just because vm_brk gets blocked behind mmap_sem readers.

Cc: "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>
Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Andrea Arcangeli <aarcange@...hat.com>
Signed-off-by: Michal Hocko <mhocko@...e.com>
---
 include/linux/mm.h | 2 +-
 mm/mmap.c          | 9 +++------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 4ee6a3561540..dccaea8682f2 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -2077,7 +2077,7 @@ static inline void mm_populate(unsigned long addr, unsigned long len) {}
 #endif
 
 /* These take the mm semaphore themselves */
-extern unsigned long vm_brk(unsigned long, unsigned long);
+extern unsigned long __must_check vm_brk(unsigned long, unsigned long);
 extern int vm_munmap(unsigned long, size_t);
 extern unsigned long __must_check vm_mmap(struct file *, unsigned long,
         unsigned long, unsigned long,
diff --git a/mm/mmap.c b/mm/mmap.c
index 5d33c841e3a2..3f264fb14118 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2718,12 +2718,9 @@ unsigned long vm_brk(unsigned long addr, unsigned long len)
 	unsigned long ret;
 	bool populate;
 
-	/*
-	 * XXX not all users are chcecking the return value, convert
-	 * to down_write_killable after they are able to cope with
-	 * error
-	 */
-	down_write(&mm->mmap_sem);
+	if (down_write_killable(&mm->mmap_sem))
+		return -EINTR;
+
 	ret = do_brk(addr, len);
 	populate = ((mm->def_flags & VM_LOCKED) != 0);
 	up_write(&mm->mmap_sem);
-- 
2.7.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ