Merge tag 'denywrite-for-5.15' of git://github.com/davidhildenbrand/linux
[linux-2.6-microblaze.git] / mm / mmap.c
index dce4610..88dcc5c 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -148,8 +148,6 @@ void vma_set_page_prot(struct vm_area_struct *vma)
 static void __remove_shared_vm_struct(struct vm_area_struct *vma,
                struct file *file, struct address_space *mapping)
 {
-       if (vma->vm_flags & VM_DENYWRITE)
-               allow_write_access(file);
        if (vma->vm_flags & VM_SHARED)
                mapping_unmap_writable(mapping);
 
@@ -667,8 +665,6 @@ static void __vma_link_file(struct vm_area_struct *vma)
        if (file) {
                struct address_space *mapping = file->f_mapping;
 
-               if (vma->vm_flags & VM_DENYWRITE)
-                       put_write_access(file_inode(file));
                if (vma->vm_flags & VM_SHARED)
                        mapping_allow_writable(mapping);
 
@@ -1625,8 +1621,6 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len,
                        return PTR_ERR(file);
        }
 
-       flags &= ~MAP_DENYWRITE;
-
        retval = vm_mmap_pgoff(file, addr, len, prot, flags, pgoff);
 out_fput:
        if (file)
@@ -1783,22 +1777,12 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
        vma->vm_pgoff = pgoff;
 
        if (file) {
-               if (vm_flags & VM_DENYWRITE) {
-                       error = deny_write_access(file);
-                       if (error)
-                               goto free_vma;
-               }
                if (vm_flags & VM_SHARED) {
                        error = mapping_map_writable(file->f_mapping);
                        if (error)
-                               goto allow_write_and_free_vma;
+                               goto free_vma;
                }
 
-               /* ->mmap() can change vma->vm_file, but must guarantee that
-                * vma_link() below can deny write-access if VM_DENYWRITE is set
-                * and map writably if VM_SHARED is set. This usually means the
-                * new file must not have been exposed to user-space, yet.
-                */
                vma->vm_file = get_file(file);
                error = call_mmap(file, vma);
                if (error)
@@ -1855,13 +1839,9 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
 
        vma_link(mm, vma, prev, rb_link, rb_parent);
        /* Once vma denies write, undo our temporary denial count */
-       if (file) {
 unmap_writable:
-               if (vm_flags & VM_SHARED)
-                       mapping_unmap_writable(file->f_mapping);
-               if (vm_flags & VM_DENYWRITE)
-                       allow_write_access(file);
-       }
+       if (file && vm_flags & VM_SHARED)
+               mapping_unmap_writable(file->f_mapping);
        file = vma->vm_file;
 out:
        perf_event_mmap(vma);
@@ -1901,9 +1881,6 @@ unmap_and_free_vma:
        charged = 0;
        if (vm_flags & VM_SHARED)
                mapping_unmap_writable(file->f_mapping);
-allow_write_and_free_vma:
-       if (vm_flags & VM_DENYWRITE)
-               allow_write_access(file);
 free_vma:
        vm_area_free(vma);
 unacct_error: