diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-05-04 20:11:36 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-10-09 02:39:00 -0400 |
commit | 19d860a140beac48a1377f179e693abe86a9dac9 (patch) | |
tree | 4da809a162a3b9aea8575828f52e150b26ca6ff1 /fs/binfmt_elf_fdpic.c | |
parent | 2926620145095ffb0350b2312ac9d0af8537796f (diff) |
handle suicide on late failure exits in execve() in search_binary_handler()
... rather than doing that in the guts of ->load_binary().
[updated to fix the bug spotted by Shentino - for SIGSEGV we really need
something stronger than send_sig_info(); again, better do that in one place]
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/binfmt_elf_fdpic.c')
-rw-r--r-- | fs/binfmt_elf_fdpic.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index fe2a643ee005..d3634bfb7fe1 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -317,8 +317,8 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) | |||
317 | goto error; | 317 | goto error; |
318 | 318 | ||
319 | /* there's now no turning back... the old userspace image is dead, | 319 | /* there's now no turning back... the old userspace image is dead, |
320 | * defunct, deceased, etc. after this point we have to exit via | 320 | * defunct, deceased, etc. |
321 | * error_kill */ | 321 | */ |
322 | set_personality(PER_LINUX_FDPIC); | 322 | set_personality(PER_LINUX_FDPIC); |
323 | if (elf_read_implies_exec(&exec_params.hdr, executable_stack)) | 323 | if (elf_read_implies_exec(&exec_params.hdr, executable_stack)) |
324 | current->personality |= READ_IMPLIES_EXEC; | 324 | current->personality |= READ_IMPLIES_EXEC; |
@@ -343,24 +343,22 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) | |||
343 | 343 | ||
344 | retval = setup_arg_pages(bprm, current->mm->start_stack, | 344 | retval = setup_arg_pages(bprm, current->mm->start_stack, |
345 | executable_stack); | 345 | executable_stack); |
346 | if (retval < 0) { | 346 | if (retval < 0) |
347 | send_sig(SIGKILL, current, 0); | 347 | goto error; |
348 | goto error_kill; | ||
349 | } | ||
350 | #endif | 348 | #endif |
351 | 349 | ||
352 | /* load the executable and interpreter into memory */ | 350 | /* load the executable and interpreter into memory */ |
353 | retval = elf_fdpic_map_file(&exec_params, bprm->file, current->mm, | 351 | retval = elf_fdpic_map_file(&exec_params, bprm->file, current->mm, |
354 | "executable"); | 352 | "executable"); |
355 | if (retval < 0) | 353 | if (retval < 0) |
356 | goto error_kill; | 354 | goto error; |
357 | 355 | ||
358 | if (interpreter_name) { | 356 | if (interpreter_name) { |
359 | retval = elf_fdpic_map_file(&interp_params, interpreter, | 357 | retval = elf_fdpic_map_file(&interp_params, interpreter, |
360 | current->mm, "interpreter"); | 358 | current->mm, "interpreter"); |
361 | if (retval < 0) { | 359 | if (retval < 0) { |
362 | printk(KERN_ERR "Unable to load interpreter\n"); | 360 | printk(KERN_ERR "Unable to load interpreter\n"); |
363 | goto error_kill; | 361 | goto error; |
364 | } | 362 | } |
365 | 363 | ||
366 | allow_write_access(interpreter); | 364 | allow_write_access(interpreter); |
@@ -397,7 +395,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) | |||
397 | if (IS_ERR_VALUE(current->mm->start_brk)) { | 395 | if (IS_ERR_VALUE(current->mm->start_brk)) { |
398 | retval = current->mm->start_brk; | 396 | retval = current->mm->start_brk; |
399 | current->mm->start_brk = 0; | 397 | current->mm->start_brk = 0; |
400 | goto error_kill; | 398 | goto error; |
401 | } | 399 | } |
402 | 400 | ||
403 | current->mm->brk = current->mm->start_brk; | 401 | current->mm->brk = current->mm->start_brk; |
@@ -410,7 +408,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm) | |||
410 | install_exec_creds(bprm); | 408 | install_exec_creds(bprm); |
411 | if (create_elf_fdpic_tables(bprm, current->mm, | 409 | if (create_elf_fdpic_tables(bprm, current->mm, |
412 | &exec_params, &interp_params) < 0) | 410 | &exec_params, &interp_params) < 0) |
413 | goto error_kill; | 411 | goto error; |
414 | 412 | ||
415 | kdebug("- start_code %lx", current->mm->start_code); | 413 | kdebug("- start_code %lx", current->mm->start_code); |
416 | kdebug("- end_code %lx", current->mm->end_code); | 414 | kdebug("- end_code %lx", current->mm->end_code); |
@@ -449,12 +447,6 @@ error: | |||
449 | kfree(interp_params.phdrs); | 447 | kfree(interp_params.phdrs); |
450 | kfree(interp_params.loadmap); | 448 | kfree(interp_params.loadmap); |
451 | return retval; | 449 | return retval; |
452 | |||
453 | /* unrecoverable error - kill the process */ | ||
454 | error_kill: | ||
455 | send_sig(SIGSEGV, current, 0); | ||
456 | goto error; | ||
457 | |||
458 | } | 450 | } |
459 | 451 | ||
460 | /*****************************************************************************/ | 452 | /*****************************************************************************/ |