]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
mm: Add return value for vma_set_page_prot
authorSri Krishna chowdary <schowdary@nvidia.com>
Wed, 11 May 2016 08:52:47 +0000 (14:22 +0530)
committerSri Krishna Chowdary <schowdary@nvidia.com>
Wed, 25 May 2016 18:53:17 +0000 (11:53 -0700)
Get dirty_accountable before the vm flags are
changed by vma_set_page_prot. Otherwise, the dirty_accountable
always remains 0 even if mprotect() changes permissions from VM_NONE
to vm_flags containing VM_SHARED | VM_WRITE. This leads to page
faults although pte is marked writable because dirty bit won't be set.

JIRA TMM-40

Change-Id: I68c41b3fa7beec151614a1882d7be30feab3bf21
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
Reviewed-on: http://git-master/r/1150587
GVS: Gerrit_Virtual_Submit

include/linux/mm.h
mm/mmap.c
mm/mprotect.c

index 2ee899717e98449b46368805d7e07b26f99e3805..209d37f9b98d3ed5c4e8bc8dc0dd1413c685cb0b 100644 (file)
@@ -2073,15 +2073,16 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
 
 #ifdef CONFIG_MMU
 pgprot_t vm_get_page_prot(unsigned long vm_flags);
-void vma_set_page_prot(struct vm_area_struct *vma);
+bool vma_set_page_prot(struct vm_area_struct *vma);
 #else
 static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
 {
        return __pgprot(0);
 }
-static inline void vma_set_page_prot(struct vm_area_struct *vma)
+static inline bool vma_set_page_prot(struct vm_area_struct *vma)
 {
        vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
+       return 0;
 }
 #endif
 
index 2b11430087937f2ff8bdf21b6c5622531c9d09ab..f8d171971be5cda1d32fe1dc6b514f351f149adb 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -108,7 +108,7 @@ static pgprot_t vm_pgprot_modify(pgprot_t oldprot, unsigned long vm_flags)
 }
 
 /* Update vma->vm_page_prot to reflect vma->vm_flags. */
-void vma_set_page_prot(struct vm_area_struct *vma)
+bool vma_set_page_prot(struct vm_area_struct *vma)
 {
        unsigned long vm_flags = vma->vm_flags;
 
@@ -117,7 +117,9 @@ void vma_set_page_prot(struct vm_area_struct *vma)
                vm_flags &= ~VM_SHARED;
                vma->vm_page_prot = vm_pgprot_modify(vma->vm_page_prot,
                                                     vm_flags);
+               return 1;
        }
+       return 0;
 }
 
 
@@ -1697,7 +1699,7 @@ out:
         */
        vma->vm_flags |= VM_SOFTDIRTY;
 
-       vma_set_page_prot(vma);
+       (void)vma_set_page_prot(vma);
 
        return addr;
 
index bddb2c75492d06b4806c6ed91c0352c05a9555f3..dc894560bcbe9fbf93602f07e6056a5d1214e609 100644 (file)
@@ -319,8 +319,7 @@ success:
         * held in write mode.
         */
        vma->vm_flags = newflags;
-       dirty_accountable = vma_wants_writenotify(vma);
-       vma_set_page_prot(vma);
+       dirty_accountable = vma_set_page_prot(vma);
 
        change_protection(vma, start, end, vma->vm_page_prot,
                          dirty_accountable, 0);