* [PATCH 1/2] mm: do not limit VmData with RLIMIT_DATA
@ 2016-01-23 7:39 Konstantin Khlebnikov
2016-01-23 7:39 ` [PATCH 2/2] mm: " Konstantin Khlebnikov
2016-01-23 7:54 ` [PATCH 1/2] mm: do not " Cyrill Gorcunov
0 siblings, 2 replies; 4+ messages in thread
From: Konstantin Khlebnikov @ 2016-01-23 7:39 UTC (permalink / raw)
To: Cyrill Gorcunov, linux-mm, Linus Torvalds, Andrew Morton, linux-kernel
Cc: Vegard Nossum, Peter Zijlstra, Vladimir Davydov, Andy Lutomirski,
Quentin Casasnovas, Kees Cook, Willy Tarreau, Pavel Emelyanov
This partially reverts 84638335900f ("mm: rework virtual memory accounting")
Before that commit RLIMIT_DATA have control only over size of the brk region.
But that change have caused problems with all existing versions of valgrind
because they set RLIMIT_DATA to zero for some reason.
More over, current check has a major flaw: RLIMIT_DATA in bytes,
not pages. So, some problems might have slipped through testing.
Let's revert it for now and put back in next release.
Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
Link: http://lkml.kernel.org/r/20151228211015.GL2194@uranus
Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
---
mm/mmap.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/mm/mmap.c b/mm/mmap.c
index 84b12624ceb0..e0cd98c510ba 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2982,10 +2982,6 @@ bool may_expand_vm(struct mm_struct *mm, vm_flags_t flags, unsigned long npages)
if (mm->total_vm + npages > rlimit(RLIMIT_AS) >> PAGE_SHIFT)
return false;
- if ((flags & (VM_WRITE | VM_SHARED | (VM_STACK_FLAGS &
- (VM_GROWSUP | VM_GROWSDOWN)))) == VM_WRITE)
- return mm->data_vm + npages <= rlimit(RLIMIT_DATA);
-
return true;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 2/2] mm: limit VmData with RLIMIT_DATA
2016-01-23 7:39 [PATCH 1/2] mm: do not limit VmData with RLIMIT_DATA Konstantin Khlebnikov
@ 2016-01-23 7:39 ` Konstantin Khlebnikov
2016-01-23 7:55 ` Cyrill Gorcunov
2016-01-23 7:54 ` [PATCH 1/2] mm: do not " Cyrill Gorcunov
1 sibling, 1 reply; 4+ messages in thread
From: Konstantin Khlebnikov @ 2016-01-23 7:39 UTC (permalink / raw)
To: Cyrill Gorcunov, linux-mm, Linus Torvalds, Andrew Morton, linux-kernel
Cc: Vegard Nossum, Peter Zijlstra, Vladimir Davydov, Andy Lutomirski,
Quentin Casasnovas, Kees Cook, Willy Tarreau, Pavel Emelyanov
This adds is correct version of RLIMIT_DATA check.
And kernel boot option "ignore_rlimit_data" for reverting old behavior.
Also could be set by /sys/module/kernel/parameters/ignore_rlimit_data.
Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
---
Documentation/kernel-parameters.txt | 5 +++++
mm/mmap.c | 8 ++++++++
2 files changed, 13 insertions(+)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index cfb2c0f1a4a8..850239102e86 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1461,6 +1461,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
could change it dynamically, usually by
/sys/module/printk/parameters/ignore_loglevel.
+ ignore_rlimit_data
+ Ignore setrlimit(RLIMIT_DATA) setting for private
+ mappings (as it was before). Could be changed by
+ /sys/module/kernel/parameters/ignore_rlimit_data.
+
ihash_entries= [KNL]
Set number of hash buckets for inode cache.
diff --git a/mm/mmap.c b/mm/mmap.c
index e0cd98c510ba..af272025b1b9 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -42,6 +42,7 @@
#include <linux/memory.h>
#include <linux/printk.h>
#include <linux/userfaultfd_k.h>
+#include <linux/moduleparam.h>
#include <asm/uaccess.h>
#include <asm/cacheflush.h>
@@ -69,6 +70,8 @@ const int mmap_rnd_compat_bits_max = CONFIG_ARCH_MMAP_RND_COMPAT_BITS_MAX;
int mmap_rnd_compat_bits __read_mostly = CONFIG_ARCH_MMAP_RND_COMPAT_BITS;
#endif
+static bool ignore_rlimit_data = false;
+core_param(ignore_rlimit_data, ignore_rlimit_data, bool, 0644);
static void unmap_region(struct mm_struct *mm,
struct vm_area_struct *vma, struct vm_area_struct *prev,
@@ -2982,6 +2985,11 @@ bool may_expand_vm(struct mm_struct *mm, vm_flags_t flags, unsigned long npages)
if (mm->total_vm + npages > rlimit(RLIMIT_AS) >> PAGE_SHIFT)
return false;
+ if (!ignore_rlimit_data && (flags & (VM_WRITE | VM_SHARED |
+ (VM_STACK_FLAGS & (VM_GROWSUP | VM_GROWSDOWN)))) == VM_WRITE &&
+ mm->data_vm + npages > rlimit(RLIMIT_DATA) >> PAGE_SHIFT)
+ return false;
+
return true;
}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mm: limit VmData with RLIMIT_DATA
2016-01-23 7:39 ` [PATCH 2/2] mm: " Konstantin Khlebnikov
@ 2016-01-23 7:55 ` Cyrill Gorcunov
0 siblings, 0 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2016-01-23 7:55 UTC (permalink / raw)
To: Konstantin Khlebnikov
Cc: linux-mm, Linus Torvalds, Andrew Morton, linux-kernel,
Vegard Nossum, Peter Zijlstra, Vladimir Davydov, Andy Lutomirski,
Quentin Casasnovas, Kees Cook, Willy Tarreau, Pavel Emelyanov
On Sat, Jan 23, 2016 at 10:39:47AM +0300, Konstantin Khlebnikov wrote:
> This adds is correct version of RLIMIT_DATA check.
> And kernel boot option "ignore_rlimit_data" for reverting old behavior.
> Also could be set by /sys/module/kernel/parameters/ignore_rlimit_data.
>
> Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mm: do not limit VmData with RLIMIT_DATA
2016-01-23 7:39 [PATCH 1/2] mm: do not limit VmData with RLIMIT_DATA Konstantin Khlebnikov
2016-01-23 7:39 ` [PATCH 2/2] mm: " Konstantin Khlebnikov
@ 2016-01-23 7:54 ` Cyrill Gorcunov
1 sibling, 0 replies; 4+ messages in thread
From: Cyrill Gorcunov @ 2016-01-23 7:54 UTC (permalink / raw)
To: Konstantin Khlebnikov
Cc: linux-mm, Linus Torvalds, Andrew Morton, linux-kernel,
Vegard Nossum, Peter Zijlstra, Vladimir Davydov, Andy Lutomirski,
Quentin Casasnovas, Kees Cook, Willy Tarreau, Pavel Emelyanov
On Sat, Jan 23, 2016 at 10:39:40AM +0300, Konstantin Khlebnikov wrote:
> This partially reverts 84638335900f ("mm: rework virtual memory accounting")
>
> Before that commit RLIMIT_DATA have control only over size of the brk region.
> But that change have caused problems with all existing versions of valgrind
> because they set RLIMIT_DATA to zero for some reason.
>
> More over, current check has a major flaw: RLIMIT_DATA in bytes,
> not pages. So, some problems might have slipped through testing.
> Let's revert it for now and put back in next release.
>
> Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
> Link: http://lkml.kernel.org/r/20151228211015.GL2194@uranus
> Reported-by: Christian Borntraeger <borntraeger@de.ibm.com>
Looks great for me. Thanks a lot, Kostya!
Acked-by: Cyrill Gorcunov <gorcunov@openvz.org>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-23 7:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-23 7:39 [PATCH 1/2] mm: do not limit VmData with RLIMIT_DATA Konstantin Khlebnikov
2016-01-23 7:39 ` [PATCH 2/2] mm: " Konstantin Khlebnikov
2016-01-23 7:55 ` Cyrill Gorcunov
2016-01-23 7:54 ` [PATCH 1/2] mm: do not " Cyrill Gorcunov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox