]> git.hungrycats.org Git - linux/commit
[PATCH] hugetlbfs private mappings
authorOleg Nesterov <oleg@tv-sign.ru>
Tue, 31 Aug 2004 03:34:10 +0000 (20:34 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 31 Aug 2004 03:34:10 +0000 (20:34 -0700)
commitc3dfa7121a1aa80eec3f9f662bd91ecc93310c9b
tree77038d3fd2324f323a1c43d1b07a31ea6a2b9a09
parentec081b118e6c9a77912493959aea07bdfa15f05a
[PATCH] hugetlbfs private mappings

Hugetlbfs silently coerce private mappings of hugetlb files into shared
ones.  So private writable mapping has MAP_SHARED semantics.  I think, such
mappings should be disallowed.

First, such behavior allows open hugetlbfs file O_RDONLY, and overwrite it
via mmap(PROT_READ|PROT_WRITE, MAP_PRIVATE), so it is security bug.

Second, private writable mmap() should fail just because kernel does not
support this.

I belisve, it is ok to allow private readonly hugetlb mappings,
sys_mprotect() does not work with hugetlb vmas.

There is another problem.  Hugetlb mapping is always prefaulted, pages
allocated at mmap() time.  So even readonly mapping allows to enlarge the
size of the hugetlbfs file, and steal huge pages without appropriative
permissions.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/hugetlbfs/inode.c