Commit cf508b58 authored by Miaohe Lin's avatar Miaohe Lin Committed by Linus Torvalds

mm: use helper function mapping_allow_writable()

Commit 4bb5f5d9 ("mm: allow drivers to prevent new writable mappings")
changed i_mmap_writable from unsigned int to atomic_t and add the helper
function mapping_allow_writable() to atomic_inc i_mmap_writable.  But it
forgot to use this helper function in dup_mmap() and __vma_link_file().
Signed-off-by: default avatarMiaohe Lin <linmiaohe@huawei.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Christian Kellner <christian@kellner.me>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Adrian Reber <areber@redhat.com>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Aleksa Sarai <cyphar@cyphar.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20200917112736.7789-1-linmiaohe@huawei.comSigned-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 0fc48a6e
...@@ -559,7 +559,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, ...@@ -559,7 +559,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
atomic_dec(&inode->i_writecount); atomic_dec(&inode->i_writecount);
i_mmap_lock_write(mapping); i_mmap_lock_write(mapping);
if (tmp->vm_flags & VM_SHARED) if (tmp->vm_flags & VM_SHARED)
atomic_inc(&mapping->i_mmap_writable); mapping_allow_writable(mapping);
flush_dcache_mmap_lock(mapping); flush_dcache_mmap_lock(mapping);
/* insert tmp into the share list, just after mpnt */ /* insert tmp into the share list, just after mpnt */
vma_interval_tree_insert_after(tmp, mpnt, vma_interval_tree_insert_after(tmp, mpnt,
......
...@@ -621,7 +621,7 @@ static void __vma_link_file(struct vm_area_struct *vma) ...@@ -621,7 +621,7 @@ static void __vma_link_file(struct vm_area_struct *vma)
if (vma->vm_flags & VM_DENYWRITE) if (vma->vm_flags & VM_DENYWRITE)
atomic_dec(&file_inode(file)->i_writecount); atomic_dec(&file_inode(file)->i_writecount);
if (vma->vm_flags & VM_SHARED) if (vma->vm_flags & VM_SHARED)
atomic_inc(&mapping->i_mmap_writable); mapping_allow_writable(mapping);
flush_dcache_mmap_lock(mapping); flush_dcache_mmap_lock(mapping);
vma_interval_tree_insert(vma, &mapping->i_mmap); vma_interval_tree_insert(vma, &mapping->i_mmap);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment