diff options
author | Jiri Slaby <jslaby@suse.cz> | 2010-03-05 16:42:42 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-03-06 14:26:29 -0500 |
commit | d554ed895dc8f293cc712c71f14b101ace82579a (patch) | |
tree | fd29ba33d640e156e2ca4267ffbdb9dc566fd3d6 /fs/exec.c | |
parent | 221e3ebf6d5f2625373573155924e39f196c5d3d (diff) |
fs: use rlimit helpers
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 commit 3e10e716abf3 ("resource:
add helpers for fetching rlimits") or ACCESS_ONCE if not applicable.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/exec.c')
-rw-r--r-- | fs/exec.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -195,7 +195,7 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos, | |||
195 | * to work from. | 195 | * to work from. |
196 | */ | 196 | */ |
197 | rlim = current->signal->rlim; | 197 | rlim = current->signal->rlim; |
198 | if (size > rlim[RLIMIT_STACK].rlim_cur / 4) { | 198 | if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur) / 4) { |
199 | put_page(page); | 199 | put_page(page); |
200 | return NULL; | 200 | return NULL; |
201 | } | 201 | } |
@@ -579,7 +579,7 @@ int setup_arg_pages(struct linux_binprm *bprm, | |||
579 | 579 | ||
580 | #ifdef CONFIG_STACK_GROWSUP | 580 | #ifdef CONFIG_STACK_GROWSUP |
581 | /* Limit stack size to 1GB */ | 581 | /* Limit stack size to 1GB */ |
582 | stack_base = current->signal->rlim[RLIMIT_STACK].rlim_max; | 582 | stack_base = rlimit_max(RLIMIT_STACK); |
583 | if (stack_base > (1 << 30)) | 583 | if (stack_base > (1 << 30)) |
584 | stack_base = 1 << 30; | 584 | stack_base = 1 << 30; |
585 | 585 | ||
@@ -1535,7 +1535,7 @@ static int format_corename(char *corename, long signr) | |||
1535 | /* core limit size */ | 1535 | /* core limit size */ |
1536 | case 'c': | 1536 | case 'c': |
1537 | rc = snprintf(out_ptr, out_end - out_ptr, | 1537 | rc = snprintf(out_ptr, out_end - out_ptr, |
1538 | "%lu", current->signal->rlim[RLIMIT_CORE].rlim_cur); | 1538 | "%lu", rlimit(RLIMIT_CORE)); |
1539 | if (rc > out_end - out_ptr) | 1539 | if (rc > out_end - out_ptr) |
1540 | goto out; | 1540 | goto out; |
1541 | out_ptr += rc; | 1541 | out_ptr += rc; |
@@ -1800,7 +1800,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
1800 | struct coredump_params cprm = { | 1800 | struct coredump_params cprm = { |
1801 | .signr = signr, | 1801 | .signr = signr, |
1802 | .regs = regs, | 1802 | .regs = regs, |
1803 | .limit = current->signal->rlim[RLIMIT_CORE].rlim_cur, | 1803 | .limit = rlimit(RLIMIT_CORE), |
1804 | }; | 1804 | }; |
1805 | 1805 | ||
1806 | audit_core_dumps(signr); | 1806 | audit_core_dumps(signr); |