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

x86: Use helpers for rlimits

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

We can either use rlimit helpers added in
3e10e716abf3c71bdb5d86b8f507f9e72236c9cd or ACCESS_ONCE if not
applicable; this patch uses the helpers.

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
LKML-Reference: <1264609942-24621-1-git-send-email-jslaby@suse.cz>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>

authored by

Jiri Slaby and committed by
H. Peter Anvin
2854e72b be8cde8b

+3 -3
+1 -1
arch/x86/ia32/ia32_aout.c
··· 297 297 * size limits imposed on them by creating programs with large 298 298 * arrays in the data or bss. 299 299 */ 300 - rlim = current->signal->rlim[RLIMIT_DATA].rlim_cur; 300 + rlim = rlimit(RLIMIT_DATA); 301 301 if (rlim >= RLIM_INFINITY) 302 302 rlim = ~0; 303 303 if (ex.a_data + ex.a_bss > rlim)
+2 -2
arch/x86/mm/mmap.c
··· 71 71 if (current->personality & ADDR_COMPAT_LAYOUT) 72 72 return 1; 73 73 74 - if (current->signal->rlim[RLIMIT_STACK].rlim_cur == RLIM_INFINITY) 74 + if (rlimit(RLIMIT_STACK) == RLIM_INFINITY) 75 75 return 1; 76 76 77 77 return sysctl_legacy_va_layout; ··· 96 96 97 97 static unsigned long mmap_base(void) 98 98 { 99 - unsigned long gap = current->signal->rlim[RLIMIT_STACK].rlim_cur; 99 + unsigned long gap = rlimit(RLIMIT_STACK); 100 100 101 101 if (gap < MIN_GAP) 102 102 gap = MIN_GAP;