summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/char/mem.c1
-rw-r--r--fs/exec.c1
-rw-r--r--include/linux/mm.h8
-rw-r--r--mm/mmap.c3
-rw-r--r--mm/nommu.c2
5 files changed, 15 insertions, 0 deletions
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index ffeb60d3434c..df66a9dd0aae 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -708,6 +708,7 @@ static int mmap_zero(struct file *file, struct vm_area_struct *vma)
708#endif 708#endif
709 if (vma->vm_flags & VM_SHARED) 709 if (vma->vm_flags & VM_SHARED)
710 return shmem_zero_setup(vma); 710 return shmem_zero_setup(vma);
711 vma_set_anonymous(vma);
711 return 0; 712 return 0;
712} 713}
713 714
diff --git a/fs/exec.c b/fs/exec.c
index 72e961a62adb..bdd0eacefdf5 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -293,6 +293,7 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
293 bprm->vma = vma = vm_area_alloc(mm); 293 bprm->vma = vma = vm_area_alloc(mm);
294 if (!vma) 294 if (!vma)
295 return -ENOMEM; 295 return -ENOMEM;
296 vma_set_anonymous(vma);
296 297
297 if (down_write_killable(&mm->mmap_sem)) { 298 if (down_write_killable(&mm->mmap_sem)) {
298 err = -EINTR; 299 err = -EINTR;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 31540f166987..7ba6d356d18f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -454,10 +454,18 @@ struct vm_operations_struct {
454 454
455static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm) 455static inline void vma_init(struct vm_area_struct *vma, struct mm_struct *mm)
456{ 456{
457 static const struct vm_operations_struct dummy_vm_ops = {};
458
457 vma->vm_mm = mm; 459 vma->vm_mm = mm;
460 vma->vm_ops = &dummy_vm_ops;
458 INIT_LIST_HEAD(&vma->anon_vma_chain); 461 INIT_LIST_HEAD(&vma->anon_vma_chain);
459} 462}
460 463
464static inline void vma_set_anonymous(struct vm_area_struct *vma)
465{
466 vma->vm_ops = NULL;
467}
468
461struct mmu_gather; 469struct mmu_gather;
462struct inode; 470struct inode;
463 471
diff --git a/mm/mmap.c b/mm/mmap.c
index ff1944d8d458..17bbf4d3e24f 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1778,6 +1778,8 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
1778 error = shmem_zero_setup(vma); 1778 error = shmem_zero_setup(vma);
1779 if (error) 1779 if (error)
1780 goto free_vma; 1780 goto free_vma;
1781 } else {
1782 vma_set_anonymous(vma);
1781 } 1783 }
1782 1784
1783 vma_link(mm, vma, prev, rb_link, rb_parent); 1785 vma_link(mm, vma, prev, rb_link, rb_parent);
@@ -2983,6 +2985,7 @@ static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long fla
2983 return -ENOMEM; 2985 return -ENOMEM;
2984 } 2986 }
2985 2987
2988 vma_set_anonymous(vma);
2986 vma->vm_start = addr; 2989 vma->vm_start = addr;
2987 vma->vm_end = addr + len; 2990 vma->vm_end = addr + len;
2988 vma->vm_pgoff = pgoff; 2991 vma->vm_pgoff = pgoff;
diff --git a/mm/nommu.c b/mm/nommu.c
index 1d22fdbf7d7c..9fc9e43335b6 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1145,6 +1145,8 @@ static int do_mmap_private(struct vm_area_struct *vma,
1145 if (ret < len) 1145 if (ret < len)
1146 memset(base + ret, 0, len - ret); 1146 memset(base + ret, 0, len - ret);
1147 1147
1148 } else {
1149 vma_set_anonymous(vma);
1148 } 1150 }
1149 1151
1150 return 0; 1152 return 0;