]> Pileus Git - ~andy/linux/blobdiff - fs/exec.c
GFS2: Extend umount wait coverage to full glock lifetime
[~andy/linux] / fs / exec.c
index 77db9a97a773fff7ee88e1be4c65bb18347ae15c..0790a107ff7e9789d5d212db9e2919e009f0e370 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -941,9 +941,7 @@ void set_task_comm(struct task_struct *tsk, char *buf)
 
 int flush_old_exec(struct linux_binprm * bprm)
 {
-       char * name;
-       int i, ch, retval;
-       char tcomm[sizeof(current->comm)];
+       int retval;
 
        /*
         * Make sure we have a private signal table and that
@@ -964,6 +962,25 @@ int flush_old_exec(struct linux_binprm * bprm)
 
        bprm->mm = NULL;                /* We're using it now */
 
+       current->flags &= ~PF_RANDOMIZE;
+       flush_thread();
+       current->personality &= ~bprm->per_clear;
+
+       return 0;
+
+out:
+       return retval;
+}
+EXPORT_SYMBOL(flush_old_exec);
+
+void setup_new_exec(struct linux_binprm * bprm)
+{
+       int i, ch;
+       char * name;
+       char tcomm[sizeof(current->comm)];
+
+       arch_pick_mmap_layout(current->mm);
+
        /* This is the point of no return */
        current->sas_ss_sp = current->sas_ss_size = 0;
 
@@ -985,9 +1002,6 @@ int flush_old_exec(struct linux_binprm * bprm)
        tcomm[i] = '\0';
        set_task_comm(current, tcomm);
 
-       current->flags &= ~PF_RANDOMIZE;
-       flush_thread();
-
        /* Set the new mm task size. We have to do that late because it may
         * depend on TIF_32BIT which is only updated in flush_thread() on
         * some architectures like powerpc
@@ -1003,8 +1017,6 @@ int flush_old_exec(struct linux_binprm * bprm)
                set_dumpable(current->mm, suid_dumpable);
        }
 
-       current->personality &= ~bprm->per_clear;
-
        /*
         * Flush performance counters when crossing a
         * security domain:
@@ -1019,14 +1031,8 @@ int flush_old_exec(struct linux_binprm * bprm)
                        
        flush_signal_handlers(current, 0);
        flush_old_files(current->files);
-
-       return 0;
-
-out:
-       return retval;
 }
-
-EXPORT_SYMBOL(flush_old_exec);
+EXPORT_SYMBOL(setup_new_exec);
 
 /*
  * Prepare credentials and lock ->cred_guard_mutex.
@@ -1763,17 +1769,20 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
        struct mm_struct *mm = current->mm;
        struct linux_binfmt * binfmt;
        struct inode * inode;
-       struct file * file;
        const struct cred *old_cred;
        struct cred *cred;
        int retval = 0;
        int flag = 0;
        int ispipe = 0;
-       unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
        char **helper_argv = NULL;
        int helper_argc = 0;
        int dump_count = 0;
        static atomic_t core_dump_count = ATOMIC_INIT(0);
+       struct coredump_params cprm = {
+               .signr = signr,
+               .regs = regs,
+               .limit = current->signal->rlim[RLIMIT_CORE].rlim_cur,
+       };
 
        audit_core_dumps(signr);
 
@@ -1829,15 +1838,15 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
        ispipe = format_corename(corename, signr);
        unlock_kernel();
 
-       if ((!ispipe) && (core_limit < binfmt->min_coredump))
+       if ((!ispipe) && (cprm.limit < binfmt->min_coredump))
                goto fail_unlock;
 
        if (ispipe) {
-               if (core_limit == 0) {
+               if (cprm.limit == 0) {
                        /*
                         * Normally core limits are irrelevant to pipes, since
                         * we're not writing to the file system, but we use
-                        * core_limit of 0 here as a speacial value. Any
+                        * cprm.limit of 0 here as a speacial value. Any
                         * non-zero limit gets set to RLIM_INFINITY below, but
                         * a limit of 0 skips the dump.  This is a consistent
                         * way to catch recursive crashes.  We can still crash
@@ -1870,25 +1879,25 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
                        goto fail_dropcount;
                }
 
-               core_limit = RLIM_INFINITY;
+               cprm.limit = RLIM_INFINITY;
 
                /* SIGPIPE can happen, but it's just never processed */
                if (call_usermodehelper_pipe(helper_argv[0], helper_argv, NULL,
-                               &file)) {
+                               &cprm.file)) {
                        printk(KERN_INFO "Core dump to %s pipe failed\n",
                               corename);
                        goto fail_dropcount;
                }
        } else
-               file = filp_open(corename,
+               cprm.file = filp_open(corename,
                                 O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
                                 0600);
-       if (IS_ERR(file))
+       if (IS_ERR(cprm.file))
                goto fail_dropcount;
-       inode = file->f_path.dentry->d_inode;
+       inode = cprm.file->f_path.dentry->d_inode;
        if (inode->i_nlink > 1)
                goto close_fail;        /* multiple links - don't dump */
-       if (!ispipe && d_unhashed(file->f_path.dentry))
+       if (!ispipe && d_unhashed(cprm.file->f_path.dentry))
                goto close_fail;
 
        /* AK: actually i see no reason to not allow this for named pipes etc.,
@@ -1901,21 +1910,22 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
         */
        if (inode->i_uid != current_fsuid())
                goto close_fail;
-       if (!file->f_op)
+       if (!cprm.file->f_op)
                goto close_fail;
-       if (!file->f_op->write)
+       if (!cprm.file->f_op->write)
                goto close_fail;
-       if (!ispipe && do_truncate(file->f_path.dentry, 0, 0, file) != 0)
+       if (!ispipe &&
+           do_truncate(cprm.file->f_path.dentry, 0, 0, cprm.file) != 0)
                goto close_fail;
 
-       retval = binfmt->core_dump(signr, regs, file, core_limit);
+       retval = binfmt->core_dump(&cprm);
 
        if (retval)
                current->signal->group_exit_code |= 0x80;
 close_fail:
        if (ispipe && core_pipe_limit)
-               wait_for_dump_helpers(file);
-       filp_close(file, NULL);
+               wait_for_dump_helpers(cprm.file);
+       filp_close(cprm.file, NULL);
 fail_dropcount:
        if (dump_count)
                atomic_dec(&core_dump_count);