fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / fs / binfmt_som.c
index 4969da6..b19f293 100644 (file)
 #include <linux/init.h>
 #include <linux/vs_memory.h>
 
+#include <asm/a.out.h>
 #include <asm/uaccess.h>
 #include <asm/pgtable.h>
 
-#include <linux/config.h>
 
 #include <linux/elf.h>
 
@@ -196,6 +196,7 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        unsigned long som_entry;
        struct som_hdr *som_ex;
        struct som_exec_auxhdr *hpuxhdr;
+       struct files_struct *files;
 
        /* Get the exec-header */
        som_ex = (struct som_hdr *) bprm->buf;
@@ -210,15 +211,27 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        size = som_ex->aux_header_size;
        if (size > SOM_PAGESIZE)
                goto out;
-       hpuxhdr = (struct som_exec_auxhdr *) kmalloc(size, GFP_KERNEL);
+       hpuxhdr = kmalloc(size, GFP_KERNEL);
        if (!hpuxhdr)
                goto out;
 
        retval = kernel_read(bprm->file, som_ex->aux_header_location,
                        (char *) hpuxhdr, size);
+       if (retval != size) {
+               if (retval >= 0)
+                       retval = -EIO;
+               goto out_free;
+       }
+
+       files = current->files; /* Refcounted so ok */
+       retval = unshare_files();
        if (retval < 0)
                goto out_free;
-#error "Fix security hole before enabling me"
+       if (files == current->files) {
+               put_files_struct(files);
+               files = NULL;
+       }
+
        retval = get_unused_fd();
        if (retval < 0)
                goto out_free;
@@ -255,13 +268,11 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
 
        set_binfmt(&som_format);
        compute_creds(bprm);
-       setup_arg_pages(bprm, EXSTACK_DEFAULT);
+       setup_arg_pages(bprm, STACK_TOP, EXSTACK_DEFAULT);
 
        create_som_tables(bprm);
 
        current->mm->start_stack = bprm->p;
-       // current->mm->rss = 0;
-       vx_rsspages_sub(current->mm, current->mm->rss);
 
 #if 0
        printk("(start_brk) %08lx\n" , (unsigned long) current->mm->start_brk);
@@ -275,8 +286,6 @@ load_som_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        map_hpux_gateway_page(current,current->mm);
 
        start_thread_som(regs, som_entry, bprm->p);
-       if (current->ptrace & PT_PTRACED)
-               send_sig(SIGTRAP, current, 0);
        return 0;
 
        /* error cleanup */