VServer 1.9.2 (patch-2.6.8.1-vs1.9.2.diff)
[linux-2.6.git] / fs / binfmt_elf.c
index 38130a2..785da46 100644 (file)
 #include <linux/pagemap.h>
 #include <linux/security.h>
 #include <linux/syscalls.h>
+#include <linux/vs_memory.h>
 
 #include <asm/uaccess.h>
 #include <asm/param.h>
-#include <asm/pgalloc.h>
 
 #include <linux/elf.h>
 
@@ -202,7 +202,10 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr * exec,
        NEW_AUX_ENT(AT_EGID, (elf_addr_t) tsk->egid);
        NEW_AUX_ENT(AT_SECURE, (elf_addr_t) security_bprm_secureexec(bprm));
        if (k_platform) {
-               NEW_AUX_ENT(AT_PLATFORM, (elf_addr_t)(long)u_platform);
+               NEW_AUX_ENT(AT_PLATFORM, (elf_addr_t)(unsigned long)u_platform);
+       }
+       if (bprm->interp_flags & BINPRM_FLAGS_EXECFD) {
+               NEW_AUX_ENT(AT_EXECFD, (elf_addr_t) bprm->interp_data);
        }
 #undef NEW_AUX_ENT
        /* AT_NULL is zero; clear the rest too */
@@ -235,8 +238,8 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr * exec,
        if (interp_aout) {
                argv = sp + 2;
                envp = argv + argc + 1;
-               __put_user((elf_addr_t)(long)argv, sp++);
-               __put_user((elf_addr_t)(long)envp, sp++);
+               __put_user((elf_addr_t)(unsigned long)argv, sp++);
+               __put_user((elf_addr_t)(unsigned long)envp, sp++);
        } else {
                argv = sp;
                envp = argv + argc + 1;
@@ -490,7 +493,8 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        struct exec interp_ex;
        char passed_fileno[6];
        struct files_struct *files;
-       int executable_stack = EXSTACK_DEFAULT;
+       int have_pt_gnu_stack, executable_stack = EXSTACK_DEFAULT;
+       unsigned long def_flags = 0;
        
        /* Get the exec-header */
        elf_ex = *((struct elfhdr *) bprm->buf);
@@ -622,7 +626,9 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                                executable_stack = EXSTACK_ENABLE_X;
                        else
                                executable_stack = EXSTACK_DISABLE_X;
+                       break;
                }
+       have_pt_gnu_stack = (i < elf_ex.e_phnum);
 
        /* Some simple consistency checks for the interpreter */
        if (elf_interpreter) {
@@ -690,10 +696,13 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        current->mm->end_code = 0;
        current->mm->mmap = NULL;
        current->flags &= ~PF_FORKNOEXEC;
+       current->mm->def_flags = def_flags;
 
        /* Do this immediately, since STACK_TOP as used in setup_arg_pages
           may depend on the personality.  */
        SET_PERSONALITY(elf_ex, ibcs2_interpreter);
+       if (elf_read_implies_exec(elf_ex, have_pt_gnu_stack))
+               current->personality |= READ_IMPLIES_EXEC;
 
        /* Do this so that we can load the interpreter, if need be.  We will
           change some of these later */