• Hugh Dickins's avatar
    [PATCH] fix shared and private accounting · e054680b
    Hugh Dickins authored
    do_mmap_pgoff's (file == NULL) check was incorrect: it caused shared
    MAP_ANONYMOUS objects to be counted twice (again in shmem_file_setup),
    and again on fork(); whereas the equivalent shared /dev/zero objects
    were correctly counted.  Conversely, a private readonly file mapping
    was (correctly) not counted, but still not counted when mprotected to
    writable: mprotect_fixup had pointless "charged = 0" changes, now it
    does vm_enough_memory checking when private is first made writable
    (but later we may want to refine behaviour on a noreserve mapping).
    
    Also changed correct (flags & MAP_SHARED) test in do_mmap_pgoff to
    equivalent (vm_flags & VM_SHARED) test: because do_mmap_pgoff is
    dealing with vm_flags rather than the input flags by that stage.
    e054680b
mmap.c 31.8 KB