xemu/include
Peter Maydell f8b94b4c52 net: mark struct ip_header as QEMU_PACKED
The ip_header is not actually guaranteed to be aligned. We attempt to
deal with this in some places such as net_checksum_calculate() by
using stw_be_p and so on to access the fields, but this is not
sufficient to be correct, because even accessing a byte member
within an unaligned struct is undefined behaviour. The clang
sanitizer will emit warnings like these if net_checksum_calculate()
is called:

     Stopping network: ../../net/checksum.c:106:9: runtime error: member access within misaligned address 0x556aad9b502e for type 'struct ip_header', which requires 4 byte alignment
    0x556aad9b502e: note: pointer points here
     34 56 08 00 45 00  01 48 a5 09 40 00 40 11  7c 8b 0a 00 02 0f 0a 00  02 02 00 44 00 43 01 34  19 56
                 ^
    SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../net/checksum.c:106:9 in
    ../../net/checksum.c:106:9: runtime error: load of misaligned address 0x556aad9b502e for type 'uint8_t' (aka 'unsigned char'), which requires 4 byte alignment
    0x556aad9b502e: note: pointer points here
     34 56 08 00 45 00  01 48 a5 09 40 00 40 11  7c 8b 0a 00 02 0f 0a 00  02 02 00 44 00 43 01 34  19 56
                 ^

Fix this by marking the ip_header struct as QEMU_PACKED, so that
the compiler knows that it might be unaligned and will generate
the right code for accessing fields.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20241114141619.806652-3-peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
2024-11-18 13:45:45 +01:00
..
authz Prefer 'on' | 'off' over 'yes' | 'no' for bool options 2021-01-29 17:07:53 +00:00
block hw/nvme: add NPDAL/NPDGL 2024-11-04 19:09:45 +01:00
chardev chardev/mux: convert size members to unsigned int 2024-10-15 12:26:01 +04:00
crypto crypto: Introduce SM3 hash hmac pbkdf algorithm 2024-11-05 18:37:18 +00:00
disas disas: Fix build against Capstone v6 (again) 2024-11-05 10:09:59 +00:00
exec softmmu: Expand comments describing max_bounce_buffer_size 2024-11-04 09:22:58 -05:00
fpu softfloat: Remove fallback rule from pickNaN() 2024-11-05 10:09:58 +00:00
gdbstub gdbstub/helpers: Introduce ldtul_$endian_p() helpers 2024-10-15 11:55:09 -03:00
hw hw/net/virtio-net.c: Don't assume IP length field is aligned 2024-11-18 13:45:45 +01:00
io qio: add support for SO_PEERCRED for socket channel 2024-07-22 13:47:41 +02:00
libdecnumber Replace config-time define HOST_WORDS_BIGENDIAN 2022-04-06 10:50:37 +02:00
migration migration: Drop migration_is_idle() 2024-10-31 15:48:18 -04:00
monitor monitor: Remove obsolete stubs 2024-06-30 19:51:44 +03:00
net net: mark struct ip_header as QEMU_PACKED 2024-11-18 13:45:45 +01:00
qapi qerror: QERR_PROPERTY_VALUE_OUT_OF_RANGE is no longer used, drop 2024-10-18 15:03:35 +02:00
qemu eif: cope with huge section offsets 2024-11-07 16:54:02 +01:00
qom qom: remove unused function 2024-10-31 18:28:32 +01:00
scsi hw/ufs: Support for UFS logical unit 2023-09-07 14:01:29 -04:00
semihosting semihosting: Include missing 'gdbstub/syscalls.h' header 2024-07-22 09:38:01 +01:00
standard-headers linux-headers: Update to Linux v6.12-rc5 2024-11-02 15:20:41 +08:00
sysemu Migration pull request for softfreeze 2024-11-04 12:31:45 +00:00
tcg tcg/riscv: Add basic support for vector 2024-10-22 11:57:25 -07:00
ui ui/input-legacy.c: remove unused legacy qemu_add_kbd_event_handler() function 2024-11-08 11:06:42 +01:00
user linux-user: Remove support for CRIS target 2024-09-13 20:10:50 +02:00
elf.h util: spelling fixes 2023-08-31 19:47:43 +02:00
glib-compat.h Bump minimum glib version to v2.66 2024-05-14 12:46:24 +02:00
qemu-io.h Include qemu-common.h exactly where needed 2019-06-12 13:20:20 +02:00
qemu-main.h ui/cocoa: Run qemu_init in the main thread 2022-09-23 14:36:33 +02:00