• Yang Shi's avatar
    mm: filemap: check if THP has hwpoisoned subpage for PMD page fault · eac96c3e
    Yang Shi authored
    When handling shmem page fault the THP with corrupted subpage could be
    PMD mapped if certain conditions are satisfied.  But kernel is supposed
    to send SIGBUS when trying to map hwpoisoned page.
    
    There are two paths which may do PMD map: fault around and regular
    fault.
    
    Before commit f9ce0be7 ("mm: Cleanup faultaround and finish_fault()
    codepaths") the thing was even worse in fault around path.  The THP
    could be PMD mapped as long as the VMA fits regardless what subpage is
    accessed and corrupted.  After this commit as long as head page is not
    corrupted the THP could be PMD mapped.
    
    In the regular fault path the THP could be PMD mapped as long as the
    corrupted page is not accessed and the VMA fits.
    
    This loophole could be fixed by iterating every subpage to check if any
    of them is hwpoisoned or not, but it is somewhat costly in page fault
    path.
    
    So introduce a new page flag called HasHWPoisoned on the first tail
    page.  It indicates the ...
    eac96c3e
memory-failure.c 59 KB