This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / binfmt_elf.c
index 55235a6..c356b1a 100644 (file)
@@ -352,8 +352,7 @@ static unsigned long load_elf_interp(struct elfhdr * interp_elf_ex,
         */
        if (interp_elf_ex->e_phentsize != sizeof(struct elf_phdr))
                goto out;
-       if (interp_elf_ex->e_phnum < 1 ||
-               interp_elf_ex->e_phnum > 65536U / sizeof(struct elf_phdr))
+       if (interp_elf_ex->e_phnum > 65536U / sizeof(struct elf_phdr))
                goto out;
 
        /* Now read in all of the header information */
@@ -562,13 +561,12 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
 
        /* Now read in all of the header information */
 
+       retval = -ENOMEM;
        if (loc->elf_ex.e_phentsize != sizeof(struct elf_phdr))
                goto out;
-       if (loc->elf_ex.e_phnum < 1 ||
-               loc->elf_ex.e_phnum > 65536U / sizeof(struct elf_phdr))
+       if (loc->elf_ex.e_phnum > 65536U / sizeof(struct elf_phdr))
                goto out;
        size = loc->elf_ex.e_phnum * sizeof(struct elf_phdr);
-       retval = -ENOMEM;
        elf_phdata = (struct elf_phdr *) kmalloc(size, GFP_KERNEL);
        if (!elf_phdata)
                goto out;
@@ -614,12 +612,10 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                         * is an a.out format binary
                         */
 
-                       retval = -ENOEXEC;
+                       retval = -ENOMEM;
                        if (elf_ppnt->p_filesz > PATH_MAX || 
-                           elf_ppnt->p_filesz < 2)
+                           elf_ppnt->p_filesz == 0)
                                goto out_free_file;
-
-                       retval = -ENOMEM;
                        elf_interpreter = (char *) kmalloc(elf_ppnt->p_filesz,
                                                           GFP_KERNEL);
                        if (!elf_interpreter)
@@ -634,7 +630,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                                goto out_free_interp;
                        }
                        /* make sure path is NULL terminated */
-                       retval = -ENOEXEC;
+                       retval = -EINVAL;
                        if (elf_interpreter[elf_ppnt->p_filesz - 1] != '\0')
                                goto out_free_interp;
 
@@ -776,7 +772,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
         * Turn off the CS limit completely if exec-shield disabled or
         * NX active:
         */
-       if (!exec_shield || executable_stack != EXSTACK_DISABLE_X || nx_enabled)
+       if (!exec_shield || executable_stack != EXSTACK_DISABLE_X)
                arch_add_exec_range(current->mm, -1);
 #endif
 
@@ -798,8 +794,7 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
        /* Do this immediately, since STACK_TOP as used in setup_arg_pages
           may depend on the personality.  */
        SET_PERSONALITY(loc->elf_ex, ibcs2_interpreter);
-       if (exec_shield != 2 &&
-                       elf_read_implies_exec(loc->elf_ex, have_pt_gnu_stack))
+       if (elf_read_implies_exec(loc->elf_ex, have_pt_gnu_stack))
                current->personality |= READ_IMPLIES_EXEC;
 
        arch_pick_mmap_layout(current->mm);
@@ -942,9 +937,8 @@ static int load_elf_binary(struct linux_binprm * bprm, struct pt_regs * regs)
                                                    &interp_load_addr,
                                                    load_bias);
                if (BAD_ADDR(elf_entry)) {
-                       printk(KERN_ERR "Unable to load interpreter %.128s\n",
-                               elf_interpreter);
-                       force_sig(SIGSEGV, current);
+                       printk(KERN_ERR "Unable to load interpreter\n");
+                       send_sig(SIGSEGV, current, 0);
                        retval = -ENOEXEC; /* Nobody gets to see this, but.. */
                        goto out_free_dentry;
                }
@@ -1163,14 +1157,22 @@ static int dump_seek(struct file *file, off_t off)
  */
 static int maydump(struct vm_area_struct *vma)
 {
-       /* Do not dump I/O mapped devices, shared memory, or special mappings */
-       if (vma->vm_flags & (VM_IO | VM_SHARED | VM_RESERVED))
+       /*
+        * If we may not read the contents, don't allow us to dump
+        * them either. "dump_write()" can't handle it anyway.
+        */
+       if (!(vma->vm_flags & VM_READ))
                return 0;
 
-       /* If it hasn't been written to, don't write it out */
-       if (!vma->anon_vma)
+       /* Do not dump I/O mapped devices! -DaveM */
+       if (vma->vm_flags & VM_IO)
                return 0;
-
+#if 1
+       if (vma->vm_flags & (VM_WRITE|VM_GROWSUP|VM_GROWSDOWN))
+               return 1;
+       if (vma->vm_flags & (VM_READ|VM_EXEC|VM_EXECUTABLE|VM_SHARED))
+               return 0;
+#endif
        return 1;
 }
 
@@ -1415,7 +1417,7 @@ static int elf_core_dump(long signr, struct pt_regs * regs, struct file * file)
        struct vm_area_struct *vma;
        struct elfhdr *elf = NULL;
        off_t offset = 0, dataoff;
-       unsigned long limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
+       unsigned long limit = current->rlim[RLIMIT_CORE].rlim_cur;
        int numnote;
        struct memelfnote *notes = NULL;
        struct elf_prstatus *prstatus = NULL;   /* NT_PRSTATUS */