btrfs-progs: reorganize extent_buffer and fix alignment of data
authorDavid Sterba <dsterba@suse.com>
Mon, 12 Sep 2016 09:13:24 +0000 (11:13 +0200)
committerDavid Sterba <dsterba@suse.com>
Wed, 21 Sep 2016 09:50:05 +0000 (11:50 +0200)
commitda64ae3a0f7498e356a72e7f1b65a704ddfbb6bc
tree86c0454b8a160700ddd78767ebdc086284592774
parentf9309584bf9c58054d588077ba51d8123df54571
btrfs-progs: reorganize extent_buffer and fix alignment of data

Reported by UBSAN, the checksum code tries to access unaligned data that
come from the extent_buffer.

struct extent_buffer {
        struct cache_extent        cache_node;           /*     0    48 */
        u64                        start;                /*    48     8 */
        u64                        dev_bytenr;           /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        u32                        len;                  /*    64     4 */

        /* XXX 4 bytes hole, try to pack */

        struct extent_io_tree *    tree;                 /*    72     8 */
        struct list_head           lru;                  /*    80    16 */
        struct list_head           recow;                /*    96    16 */
        int                        refs;                 /*   112     4 */
        u32                        flags;                /*   116     4 */
        int                        fd;                   /*   120     4 */
        char                       data[0];              /*   124     0 */

        /* size: 128, cachelines: 2, members: 11 */
        /* sum members: 120, holes: 1, sum holes: 4 */
        /* padding: 4 */
};

Add explicit alignment to data.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=156471
Signed-off-by: David Sterba <dsterba@suse.com>
extent_io.h
tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.txt [new file with mode: 0644]
tests/fuzz-tests/images/bko-156471-ubsan-trigger-crc32c-unaligned.raw.xz [new file with mode: 0644]