libbtrfsutil: declare struct btrfs_ioctl_search_header as packed

The search header is used for extracting data from buffer returned by
the SEARCH_TREE ioctl and needs special access helpers as there are no
guarantees about alignment.

With -fsanitize=alignment this still leads to an error because address
of the members is taken, regardless of the unaligned access method is
used (both temporary memcpy to a structure or the packed struct cast).

Add another hint to compiler that the structure is special and add the
packed attribute. This fixes the sanitizer error.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-05-29 21:56:31 +02:00
parent 06c7012a54
commit d8c7a5e6f4

View file

@ -552,7 +552,7 @@ struct btrfs_ioctl_search_header {
__u64 offset;
__u32 type;
__u32 len;
} __attribute__ ((__may_alias__));
} __attribute__ ((__may_alias__, __packed__));
#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
/*