[Devel] [PATCH RHEL7 COMMIT] ms/mm: use may_adjust_brk helper
Konstantin Khorenko
khorenko at virtuozzo.com
Tue Oct 20 02:29:36 PDT 2015
The commit is pushed to "branch-rh7-3.10.0-229.7.2.vz7.8.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-229.7.2.vz7.8.8
------>
commit 7ed80b3f04e73e8692127a134efade3101ec2122
Author: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Tue Oct 20 13:28:01 2015 +0400
ms/mm: use may_adjust_brk helper
This is needed for CRIU.
ML: 8764b338b37524ab1a78aee527318ebee9762487
https://jira.sw.ru/browse/PSBM-39834
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
Cc: Kees Cook <keescook at chromium.org>
Cc: Tejun Heo <tj at kernel.org>
Cc: Andrew Vagin <avagin at openvz.org>
Cc: Eric W. Biederman <ebiederm at xmission.com>
Cc: H. Peter Anvin <hpa at zytor.com>
Acked-by: Serge Hallyn <serge.hallyn at canonical.com>
Cc: Pavel Emelyanov <xemul at parallels.com>
Cc: Vasiliy Kulikov <segoon at openwall.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu at jp.fujitsu.com>
Cc: Michael Kerrisk <mtk.manpages at gmail.com>
Cc: Julien Tinnes <jln at google.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Cyrill Gorcunov <gorcunov at virtuozzo.com>
---
kernel/sys.c | 11 ++++-------
mm/mmap.c | 7 +++----
2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/kernel/sys.c b/kernel/sys.c
index 737d9da..9218fde 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -2279,7 +2279,6 @@ out:
static int prctl_set_mm(int opt, unsigned long addr,
unsigned long arg4, unsigned long arg5)
{
- unsigned long rlim = rlimit(RLIMIT_DATA);
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
int error;
@@ -2330,9 +2329,8 @@ static int prctl_set_mm(int opt, unsigned long addr,
if (addr <= mm->end_data)
goto out;
- if (rlim < RLIM_INFINITY &&
- (mm->brk - addr) +
- (mm->end_data - mm->start_data) > rlim)
+ if (check_data_rlimit(rlimit(RLIMIT_DATA), mm->brk, addr,
+ mm->end_data, mm->start_data))
goto out;
mm->start_brk = addr;
@@ -2342,9 +2340,8 @@ static int prctl_set_mm(int opt, unsigned long addr,
if (addr <= mm->end_data)
goto out;
- if (rlim < RLIM_INFINITY &&
- (addr - mm->start_brk) +
- (mm->end_data - mm->start_data) > rlim)
+ if (check_data_rlimit(rlimit(RLIMIT_DATA), addr, mm->start_brk,
+ mm->end_data, mm->start_data))
goto out;
mm->brk = addr;
diff --git a/mm/mmap.c b/mm/mmap.c
index 7cc9812..8796ed6 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -272,7 +272,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len, int soft);
SYSCALL_DEFINE1(brk, unsigned long, brk)
{
- unsigned long rlim, retval;
+ unsigned long retval;
unsigned long newbrk, oldbrk;
struct mm_struct *mm = current->mm;
unsigned long min_brk;
@@ -302,9 +302,8 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
* segment grow beyond its set limit the in case where the limit is
* not page aligned -Ram Gupta
*/
- rlim = rlimit(RLIMIT_DATA);
- if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
- (mm->end_data - mm->start_data) > rlim)
+ if (check_data_rlimit(rlimit(RLIMIT_DATA), brk, mm->start_brk,
+ mm->end_data, mm->start_data))
goto out;
newbrk = PAGE_ALIGN(brk);
More information about the Devel
mailing list