This commit was manufactured by cvs2svn to create tag
[linux-2.6.git] / fs / exec.c
index be4366c..6715972 100644 (file)
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -46,6 +46,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/rmap.h>
+#include <linux/ckrm.h>
 
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
@@ -319,7 +320,8 @@ void install_arg_page(struct vm_area_struct *vma,
                pte_unmap(pte);
                goto out;
        }
-       mm->rss++;
+       // mm->rss++;
+       vx_rsspages_inc(mm);
        lru_cache_add_active(page);
        set_pte(pte, pte_mkdirty(pte_mkwrite(mk_pte(
                                        page, vma->vm_page_prot))));
@@ -388,8 +390,13 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
        /* zero pages that were copied above */
        while (i < MAX_ARG_PAGES)
                bprm->page[i++] = NULL;
+#else
+#ifdef __HAVE_ARCH_ALIGN_STACK
+       stack_base = arch_align_stack(STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE);
+       stack_base = PAGE_ALIGN(stack_base);
 #else
        stack_base = STACK_TOP - MAX_ARG_PAGES * PAGE_SIZE;
+#endif
        mm->arg_start = bprm->p + stack_base;
        arg_size = STACK_TOP - (PAGE_MASK & (unsigned long) mm->arg_start);
 #endif
@@ -403,7 +410,8 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
        if (!mpnt)
                return -ENOMEM;
 
-       if (security_vm_enough_memory(arg_size >> PAGE_SHIFT)) {
+       if (security_vm_enough_memory(arg_size >> PAGE_SHIFT) ||
+               !vx_vmpages_avail(mm, arg_size >> PAGE_SHIFT)) {
                kmem_cache_free(vm_area_cachep, mpnt);
                return -ENOMEM;
        }
@@ -433,7 +441,9 @@ int setup_arg_pages(struct linux_binprm *bprm, int executable_stack)
                mpnt->vm_flags |= mm->def_flags;
                mpnt->vm_page_prot = protection_map[mpnt->vm_flags & 0x7];
                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++) {
@@ -836,6 +846,7 @@ int flush_old_exec(struct linux_binprm * bprm)
        }
        current->comm[i] = '\0';
 
+       current->flags &= ~PF_RELOCEXEC;
        flush_thread();
 
        if (bprm->e_uid != current->euid || bprm->e_gid != current->egid || 
@@ -888,8 +899,11 @@ int prepare_binprm(struct linux_binprm *bprm)
        if(!(bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID)) {
                /* Set-uid? */
                if (mode & S_ISUID) {
-                       current->personality &= ~PER_CLEAR_ON_SETID;
                        bprm->e_uid = inode->i_uid;
+#ifdef __i386__
+                       /* reset personality */
+                       current->personality = PER_LINUX;
+#endif
                }
 
                /* Set-gid? */
@@ -899,8 +913,11 @@ int prepare_binprm(struct linux_binprm *bprm)
                 * executable.
                 */
                if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
-                       current->personality &= ~PER_CLEAR_ON_SETID;
                        bprm->e_gid = inode->i_gid;
+#ifdef __i386__
+                       /* reset personality */
+                       current->personality = PER_LINUX;
+#endif
                }
        }
 
@@ -1035,6 +1052,7 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
                                        fput(bprm->file);
                                bprm->file = NULL;
                                current->did_exec = 1;
+                               ckrm_cb_exec(bprm->filename);
                                return retval;
                        }
                        read_lock(&binfmt_lock);