• Andrew Morton's avatar
    [PATCH] tmpfs 4/7 getpage/truncate race fix · 686e9e72
    Andrew Morton authored
    From: Hugh Dickins <hugh@veritas.com>
    
    Extend use of that SHMEM_PAGEIN flag to where shmem_getpage adds a page
    to the cache.  It couldn't have caused a BUG_ON(inode->i_blocks), but if
    i_size is reduced (from another cpu) the instant after shmem_swp_alloc
    checks it, shmem_getpage could insert a page into the cache just after
    truncate_inode_pages has passed through cleaning it, leaving stale data
    (which may mysteriously reappear if the file is later extended).
    
    Easily fixed for tmpfs, using the mechanism just added for swapoff; and
    probably more important there, since its read from swap can insert non-0
    data.  But is there not a similar issue, a tiny window, in filemap.c?
    if truncate_inode_pages comes in between checking i_size and adding new
    page to cache.  Not worth getting excited, but something to beware of.
    686e9e72
shmem.c 49.3 KB