]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
linux-user: Use abi_int for imr_ifindex in ip_mreqn struct
authorHelge Deller <deller@gmx.de>
Fri, 24 Apr 2026 15:21:01 +0000 (17:21 +0200)
committerHelge Deller <deller@gmx.de>
Fri, 24 Apr 2026 22:38:33 +0000 (00:38 +0200)
Peter Hartley noticed, that in the qemu code the imr_ifindex member of
struct target_ip_mreq needs to be of type "int" instead of "long", which
is what the Linux kernel uses on all architectures.

Adjust the type accordingly, and add a QEMU_BUILD_BUG_ON() checker to
prevent such issues in the future.

This change should fix multicast issues when using hosts and guests with
different endianess or bit size.

Reported-by: Peter Hartley <peter@talesfromthearmchair.net>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2553
Signed-off-by: Helge Deller <deller@gmx.de>
linux-user/syscall.c
linux-user/syscall_defs.h

index 910a4da0a64f041c4164594f4b8d8568dac4e48a..4594909242e3c014ac3833136a7b73d3fbfdf406 100644 (file)
@@ -2161,6 +2161,8 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
 
             QEMU_BUILD_BUG_ON(sizeof(struct ip_mreq) !=
                               sizeof(struct target_ip_mreq));
+            QEMU_BUILD_BUG_ON(sizeof(struct ip_mreqn) !=
+                              sizeof(struct target_ip_mreqn));
 
             if (optname == IP_MULTICAST_IF) {
                 min_size = sizeof(struct in_addr);
index 6967306be48224ecd59e5fbef575eec8557cf753..5799769f832fd953fe731a33ad7746113dff9957 100644 (file)
@@ -210,7 +210,7 @@ struct target_ip_mreq {
 struct target_ip_mreqn {
     struct target_in_addr imr_multiaddr;
     struct target_in_addr imr_address;
-    abi_long imr_ifindex;
+    abi_int imr_ifindex;
 };
 
 struct target_ip_mreq_source {