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

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

Advertisement

Kernel v2.6.24 /mm/mmap.c

Filename:/mm/mmap.c
Lines Added:19
Lines Deleted:13
Also changed in: (Previous) 2.6.24-rc8  2.6.24-rc7  2.6.24-rc6  2.6.24-rc5  2.6.24-rc4-git7  2.6.24-rc4-git6 
(Following) 2.6.24-git1  2.6.24-git2  2.6.24-git3  2.6.24-git4  2.6.24-git5  2.6.24-git6 

Location
[  2.6.24
  [  mm
     o  mmap.c

Patch

diff --git a/mm/mmap.c b/mm/mmap.c
index 0d40e66..15678aa 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -7,6 +7,7 @@
  */
 
 #include <linux/slab.h>
+#include <linux/backing-dev.h>
 #include <linux/mm.h>
 #include <linux/shm.h>
 #include <linux/mman.h>
@@ -180,8 +181,6 @@ error:
    return -ENOMEM;
 }
 
-EXPORT_SYMBOL(__vm_enough_memory);
-
 /*
  * Requires inode->i_mapping->i_mmap_lock
  */
@@ -913,6 +912,9 @@ unsigned long do_mmap_pgoff(struct file * file, unsigned long addr,
    if (!len)
       return -EINVAL;
 
+   if (!(flags & MAP_FIXED))
+      addr = round_hint_to_min(addr);
+
    error = arch_mmap_check(addr, len, flags);
    if (error)
       return error;
@@ -1049,8 +1051,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
 
    /* The open routine did something to the protections already? */
    if (pgprot_val(vma->vm_page_prot) !=
-       pgprot_val(protection_map[vm_flags &
-          (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]))
+       pgprot_val(vm_get_page_prot(vm_flags)))
       return 0;
 
    /* Specialty mapping? */
@@ -1131,8 +1132,7 @@ munmap_back:
    vma->vm_start = addr;
    vma->vm_end = addr + len;
    vma->vm_flags = vm_flags;
-   vma->vm_page_prot = protection_map[vm_flags &
-            (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)];
+   vma->vm_page_prot = vm_get_page_prot(vm_flags);
    vma->vm_pgoff = pgoff;
 
    if (file) {
@@ -1174,8 +1174,7 @@ munmap_back:
    vm_flags = vma->vm_flags;
 
    if (vma_wants_writenotify(vma))
-      vma->vm_page_prot =
-         protection_map[vm_flags & (VM_READ|VM_WRITE|VM_EXEC)];
+      vma->vm_page_prot = vm_get_page_prot(vm_flags & ~VM_SHARED);
 
    if (!file || !vma_merge(mm, prev, addr, vma->vm_end,
          vma->vm_flags, NULL, file, pgoff, vma_policy(vma))) {
@@ -1619,6 +1618,12 @@ static inline int expand_downwards(struct vm_area_struct *vma,
     */
    if (unlikely(anon_vma_prepare(vma)))
       return -ENOMEM;
+
+   address &= PAGE_MASK;
+   error = security_file_mmap(0, 0, 0, 0, address, 1);
+   if (error)
+      return error;
+
    anon_vma_lock(vma);
 
    /*
@@ -1626,8 +1631,6 @@ static inline int expand_downwards(struct vm_area_struct *vma,
     * is required to hold the mmap_sem in read mode.  We need the
     * anon_vma lock to serialize against concurrent expand_stacks.
     */
-   address &= PAGE_MASK;
-   error = 0;
 
    /* Somebody else might have raced and expanded it already */
    if (address < vma->vm_start) {
@@ -1938,6 +1941,10 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
    if (is_hugepage_only_range(mm, addr, len))
       return -EINVAL;
 
+   error = security_file_mmap(0, 0, 0, 0, addr, 1);
+   if (error)
+      return error;
+
    flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
 
    error = arch_mmap_check(addr, len, flags);
@@ -2003,8 +2010,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
    vma->vm_end = addr + len;
    vma->vm_pgoff = pgoff;
    vma->vm_flags = flags;
-   vma->vm_page_prot = protection_map[flags &
-            (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)];
+   vma->vm_page_prot = vm_get_page_prot(flags);
    vma_link(mm, vma, prev, rb_link, rb_parent);
 out:
    mm->total_vm += len >> PAGE_SHIFT;
@@ -2210,7 +2216,7 @@ int install_special_mapping(struct mm_struct *mm,
    vma->vm_end = addr + len;
 
    vma->vm_flags = vm_flags | mm->def_flags;
-   vma->vm_page_prot = protection_map[vma->vm_flags & 7];
+   vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
 
    vma->vm_ops = &special_mapping_vmops;
    vma->vm_private_data = pages;


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