• Oleg Nesterov's avatar
    [PATCH] hugetlbfs private mappings · c3dfa712
    Oleg Nesterov authored
    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: default avatarOleg Nesterov <oleg@tv-sign.ru>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    c3dfa712
inode.c 18.9 KB