patch-2.6.6-vs1.9.0
[linux-2.6.git] / arch / x86_64 / ia32 / ia32_binfmt.c
index 92817f1..1b70ef9 100644 (file)
@@ -327,7 +327,7 @@ 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;
@@ -344,7 +344,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;
        }
@@ -368,7 +371,9 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
                INIT_LIST_HEAD(&mpnt->shared);
                mpnt->vm_private_data = (void *) 0;
                insert_vm_struct(mm, mpnt);
-               mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               // mm->total_vm = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
+               vx_vmpages_sub(mm, mm->total_vm -
+                       ((mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT));
        } 
 
        for (i = 0 ; i < MAX_ARG_PAGES ; i++) {