• Mike Kravetz's avatar
    hugetlb: don't pass page cache pages to restore_reserve_on_error · c7b1850d
    Mike Kravetz authored
    syzbot hit kernel BUG at fs/hugetlbfs/inode.c:532 as described in [1].
    This BUG triggers if the HPageRestoreReserve flag is set on a page in
    the page cache.  It should never be set, as the routine
    huge_add_to_page_cache explicitly clears the flag after adding a page to
    the cache.
    
    The only code other than huge page allocation which sets the flag is
    restore_reserve_on_error.  It will potentially set the flag in rare out
    of memory conditions.  syzbot was injecting errors to cause memory
    allocation errors which exercised this specific path.
    
    The code in restore_reserve_on_error is doing the right thing.  However,
    there are instances where pages in the page cache were being passed to
    restore_reserve_on_error.  This is incorrect, as once a page goes into
    the cache reservation information will not be modified for the page
    until it is removed from the cache.  Error paths do not remove pages
    from the cache, so even in the case of error, the page wil...
    c7b1850d
hugetlb.c 174 KB