diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2014-08-08 14:25:25 -0700 |
---|---|---|
committer | Maciej Wereski <m.wereski@partner.samsung.com> | 2014-12-29 09:31:35 +0100 |
commit | f5eb589a8cff825e57d6cb42d84c9ae61f2e1baf (patch) | |
tree | bbf7ed91762f0dcfabe0e278901d4270f6d93367 /fs | |
parent | 5988dd09c4983bed7c2671446de5715a63036bb3 (diff) | |
download | linux-3.10-f5eb589a8cff825e57d6cb42d84c9ae61f2e1baf.tar.gz linux-3.10-f5eb589a8cff825e57d6cb42d84c9ae61f2e1baf.tar.bz2 linux-3.10-f5eb589a8cff825e57d6cb42d84c9ae61f2e1baf.zip |
mm: allow drivers to prevent new writable mappings
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 <dh.herrmann@gmail.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Ryan Lortie <desrt@desrt.ca>
Cc: Lennart Poettering <lennart@poettering.net>
Cc: Daniel Mack <zonque@gmail.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Change-Id: If33fdcedbcf202ab177c4e21afc7eec261088a8b
Origin: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4bb5f5d9395bc112d93a134d8f5b05611eddc9c0
Backported-by: Maciej Wereski <m.wereski@partner.samsung.com>
Signed-off-by: Maciej Wereski <m.wereski@partner.samsung.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/inode.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/inode.c b/fs/inode.c index 1b300a06b8b..7216a0f6f0a 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -164,6 +164,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode) mapping->a_ops = &empty_aops; mapping->host = inode; mapping->flags = 0; + atomic_set(&mapping->i_mmap_writable, 0); mapping_set_gfp_mask(mapping, GFP_HIGHUSER_MOVABLE); mapping->private_data = NULL; mapping->backing_dev_info = &default_backing_dev_info; |