Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Jiri Slaby and committed by
David S. Miller
76704fb5 6df1c176

+3 -3
+3 -3
arch/sparc/kernel/sys_sparc_64.c
··· 365 365 void arch_pick_mmap_layout(struct mm_struct *mm) 366 366 { 367 367 unsigned long random_factor = 0UL; 368 + unsigned long gap; 368 369 369 370 if (current->flags & PF_RANDOMIZE) { 370 371 random_factor = get_random_int(); ··· 380 379 * Fall back to the standard layout if the personality 381 380 * bit is set, or if the expected stack growth is unlimited: 382 381 */ 382 + gap = rlimit(RLIMIT_STACK); 383 383 if (!test_thread_flag(TIF_32BIT) || 384 384 (current->personality & ADDR_COMPAT_LAYOUT) || 385 - current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY || 385 + gap == RLIM_INFINITY || 386 386 sysctl_legacy_va_layout) { 387 387 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor; 388 388 mm->get_unmapped_area = arch_get_unmapped_area; ··· 391 389 } else { 392 390 /* We know it's 32-bit */ 393 391 unsigned long task_size = STACK_TOP32; 394 - unsigned long gap; 395 392 396 - gap = current->signal->rlim[RLIMIT_STACK].rlim_cur; 397 393 if (gap < 128 * 1024 * 1024) 398 394 gap = 128 * 1024 * 1024; 399 395 if (gap > (task_size / 6 * 5))