• David Hildenbrand's avatar
    mm/madvise: report SIGBUS as -EFAULT for MADV_POPULATE_(READ|WRITE) · eb2faa51
    David Hildenbrand authored
    Doing some extended tests and polishing the man page update for
    MADV_POPULATE_(READ|WRITE), I realized that we end up converting also
    SIGBUS (via -EFAULT) to -EINVAL, making it look like yet another
    madvise() user error.
    
    We want to report only problematic mappings and permission problems that
    the user could have know as -EINVAL.
    
    Let's not convert -EFAULT arising due to SIGBUS (or SIGSEGV) to -EINVAL,
    but instead indicate -EFAULT to user space.  While we could also convert
    it to -ENOMEM, using -EFAULT looks more helpful when user space might
    want to troubleshoot what's going wrong: MADV_POPULATE_(READ|WRITE) is
    not part of an final Linux release and we can still adjust the behavior.
    
    Link: https://lkml.kernel.org/r/20210726154932.102880-1-david@redhat.com
    Fixes: 4ca9b385
    
     ("mm/madvise: introduce MADV_POPULATE_(READ|WRITE) to prefault page tables")
    Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc...
    eb2faa51
madvise.c 32.4 KB