]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Better argument size tracking in fs/exec.c
authorAndrew Morton <akpm@osdl.org>
Thu, 14 Aug 2003 17:24:28 +0000 (10:24 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Thu, 14 Aug 2003 17:24:28 +0000 (10:24 -0700)
From: Matthew Wilcox <willy@debian.org>

Introduce a new variable "arg_size" and set it appropriately in each arm of
the CONFIG_STACK_GROWSUP.  This patch fixes a bug for PA-RISC and makes the
code cleaner for everyone.

fs/exec.c

index c738d07f7a7d351a81a6d5e45632ef5be11c387c..ce0332bd2105611e8f1a1c37a68e741fcd1964ea 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -341,6 +341,7 @@ int setup_arg_pages(struct linux_binprm *bprm)
        struct vm_area_struct *mpnt;
        struct mm_struct *mm = current->mm;
        int i;
+       long arg_size;
 
 #ifdef CONFIG_STACK_GROWSUP
        /* Move the argument and environment strings to the bottom of the
@@ -375,6 +376,7 @@ int setup_arg_pages(struct linux_binprm *bprm)
        bprm->p = PAGE_SIZE * i - offset;
        stack_base = STACK_TOP - current->rlim[RLIMIT_STACK].rlim_max;
        mm->arg_start = stack_base;
+       arg_size = i << PAGE_SHIFT;
 
        /* zero pages that were copied above */
        while (i < MAX_ARG_PAGES)
@@ -382,6 +384,7 @@ int setup_arg_pages(struct linux_binprm *bprm)
 #else
        stack_base = STACK_TOP - MAX_ARG_PAGES * PAGE_SIZE;
        mm->arg_start = bprm->p + stack_base;
+       arg_size = STACK_TOP - (PAGE_MASK & (unsigned long) mm->arg_start);
 #endif
 
        bprm->p += stack_base;
@@ -393,7 +396,7 @@ int setup_arg_pages(struct linux_binprm *bprm)
        if (!mpnt)
                return -ENOMEM;
 
-       if (security_vm_enough_memory((STACK_TOP - (PAGE_MASK & (unsigned long) bprm->p))>>PAGE_SHIFT)) {
+       if (security_vm_enough_memory(arg_size >> PAGE_SHIFT)) {
                kmem_cache_free(vm_area_cachep, mpnt);
                return -ENOMEM;
        }