diff options
author | Kees Cook <keescook@chromium.org> | 2018-04-10 19:34:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-11 13:28:37 -0400 |
commit | b83838313386f617d6bd8201be7f5b532059bba1 (patch) | |
tree | d38c1ea9433292b4a33efe3d3fad48bf8fb1f314 /fs | |
parent | 8f2af155b513583e8b149a384551f13e1ac5dc72 (diff) |
exec: introduce finalize_exec() before start_thread()
Provide a final callback into fs/exec.c before start_thread() takes
over, to handle any last-minute changes, like the coming restoration of
the stack limit.
Link: http://lkml.kernel.org/r/1518638796-20819-3-git-send-email-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ben Hutchings <ben@decadent.org.uk>
Cc: Ben Hutchings <ben.hutchings@codethink.co.uk>
Cc: Brad Spengler <spender@grsecurity.net>
Cc: Greg KH <greg@kroah.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Willy Tarreau <w@1wt.eu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/binfmt_aout.c | 1 | ||||
-rw-r--r-- | fs/binfmt_elf.c | 1 | ||||
-rw-r--r-- | fs/binfmt_elf_fdpic.c | 1 | ||||
-rw-r--r-- | fs/binfmt_flat.c | 1 | ||||
-rw-r--r-- | fs/exec.c | 6 |
5 files changed, 10 insertions, 0 deletions
diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c index ce1824f47ba6..c3deb2e35f20 100644 --- a/fs/binfmt_aout.c +++ b/fs/binfmt_aout.c | |||
@@ -330,6 +330,7 @@ beyond_if: | |||
330 | #ifdef __alpha__ | 330 | #ifdef __alpha__ |
331 | regs->gp = ex.a_gpvalue; | 331 | regs->gp = ex.a_gpvalue; |
332 | #endif | 332 | #endif |
333 | finalize_exec(bprm); | ||
333 | start_thread(regs, ex.a_entry, current->mm->start_stack); | 334 | start_thread(regs, ex.a_entry, current->mm->start_stack); |
334 | return 0; | 335 | return 0; |
335 | } | 336 | } |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index bdb201230bae..3edca6cb9a33 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
@@ -1155,6 +1155,7 @@ static int load_elf_binary(struct linux_binprm *bprm) | |||
1155 | ELF_PLAT_INIT(regs, reloc_func_desc); | 1155 | ELF_PLAT_INIT(regs, reloc_func_desc); |
1156 | #endif | 1156 | #endif |
1157 | 1157 | ||
1158 | finalize_exec(bprm); | ||
1158 | start_thread(regs, elf_entry, bprm->p); | 1159 | start_thread(regs, elf_entry, bprm->p); |
1159 | retval = 0; | 1160 | retval = 0; |
1160 | out: | 1161 | out: |
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 429326b6e2e7..d90993adeffa 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -463,6 +463,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) | |||
463 | dynaddr); | 463 | dynaddr); |
464 | #endif | 464 | #endif |
465 | 465 | ||
466 | finalize_exec(bprm); | ||
466 | /* everything is now ready... get the userspace context ready to roll */ | 467 | /* everything is now ready... get the userspace context ready to roll */ |
467 | entryaddr = interp_params.entry_addr ?: exec_params.entry_addr; | 468 | entryaddr = interp_params.entry_addr ?: exec_params.entry_addr; |
468 | start_thread(regs, entryaddr, current->mm->start_stack); | 469 | start_thread(regs, entryaddr, current->mm->start_stack); |
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c index 5d6b94475f27..82a48e830018 100644 --- a/fs/binfmt_flat.c +++ b/fs/binfmt_flat.c | |||
@@ -994,6 +994,7 @@ static int load_flat_binary(struct linux_binprm *bprm) | |||
994 | FLAT_PLAT_INIT(regs); | 994 | FLAT_PLAT_INIT(regs); |
995 | #endif | 995 | #endif |
996 | 996 | ||
997 | finalize_exec(bprm); | ||
997 | pr_debug("start_thread(regs=0x%p, entry=0x%lx, start_stack=0x%lx)\n", | 998 | pr_debug("start_thread(regs=0x%p, entry=0x%lx, start_stack=0x%lx)\n", |
998 | regs, start_addr, current->mm->start_stack); | 999 | regs, start_addr, current->mm->start_stack); |
999 | start_thread(regs, start_addr, current->mm->start_stack); | 1000 | start_thread(regs, start_addr, current->mm->start_stack); |
@@ -1384,6 +1384,12 @@ void setup_new_exec(struct linux_binprm * bprm) | |||
1384 | } | 1384 | } |
1385 | EXPORT_SYMBOL(setup_new_exec); | 1385 | EXPORT_SYMBOL(setup_new_exec); |
1386 | 1386 | ||
1387 | /* Runs immediately before start_thread() takes over. */ | ||
1388 | void finalize_exec(struct linux_binprm *bprm) | ||
1389 | { | ||
1390 | } | ||
1391 | EXPORT_SYMBOL(finalize_exec); | ||
1392 | |||
1387 | /* | 1393 | /* |
1388 | * Prepare credentials and lock ->cred_guard_mutex. | 1394 | * Prepare credentials and lock ->cred_guard_mutex. |
1389 | * install_exec_creds() commits the new creds and drops the lock. | 1395 | * install_exec_creds() commits the new creds and drops the lock. |