* [PATCH] mm: Use helper function mapping_allow_writable()
@ 2020-09-17 11:27 Miaohe Lin
0 siblings, 0 replies; only message in thread
From: Miaohe Lin @ 2020-09-17 11:27 UTC (permalink / raw)
To: akpm, christian.brauner, mingo, peterz, ebiederm, christian,
surenb, areber, shakeelb, cyphar, tglx
Cc: linux-mm, linux-kernel, linmiaohe
Commit 4bb5f5d9395b ("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: Miaohe Lin <linmiaohe@huawei.com>
---
kernel/fork.c | 2 +-
mm/mmap.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/fork.c b/kernel/fork.c
index 11ed5ac35caf..b9164b75b20c 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -558,7 +558,7 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
atomic_dec(&inode->i_writecount);
i_mmap_lock_write(mapping);
if (tmp->vm_flags & VM_SHARED)
- atomic_inc(&mapping->i_mmap_writable);
+ mapping_allow_writable(mapping);
flush_dcache_mmap_lock(mapping);
/* insert tmp into the share list, just after mpnt */
vma_interval_tree_insert_after(tmp, mpnt,
diff --git a/mm/mmap.c b/mm/mmap.c
index e3a1c1b48909..ae9ef433f830 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -665,7 +665,7 @@ static void __vma_link_file(struct vm_area_struct *vma)
if (vma->vm_flags & VM_DENYWRITE)
atomic_dec(&file_inode(file)->i_writecount);
if (vma->vm_flags & VM_SHARED)
- atomic_inc(&mapping->i_mmap_writable);
+ mapping_allow_writable(mapping);
flush_dcache_mmap_lock(mapping);
vma_interval_tree_insert(vma, &mapping->i_mmap);
--
2.19.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-17 11:29 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17 11:27 [PATCH] mm: Use helper function mapping_allow_writable() Miaohe Lin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).