path: root/kernel/fork.c
diff options
authorDavid Herrmann <>2014-08-08 21:25:25 (GMT)
committerMaciej Wereski <>2014-12-29 08:31:35 (GMT)
commitf5eb589a8cff825e57d6cb42d84c9ae61f2e1baf (patch)
treebbf7ed91762f0dcfabe0e278901d4270f6d93367 /kernel/fork.c
parent5988dd09c4983bed7c2671446de5715a63036bb3 (diff)
mm: allow drivers to prevent new writable mappingsrefs/changes/04/32904/1
This patch (of 6): The i_mmap_writable field counts existing writable mappings of an address_space. To allow drivers to prevent new writable mappings, make this counter signed and prevent new writable mappings if it is negative. This is modelled after i_writecount and DENYWRITE. This will be required by the shmem-sealing infrastructure to prevent any new writable mappings after the WRITE seal has been set. In case there exists a writable mapping, this operation will fail with EBUSY. Note that we rely on the fact that iff you already own a writable mapping, you can increase the counter without using the helpers. This is the same that we do for i_writecount. Signed-off-by: David Herrmann <> Acked-by: Hugh Dickins <> Cc: Michael Kerrisk <> Cc: Ryan Lortie <> Cc: Lennart Poettering <> Cc: Daniel Mack <> Cc: Andy Lutomirski <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <> Change-Id: If33fdcedbcf202ab177c4e21afc7eec261088a8b Origin: Backported-by: Maciej Wereski <> Signed-off-by: Maciej Wereski <>
Diffstat (limited to 'kernel/fork.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 514dbc4..219a0fc 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -422,7 +422,7 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
if (tmp->vm_flags & VM_SHARED)
- mapping->i_mmap_writable++;
+ atomic_inc(&mapping->i_mmap_writable);
/* insert tmp into the share list, just after mpnt */
if (unlikely(tmp->vm_flags & VM_NONLINEAR))