fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / ia64 / ia32 / binfmt_elf32.c
index 093129c..7bc158b 100644 (file)
@@ -9,7 +9,6 @@
  * 04/13/01    D. Mosberger    dropped saving tssd in ar.k1---it's not needed
  * 09/14/01    D. Mosberger    fixed memory management for gdt/tss page
  */
-#include <linux/config.h>
 
 #include <linux/types.h>
 #include <linux/mm.h>
@@ -35,7 +34,10 @@ extern void ia64_elf32_init (struct pt_regs *regs);
 
 static void elf32_set_personality (void);
 
-#define setup_arg_pages(bprm,exec)             ia32_setup_arg_pages(bprm,exec)
+static unsigned long __attribute ((unused))
+randomize_stack_top(unsigned long stack_top);
+
+#define setup_arg_pages(bprm,tos,exec)         ia32_setup_arg_pages(bprm,exec)
 #define elf_map                                elf32_map
 
 #undef SET_PERSONALITY
@@ -89,7 +91,7 @@ ia64_elf32_init (struct pt_regs *regs)
         * it with privilege level 3 because the IVE uses non-privileged accesses to these
         * tables.  IA-32 segmentation is used to protect against IA-32 accesses to them.
         */
-       vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
                memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
@@ -100,7 +102,11 @@ ia64_elf32_init (struct pt_regs *regs)
                vma->vm_ops = &ia32_shared_page_vm_ops;
                down_write(&current->mm->mmap_sem);
                {
-                       insert_vm_struct(current->mm, vma);
+                       if (insert_vm_struct(current->mm, vma)) {
+                               kmem_cache_free(vm_area_cachep, vma);
+                               up_write(&current->mm->mmap_sem);
+                               BUG();
+                       }
                }
                up_write(&current->mm->mmap_sem);
        }
@@ -111,7 +117,7 @@ ia64_elf32_init (struct pt_regs *regs)
         * code is locked in specific gate page, which is pointed by pretcode
         * when setup_frame_ia32
         */
-       vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
                memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
@@ -123,7 +129,11 @@ ia64_elf32_init (struct pt_regs *regs)
                vma->vm_ops = &ia32_gate_page_vm_ops;
                down_write(&current->mm->mmap_sem);
                {
-                       insert_vm_struct(current->mm, vma);
+                       if (insert_vm_struct(current->mm, vma)) {
+                               kmem_cache_free(vm_area_cachep, vma);
+                               up_write(&current->mm->mmap_sem);
+                               BUG();
+                       }
                }
                up_write(&current->mm->mmap_sem);
        }
@@ -132,7 +142,7 @@ ia64_elf32_init (struct pt_regs *regs)
         * Install LDT as anonymous memory.  This gives us all-zero segment descriptors
         * until a task modifies them via modify_ldt().
         */
-       vma = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       vma = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (vma) {
                memset(vma, 0, sizeof(*vma));
                vma->vm_mm = current->mm;
@@ -142,7 +152,11 @@ ia64_elf32_init (struct pt_regs *regs)
                vma->vm_flags = VM_READ|VM_WRITE|VM_MAYREAD|VM_MAYWRITE;
                down_write(&current->mm->mmap_sem);
                {
-                       insert_vm_struct(current->mm, vma);
+                       if (insert_vm_struct(current->mm, vma)) {
+                               kmem_cache_free(vm_area_cachep, vma);
+                               up_write(&current->mm->mmap_sem);
+                               BUG();
+                       }
                }
                up_write(&current->mm->mmap_sem);
        }
@@ -187,10 +201,10 @@ ia64_elf32_init (struct pt_regs *regs)
 int
 ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
 {
-       unsigned long stack_base, grow;
+       unsigned long stack_base;
        struct vm_area_struct *mpnt;
        struct mm_struct *mm = current->mm;
-       int i;
+       int i, ret;
 
        stack_base = IA32_STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE;
        mm->arg_start = bprm->p + stack_base;
@@ -200,18 +214,10 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
                bprm->loader += stack_base;
        bprm->exec += stack_base;
 
-       mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
+       mpnt = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
        if (!mpnt)
                return -ENOMEM;
 
-       grow = (IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))
-               >> PAGE_SHIFT;
-       if (security_vm_enough_memory(grow) ||
-               !vx_vmpages_avail(mm, grow)) {
-               kmem_cache_free(vm_area_cachep, mpnt);
-               return -ENOMEM;
-       }
-
        memset(mpnt, 0, sizeof(*mpnt));
 
        down_write(&current->mm->mmap_sem);
@@ -227,8 +233,11 @@ ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack)
                        mpnt->vm_flags = VM_STACK_FLAGS;
                mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC)?
                                        PAGE_COPY_EXEC: PAGE_COPY;
-               insert_vm_struct(current->mm, mpnt);
-               // current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt);
+               if ((ret = insert_vm_struct(current->mm, mpnt))) {
+                       up_write(&current->mm->mmap_sem);
+                       kmem_cache_free(vm_area_cachep, mpnt);
+                       return ret;
+               }
                vx_vmpages_sub(current->mm, current->mm->total_vm - vma_pages(mpnt));
                current->mm->stack_vm = current->mm->total_vm;
        }
@@ -255,12 +264,10 @@ elf32_set_personality (void)
 {
        set_personality(PER_LINUX32);
        current->thread.map_base  = IA32_PAGE_OFFSET/3;
-       current->thread.task_size = IA32_PAGE_OFFSET;   /* use what Linux/x86 uses... */
-       set_fs(USER_DS);                                /* set addr limit for new TASK_SIZE */
 }
 
 static unsigned long
-elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type)
+elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type, unsigned long unused)
 {
        unsigned long pgoff = (eppnt->p_vaddr) & ~IA32_PAGE_MASK;