Commit 2854e72b58dad82f5248b30a45dda0df49e5fe05
Committed by
H. Peter Anvin
1 parent
be8cde8b24
Exists in
master
and in
39 other branches
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>
Showing 2 changed files with 3 additions and 3 deletions Side-by-side Diff
arch/x86/ia32/ia32_aout.c
... | ... | @@ -297,7 +297,7 @@ |
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) |
arch/x86/mm/mmap.c
... | ... | @@ -71,7 +71,7 @@ |
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,7 +96,7 @@ |
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; |