Commit 76704fb5 authored by Jiri Slaby's avatar Jiri Slaby Committed by David S. Miller

SPARC: use helpers for rlimits

Make sure compiler won't do weird things with limits. E.g. fetching
them twice may return 2 different values after writable limits are
implemented.

I.e. either use rlimit helpers added in
3e10e716
or ACCESS_ONCE if not applicable.
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6df1c176
...@@ -365,6 +365,7 @@ EXPORT_SYMBOL(get_fb_unmapped_area); ...@@ -365,6 +365,7 @@ EXPORT_SYMBOL(get_fb_unmapped_area);
void arch_pick_mmap_layout(struct mm_struct *mm) void arch_pick_mmap_layout(struct mm_struct *mm)
{ {
unsigned long random_factor = 0UL; unsigned long random_factor = 0UL;
unsigned long gap;
if (current->flags & PF_RANDOMIZE) { if (current->flags & PF_RANDOMIZE) {
random_factor = get_random_int(); random_factor = get_random_int();
...@@ -379,9 +380,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm) ...@@ -379,9 +380,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
* Fall back to the standard layout if the personality * Fall back to the standard layout if the personality
* bit is set, or if the expected stack growth is unlimited: * bit is set, or if the expected stack growth is unlimited:
*/ */
gap = rlimit(RLIMIT_STACK);
if (!test_thread_flag(TIF_32BIT) || if (!test_thread_flag(TIF_32BIT) ||
(current->personality & ADDR_COMPAT_LAYOUT) || (current->personality & ADDR_COMPAT_LAYOUT) ||
current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY || gap == RLIM_INFINITY ||
sysctl_legacy_va_layout) { sysctl_legacy_va_layout) {
mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
mm->get_unmapped_area = arch_get_unmapped_area; mm->get_unmapped_area = arch_get_unmapped_area;
...@@ -389,9 +391,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm) ...@@ -389,9 +391,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
} else { } else {
/* We know it's 32-bit */ /* We know it's 32-bit */
unsigned long task_size = STACK_TOP32; unsigned long task_size = STACK_TOP32;
unsigned long gap;
gap = current->signal->rlim[RLIMIT_STACK].rlim_cur;
if (gap < 128 * 1024 * 1024) if (gap < 128 * 1024 * 1024)
gap = 128 * 1024 * 1024; gap = 128 * 1024 * 1024;
if (gap > (task_size / 6 * 5)) if (gap > (task_size / 6 * 5))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment