@samitouri / QOSamiQemu / commits / 9e3df3019d

linux-user: Fix msqid_ds struct wrt 32-bit big endian architectures

Make sure that the time entries (msg_stime, msg_rtime and msg_ctime) are defined as 64-bit time_t values, since the userspace may access the whole 64-bit value. By this change we fix the word ordering for 32-bit big endian architectures as well. This fixes the msgctl01 LTP testcase on hppa32. Cc: qemu-stable@nongnu.org Signed-off-by: Helge Deller <deller@gmx.de>

Helge Deller committed Jul 28, 2026 at 21:20 UTC 9e3df3019d21c54df435406fca31b3e145b29702
1 file changed +12 -18
linux-user/syscall.c
+12 -18
@@ -4216,21 +4216,15 @@ static inline abi_long do_semtimedop(int semid,
4216 }
4217 #endif
4218
4219 +#define target_time64_t abi_ullong
4220 +#define target_swap_time64(x) tswap64(x)
4221 +
4222 struct target_msqid_ds
4223 {
4224 struct target_ipc_perm msg_perm;
4222 - abi_ulong msg_stime;
4223 -#if TARGET_ABI_BITS == 32
4224 - abi_ulong __unused1;
4225 -#endif
4226 - abi_ulong msg_rtime;
4227 -#if TARGET_ABI_BITS == 32
4228 - abi_ulong __unused2;
4229 -#endif
4230 - abi_ulong msg_ctime;
4231 -#if TARGET_ABI_BITS == 32
4232 - abi_ulong __unused3;
4233 -#endif
4225 + target_time64_t msg_stime;
4226 + target_time64_t msg_rtime;
4227 + target_time64_t msg_ctime;
4228 abi_ulong __msg_cbytes;
4229 abi_ulong msg_qnum;
4230 abi_ulong msg_qbytes;
@@ -4249,9 +4243,9 @@ static inline abi_long target_to_host_msqid_ds(struct msqid_ds *host_md,
4243 return -TARGET_EFAULT;
4244 if (target_to_host_ipc_perm(&(host_md->msg_perm),target_addr))
4245 return -TARGET_EFAULT;
4252 - host_md->msg_stime = tswapal(target_md->msg_stime);
4253 - host_md->msg_rtime = tswapal(target_md->msg_rtime);
4254 - host_md->msg_ctime = tswapal(target_md->msg_ctime);
4246 + host_md->msg_stime = target_swap_time64(target_md->msg_stime);
4247 + host_md->msg_rtime = target_swap_time64(target_md->msg_rtime);
4248 + host_md->msg_ctime = target_swap_time64(target_md->msg_ctime);
4249 host_md->__msg_cbytes = tswapal(target_md->__msg_cbytes);
4250 host_md->msg_qnum = tswapal(target_md->msg_qnum);
4251 host_md->msg_qbytes = tswapal(target_md->msg_qbytes);
@@ -4270,9 +4264,9 @@ static inline abi_long host_to_target_msqid_ds(abi_ulong target_addr,
4264 return -TARGET_EFAULT;
4265 if (host_to_target_ipc_perm(target_addr,&(host_md->msg_perm)))
4266 return -TARGET_EFAULT;
4273 - target_md->msg_stime = tswapal(host_md->msg_stime);
4274 - target_md->msg_rtime = tswapal(host_md->msg_rtime);
4275 - target_md->msg_ctime = tswapal(host_md->msg_ctime);
4267 + target_md->msg_stime = target_swap_time64(host_md->msg_stime);
4268 + target_md->msg_rtime = target_swap_time64(host_md->msg_rtime);
4269 + target_md->msg_ctime = target_swap_time64(host_md->msg_ctime);
4270 target_md->__msg_cbytes = tswapal(host_md->__msg_cbytes);
4271 target_md->msg_qnum = tswapal(host_md->msg_qnum);
4272 target_md->msg_qbytes = tswapal(host_md->msg_qbytes);