Merge git://git.kernel.org/pub/scm/linux/kernel/git/sfrench/cifs-2.6
[sfrench/cifs-2.6.git] / fs / binfmt_flat.c
index 69f44dcdb0b4c92f504e118a4eae080528cf68b0..a62fd4018a201199fcb113d37920f3a643c3d321 100644 (file)
@@ -16,7 +16,6 @@
  */
 
 #include <linux/module.h>
-#include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
@@ -428,7 +427,6 @@ static int load_flat_file(struct linux_binprm * bprm,
        loff_t fpos;
        unsigned long start_code, end_code;
        int ret;
-       int exec_fileno;
 
        hdr = ((struct flat_hdr *) bprm->buf);          /* exec-header */
        inode = bprm->file->f_dentry->d_inode;
@@ -502,25 +500,16 @@ static int load_flat_file(struct linux_binprm * bprm,
                goto err;
        }
 
-       /* check file descriptor */
-       exec_fileno = get_unused_fd();
-       if (exec_fileno < 0) {
-               ret = -EMFILE;
-               goto err;
-       }
-       get_file(bprm->file);
-       fd_install(exec_fileno, bprm->file);
-
        /* Flush all traces of the currently running executable */
        if (id == 0) {
                result = flush_old_exec(bprm);
                if (result) {
                        ret = result;
-                       goto err_close;
+                       goto err;
                }
 
                /* OK, This is the point of no return */
-               set_personality(PER_LINUX);
+               set_personality(PER_LINUX_32BIT);
        }
 
        /*
@@ -548,7 +537,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                                textpos = (unsigned long) -ENOMEM;
                        printk("Unable to mmap process text, errno %d\n", (int)-textpos);
                        ret = textpos;
-                       goto err_close;
+                       goto err;
                }
 
                down_write(&current->mm->mmap_sem);
@@ -564,7 +553,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                                        (int)-datapos);
                        do_munmap(current->mm, textpos, text_len);
                        ret = realdatastart;
-                       goto err_close;
+                       goto err;
                }
                datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long);
 
@@ -587,7 +576,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                        do_munmap(current->mm, textpos, text_len);
                        do_munmap(current->mm, realdatastart, data_len + extra);
                        ret = result;
-                       goto err_close;
+                       goto err;
                }
 
                reloc = (unsigned long *) (datapos+(ntohl(hdr->reloc_start)-text_len));
@@ -606,7 +595,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                        printk("Unable to allocate RAM for process text/data, errno %d\n",
                                        (int)-textpos);
                        ret = textpos;
-                       goto err_close;
+                       goto err;
                }
 
                realdatastart = textpos + ntohl(hdr->data_start);
@@ -652,7 +641,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                        do_munmap(current->mm, textpos, text_len + data_len + extra +
                                MAX_SHARED_LIBS * sizeof(unsigned long));
                        ret = result;
-                       goto err_close;
+                       goto err;
                }
        }
 
@@ -717,7 +706,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                                addr = calc_reloc(*rp, libinfo, id, 0);
                                if (addr == RELOC_FAILED) {
                                        ret = -ENOEXEC;
-                                       goto err_close;
+                                       goto err;
                                }
                                *rp = addr;
                        }
@@ -747,7 +736,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                        rp = (unsigned long *) calc_reloc(addr, libinfo, id, 1);
                        if (rp == (unsigned long *)RELOC_FAILED) {
                                ret = -ENOEXEC;
-                               goto err_close;
+                               goto err;
                        }
 
                        /* Get the pointer's value.  */
@@ -762,7 +751,7 @@ static int load_flat_file(struct linux_binprm * bprm,
                                addr = calc_reloc(addr, libinfo, id, 0);
                                if (addr == RELOC_FAILED) {
                                        ret = -ENOEXEC;
-                                       goto err_close;
+                                       goto err;
                                }
 
                                /* Write back the relocated pointer.  */
@@ -783,8 +772,6 @@ static int load_flat_file(struct linux_binprm * bprm,
                        stack_len);
 
        return 0;
-err_close:
-       sys_close(exec_fileno);
 err:
        return ret;
 }