/*
* With the new mm installed it is completely impossible to
* fail and return to the original process. If anything from
- * here on returns an error, the check in
- * search_binary_handler() will SEGV current.
+ * here on returns an error, the check in __do_execve_file()
+ * will SEGV current.
*/
bprm->point_of_no_return = true;
bprm->mm = NULL;
read_lock(&binfmt_lock);
put_binfmt(fmt);
- if (retval < 0 && bprm->point_of_no_return) {
- /* we got to flush_old_exec() and failed after it */
- read_unlock(&binfmt_lock);
- force_sigsegv(SIGSEGV);
- return retval;
- }
- if (retval != -ENOEXEC || !bprm->file) {
+ if (bprm->point_of_no_return || !bprm->file ||
+ (retval != -ENOEXEC)) {
read_unlock(&binfmt_lock);
return retval;
}
return retval;
out:
+ /*
+ * If past the point of no return ensure the the code never
+ * returns to the userspace process. Use an existing fatal
+ * signal if present otherwise terminate the process with
+ * SIGSEGV.
+ */
+ if (bprm->point_of_no_return && !fatal_signal_pending(current))
+ force_sigsegv(SIGSEGV);
if (bprm->mm) {
acct_arg_size(bprm, 0);
mmput(bprm->mm);