[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 03/12] linux-user: Properly Handle semun Structure I
From: |
Tom Musta |
Subject: |
[Qemu-devel] [PATCH 03/12] linux-user: Properly Handle semun Structure In Cross-Endian Situations |
Date: |
Mon, 4 Aug 2014 11:45:30 -0500 |
The semun union used in the semctl system call contains both an int (val) and
pointers. In cross-endian situations on 64 bit targets, the target memory
must be byte swapped, otherwise the wrong 32 bits are used for the val
field.
Signed-off-by: Tom Musta <address@hidden>
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 229c482..fb03e96 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2647,9 +2647,14 @@ static inline abi_long do_semctl(int semid, int semnum,
int cmd,
switch( cmd ) {
case GETVAL:
case SETVAL:
+#if TARGET_ABI_BITS == 64
+ /* In 64 bit cross endian situations, we will erroneously pick up
+ * the wrong half of the union for the "val" element. To rectify
+ * this, the entire structure is byteswaped. */
+ target_su.buf = tswapal(target_su.buf);
+#endif
arg.val = tswap32(target_su.val);
ret = get_errno(semctl(semid, semnum, cmd, arg));
- target_su.val = tswap32(arg.val);
break;
case GETALL:
case SETALL:
--
1.7.1
- [Qemu-devel] [PATCH 00/12] target-ppc: Linux-User Mode Bug Fixes for Power, Tom Musta, 2014/08/04
- [Qemu-devel] [PATCH 01/12] linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2, Tom Musta, 2014/08/04
- [Qemu-devel] [PATCH 02/12] linux-user: Dereference Pointer Argument to ipc/semctl Sys Call, Tom Musta, 2014/08/04
- [Qemu-devel] [PATCH 03/12] linux-user: Properly Handle semun Structure In Cross-Endian Situations,
Tom Musta <=
- [Qemu-devel] [PATCH 04/12] linux-user: Make ipc syscall's third argument an abi_long, Tom Musta, 2014/08/04
- [Qemu-devel] [PATCH 05/12] linux-user: Conditionally Pass Attribute Pointer to mq_open(), Tom Musta, 2014/08/04
- [Qemu-devel] [PATCH 06/12] linux-user: Detect Negative Message Sizes in msgsnd System Call, Tom Musta, 2014/08/04
- [Qemu-devel] [PATCH 07/12] linux-user: Handle NULL argument to sched_{get, set}param, Tom Musta, 2014/08/04
- [Qemu-devel] [PATCH 08/12] linux-user: Detect fault in sched_rr_get_interval, Tom Musta, 2014/08/04