Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.25-git19 /mm/nommu.c

Filename:/mm/nommu.c
Lines Added:22
Lines Deleted:7
Also changed in: (Previous) 2.6.25-git18  2.6.25-git17  2.6.25-git16  2.6.25-git15  2.6.25-git14  2.6.25-git13 
(Following) 2.6.25-git20  2.6.26-rc1  2.6.26-rc2  2.6.26-rc3  2.6.26-rc3-git7  2.6.26-rc3-git8 

Location
[  2.6.25-git19
  [  mm
     o  nommu.c

Patch

diff --git a/mm/nommu.c b/mm/nommu.c
index 5d8ae08..ef8c62c 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -105,7 +105,11 @@ unsigned int kobjsize(const void *objp)
 {
    struct page *page;
 
-   if (!objp || !((page = virt_to_page(objp))))
+   /*
+    * If the object we have should not have ksize performed on it,
+    * return size of 0
+    */
+   if (!objp || (unsigned long)objp >= memory_end || !((page = virt_to_page(objp))))
       return 0;
 
    if (PageSlab(page))
@@ -962,8 +966,13 @@ unsigned long do_mmap_pgoff(struct file *file,
 
    INIT_LIST_HEAD(&vma->anon_vma_node);
    atomic_set(&vma->vm_usage, 1);
-   if (file)
+   if (file) {
       get_file(file);
+      if (vm_flags & VM_EXECUTABLE) {
+         added_exe_file_vma(current->mm);
+         vma->vm_mm = current->mm;
+      }
+   }
    vma->vm_file   = file;
    vma->vm_flags   = vm_flags;
    vma->vm_start   = addr;
@@ -1018,8 +1027,11 @@ unsigned long do_mmap_pgoff(struct file *file,
    up_write(&nommu_vma_sem);
    kfree(vml);
    if (vma) {
-      if (vma->vm_file)
+      if (vma->vm_file) {
          fput(vma->vm_file);
+         if (vma->vm_flags & VM_EXECUTABLE)
+            removed_exe_file_vma(vma->vm_mm);
+      }
       kfree(vma);
    }
    return ret;
@@ -1049,7 +1061,7 @@ EXPORT_SYMBOL(do_mmap_pgoff);
 /*
  * handle mapping disposal for uClinux
  */
-static void put_vma(struct vm_area_struct *vma)
+static void put_vma(struct mm_struct *mm, struct vm_area_struct *vma)
 {
    if (vma) {
       down_write(&nommu_vma_sem);
@@ -1071,8 +1083,11 @@ static void put_vma(struct vm_area_struct *vma)
          realalloc -= kobjsize(vma);
          askedalloc -= sizeof(*vma);
 
-         if (vma->vm_file)
+         if (vma->vm_file) {
             fput(vma->vm_file);
+            if (vma->vm_flags & VM_EXECUTABLE)
+               removed_exe_file_vma(mm);
+         }
          kfree(vma);
       }
 
@@ -1109,7 +1124,7 @@ int do_munmap(struct mm_struct *mm, unsigned long addr, size_t len)
  found:
    vml = *parent;
 
-   put_vma(vml->vma);
+   put_vma(mm, vml->vma);
 
    *parent = vml->next;
    realalloc -= kobjsize(vml);
@@ -1154,7 +1169,7 @@ void exit_mmap(struct mm_struct * mm)
 
       while ((tmp = mm->context.vmlist)) {
          mm->context.vmlist = tmp->next;
-         put_vma(tmp->vma);
+         put_vma(mm, tmp->vma);
 
          realalloc -= kobjsize(tmp);
          askedalloc -= sizeof(*tmp);


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.