This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / arch / x86_64 / ia32 / ia32_binfmt.c
index b802b5f..a385759 100644 (file)
@@ -330,10 +330,10 @@ static void elf32_init(struct pt_regs *regs)
 
 int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
 {
-       unsigned long stack_base;
+       unsigned long stack_base, grow;
        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;
@@ -347,7 +347,10 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
        if (!mpnt) 
                return -ENOMEM; 
        
-       if (security_vm_enough_memory((IA32_STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))>>PAGE_SHIFT)) {
+       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;
        }
@@ -367,8 +370,14 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
                        mpnt->vm_flags = vm_stack_flags32;
                mpnt->vm_page_prot = (mpnt->vm_flags & VM_EXEC) ? 
                        PAGE_COPY_EXEC : PAGE_COPY;
-               insert_vm_struct(mm, mpnt);
-               mm->stack_vm = mm->total_vm = vma_pages(mpnt);
+               if ((ret = insert_vm_struct(mm, mpnt))) {
+                       up_write(&mm->mmap_sem);
+                       kmem_cache_free(vm_area_cachep, mpnt);
+                       return ret;
+               }
+               // mm->stack_vm = mm->total_vm = vma_pages(mpnt);
+               vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt));
+               mm->stack_vm = mm->total_vm;
        } 
 
        for (i = 0 ; i < MAX_ARG_PAGES ; i++) {
@@ -385,7 +394,7 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
 }
 
 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 map_addr;
        struct task_struct *me = current;