Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1684020
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 8/8] exec: Use sane stack rlimit under secureexec |
| Date | 2017-07-10 10:00 +0200 |
| Message-ID | <u1BLP-2bz-9@gated-at.bofh.it> (permalink) |
| References | <u1BLP-2bz-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
For a secureexec, before memory layout selection has happened, reset the stack rlimit to something sane to avoid the caller having control over the resulting layouts. $ ulimit -s 8192 $ ulimit -s unlimited $ /bin/sh -c 'ulimit -s' unlimited $ sudo /bin/sh -c 'ulimit -s' 8192 Signed-off-by: Kees Cook <keescook@chromium.org> --- fs/exec.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/exec.c b/fs/exec.c index e0186db02f90..1e3463854a16 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1343,6 +1343,16 @@ void setup_new_exec(struct linux_binprm * bprm) /* Make sure parent cannot signal privileged process. */ current->pdeath_signal = 0; + + /* + * For secureexec, reset the stack limit to sane default to + * avoid bad behavior from the prior rlimits. This has to + * happen before arch_pick_mmap_layout(), which examines + * RLIMIT_STACK, but after the point of no return to avoid + * needing to clean up the change on failure. + */ + if (current->signal->rlim[RLIMIT_STACK].rlim_cur > _STK_LIM) + current->signal->rlim[RLIMIT_STACK].rlim_cur = _STK_LIM; } arch_pick_mmap_layout(current->mm); -- 2.7.4
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH v2 8/8] exec: Use sane stack rlimit under secureexec Kees Cook <keescook@chromium.org> - 2017-07-10 10:00 +0200 Re: [PATCH v2 8/8] exec: Use sane stack rlimit under secureexec Ben Hutchings <ben@decadent.org.uk> - 2017-07-10 16:10 +0200
csiph-web