• Masahiro Yamada's avatar
    modpost: remove broken calculation of exception_table_entry size · d0acc76a
    Masahiro Yamada authored
    find_extable_entry_size() is completely broken. It has awesome comments
    about how to calculate sizeof(struct exception_table_entry).
    
    It was based on these assumptions:
    
      - struct exception_table_entry has two fields
      - both of the fields have the same size
    
    Then, we came up with this equation:
    
      (offset of the second field) * 2 == (size of struct)
    
    It was true for all architectures when commit 52dc0595 ("modpost:
    handle relocations mismatch in __ex_table.") was applied.
    
    Our mathematics broke when commit 548acf19 ("x86/mm: Expand the
    exception table logic to allow new handling options") introduced the
    third field.
    
    Now, the definition of exception_table_entry is highly arch-dependent.
    
    For x86, sizeof(struct exception_table_entry) is apparently 12, but
    find_extable_entry_size() sets extable_entry_size to 8.
    
    I could fix it, but I do not see much value in this code.
    
    extable_entry_size is used just for selecting a slightly different
    error message.
    
    If the first field ("insn") references to a non-executable section,
    
        The relocation at %s+0x%lx references
        section "%s" which is not executable, IOW
        it is not possible for the kernel to fault
        at that address.  Something is seriously wrong
        and should be fixed.
    
    If the second field ("fixup") references to a non-executable section,
    
        The relocation at %s+0x%lx references
        section "%s" which is not executable, IOW
        the kernel will fault if it ever tries to
        jump to it.  Something is seriously wrong
        and should be fixed.
    
    Merge the two error messages rather than adding even more complexity.
    
    Change fatal() to error() to make it continue running and catch more
    possible errors.
    
    Fixes: 548acf19 ("x86/mm: Expand the exception table logic to allow new handling options")
    Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
    d0acc76a
modpost.c 59.6 KB