Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zfs_log: add flex array fields to log record structs #16539

Merged
merged 1 commit into from
Sep 27, 2024

Commits on Sep 26, 2024

  1. zfs_log: add flex array fields to log record structs

    ZIL log record structs (lr_XX_t) are frequently allocated with extra
    space after the struct to carry variable-sized "payload" items.
    
    Linux 6.10+ compiled with CONFIG_FORTIFY_SOURCE has been doing runtime
    bounds checking on memcpy() calls. Because these types had no indicator
    that they might use more space than their simple definition,
    __fortify_memcpy_chk will frequently complain about overruns eg:
    
        memcpy: detected field-spanning write (size 7) of single field
            "lr + 1" at zfs_log.c:425 (size 0)
        memcpy: detected field-spanning write (size 9) of single field
            "(char *)(lr + 1)" at zfs_log.c:593 (size 0)
        memcpy: detected field-spanning write (size 4) of single field
            "(char *)(lr + 1) + snamesize" at zfs_log.c:594 (size 0)
        memcpy: detected field-spanning write (size 7) of single field
            "lr + 1" at zfs_log.c:425 (size 0)
        memcpy: detected field-spanning write (size 9) of single field
            "(char *)(lr + 1)" at zfs_log.c:593 (size 0)
        memcpy: detected field-spanning write (size 4) of single field
            "(char *)(lr + 1) + snamesize" at zfs_log.c:594 (size 0)
        memcpy: detected field-spanning write (size 7) of single field
            "lr + 1" at zfs_log.c:425 (size 0)
        memcpy: detected field-spanning write (size 9) of single field
            "(char *)(lr + 1)" at zfs_log.c:593 (size 0)
        memcpy: detected field-spanning write (size 4) of single field
            "(char *)(lr + 1) + snamesize" at zfs_log.c:594 (size 0)
    
    To fix this, this commit adds flex array fields to all lr_XX_t structs
    that require them, and then uses those fields to access that
    end-of-struct area rather than more complicated casts and pointer
    addition.
    
    Signed-off-by: Rob Norris <[email protected]>
    Sponsored-by: https://despairlabs.com/sponsor/
    robn committed Sep 26, 2024
    Configuration menu
    Copy the full SHA
    cad9f2d View commit details
    Browse the repository at this point in the history