diff options
author | Jiri Slaby <jslaby@suse.cz> | 2010-01-08 03:03:26 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-01-08 03:03:26 -0500 |
commit | 76704fb56c7317ae02c3267fc31d215f3a2528ca (patch) | |
tree | 9175710b17e36663ef32f49ad990d894ca9d1491 /arch/sparc/kernel | |
parent | 6df1c176994fab993f3112e3e4145a7d2bae64d0 (diff) |
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
3e10e716abf3c71bdb5d86b8f507f9e72236c9cd
or ACCESS_ONCE if not applicable.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc/kernel')
-rw-r--r-- | arch/sparc/kernel/sys_sparc_64.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index cfa0e19abe3b..d77f54316948 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c | |||
@@ -365,6 +365,7 @@ EXPORT_SYMBOL(get_fb_unmapped_area); | |||
365 | void arch_pick_mmap_layout(struct mm_struct *mm) | 365 | void arch_pick_mmap_layout(struct mm_struct *mm) |
366 | { | 366 | { |
367 | unsigned long random_factor = 0UL; | 367 | unsigned long random_factor = 0UL; |
368 | unsigned long gap; | ||
368 | 369 | ||
369 | if (current->flags & PF_RANDOMIZE) { | 370 | if (current->flags & PF_RANDOMIZE) { |
370 | random_factor = get_random_int(); | 371 | random_factor = get_random_int(); |
@@ -379,9 +380,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm) | |||
379 | * Fall back to the standard layout if the personality | 380 | * Fall back to the standard layout if the personality |
380 | * bit is set, or if the expected stack growth is unlimited: | 381 | * bit is set, or if the expected stack growth is unlimited: |
381 | */ | 382 | */ |
383 | gap = rlimit(RLIMIT_STACK); | ||
382 | if (!test_thread_flag(TIF_32BIT) || | 384 | if (!test_thread_flag(TIF_32BIT) || |
383 | (current->personality & ADDR_COMPAT_LAYOUT) || | 385 | (current->personality & ADDR_COMPAT_LAYOUT) || |
384 | current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY || | 386 | gap == RLIM_INFINITY || |
385 | sysctl_legacy_va_layout) { | 387 | sysctl_legacy_va_layout) { |
386 | mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; | 388 | mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; |
387 | mm->get_unmapped_area = arch_get_unmapped_area; | 389 | mm->get_unmapped_area = arch_get_unmapped_area; |
@@ -389,9 +391,7 @@ void arch_pick_mmap_layout(struct mm_struct *mm) | |||
389 | } else { | 391 | } else { |
390 | /* We know it's 32-bit */ | 392 | /* We know it's 32-bit */ |
391 | unsigned long task_size = STACK_TOP32; | 393 | unsigned long task_size = STACK_TOP32; |
392 | unsigned long gap; | ||
393 | 394 | ||
394 | gap = current->signal->rlim[RLIMIT_STACK].rlim_cur; | ||
395 | if (gap < 128 * 1024 * 1024) | 395 | if (gap < 128 * 1024 * 1024) |
396 | gap = 128 * 1024 * 1024; | 396 | gap = 128 * 1024 * 1024; |
397 | if (gap > (task_size / 6 * 5)) | 397 | if (gap > (task_size / 6 * 5)) |