Skip to contentSkip to conversation

linux-user: shmctl() should ignore IPC_64

PATCH In review Laurent Vivier 2 participants 3 messages Jun 1, 2009 – Jun 10, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux-user: shmctl() should ignore IPC_64

This has been detected trying to use "dbench" with m68k-linux-user/qemu-m68k where "shmctl()" is called with "IPC_RMID | IPC_64".

IPC_64 is useless with IPC_RMID, SHM_LOCK, SHM_UNLOCK (as the only parameter is the id without shmid_ds) and already ignored with semctl() and msgctl().

---
 linux-user/syscall.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
linux-user/syscall.c +2 -2
index b1bba48..c3d1d73 100644
@@ -2539,11 +2539,11 @@ static abi_long do_ipc(unsigned int call, int first,
 
 	/* IPC_* and SHM_* command values are the same on all linux platforms */
     case IPCOP_shmctl:
-        switch(second) {
+        switch(second & 0xff) {
         case IPC_RMID:
         case SHM_LOCK:
         case SHM_UNLOCK:
-            ret = get_errno(shmctl(first, second, NULL));
+            ret = get_errno(shmctl(first, second & 0xff, NULL));
             break;
         default:
             goto unimplemented;
Signature · 1 line
1.5.6.5
#1 lore raw
Quoted 17 lines · Laurent Vivier

This has been detected trying to use "dbench" with m68k-linux-user/qemu-m68k where "shmctl()" is called with "IPC_RMID | IPC_64".

IPC_64 is useless with IPC_RMID, SHM_LOCK, SHM_UNLOCK (as the only parameter is the id without shmid_ds) and already ignored with semctl() and msgctl().

---
 linux-user/syscall.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
linux-user/syscall.c +0 -0
index b1bba48..c3d1d73 100644

linux-user/syscall.c static abi_long do_ipc(unsigned int call, int first, · line 2542

Quoted 5 lines
linux-user/syscall.c +1 -1
@@ -2539,11 +2539,11 @@ static abi_long do_ipc(unsigned int call, int first,
 
 	/* IPC_* and SHM_* command values are the same on all linux platforms */
     case IPCOP_shmctl:
-        switch(second) {
+        switch(second & 0xff) {

This appears to be also taken care in this old patch where shmctl was moved to do_shmctl()

https://git.maemo.org/projects/qemu/gitweb?p=qemu;a=commitdiff;h=d1f365ccd0615c57d2869d33fb5e0637b3623b64

Quoted 12 lines
linux-user/syscall.c +1 -1
         case IPC_RMID:
         case SHM_LOCK:
         case SHM_UNLOCK:
-            ret = get_errno(shmctl(first, second, NULL));
+            ret = get_errno(shmctl(first, second & 0xff, NULL));
             break;
         default:
             goto unimplemented;
Signature · 1 line
1.5.6.5
#2 lore raw
Quoted 27 lines · Riku Voipio
Quoted 17 lines · Laurent Vivier

This has been detected trying to use "dbench" with m68k-linux-user/qemu-m68k where "shmctl()" is called with "IPC_RMID | IPC_64".

IPC_64 is useless with IPC_RMID, SHM_LOCK, SHM_UNLOCK (as the only parameter is the id without shmid_ds) and already ignored with semctl() and msgctl().

---
 linux-user/syscall.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
linux-user/syscall.c +0 -0
index b1bba48..c3d1d73 100644

linux-user/syscall.c static abi_long do_ipc(unsigned int call, int first, · line 2542

Quoted 5 lines
linux-user/syscall.c +1 -1
@@ -2539,11 +2539,11 @@ static abi_long do_ipc(unsigned int call, int first,
 
 	/* IPC_* and SHM_* command values are the same on all linux platforms */
     case IPCOP_shmctl:
-        switch(second) {
+        switch(second & 0xff) {

This appears to be also taken care in this old patch where shmctl was moved to do_shmctl()

Quoted 1 line

https://git.maemo.org/projects/qemu/gitweb?p=qemu;a=commitdiff;h=d1f365ccd0615c57d2869d33fb5e0637b3623b64

Why it is not in qemu original git tree ?

Quoted 10 lines

linux-user/syscall.c static abi_long do_ipc(unsigned int call, int first, · line 2549

Quoted 10 lines
linux-user/syscall.c +1 -1
         case IPC_RMID:
         case SHM_LOCK:
         case SHM_UNLOCK:
-            ret = get_errno(shmctl(first, second, NULL));
+            ret = get_errno(shmctl(first, second & 0xff, NULL));
             break;
         default:
             goto unimplemented;

If no patch to solve this is applied soon, I will resend mine... :-P

Regards,
Laurent

Signature · 3 lines
--------------------- [email protected] ----------------------
"Tout ce qui est impossible reste à accomplir"    Jules Verne
"Things are only impossible until they're not" Jean-Luc Picard