]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Modify the ipc system call so that only those calls which may block
authorTom Hughes <tom@compton.nu>
Thu, 29 Jul 2004 22:40:07 +0000 (22:40 +0000)
committerTom Hughes <tom@compton.nu>
Thu, 29 Jul 2004 22:40:07 +0000 (22:40 +0000)
are treated as blocking.

This fixes bug #86000 because shmat is no longer treated as blocking
and it is therefore no longer possible for two threads to try and use
the same address for the shared memory segment.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@2536

coregrind/vg_syscalls.c
include/vg_kerneliface.h

index d6f03cffa51cd11b510b3cf46bb594b3c8d693d0..e1532260f632ce1183a660632302b2e55df5281b 100644 (file)
@@ -2553,6 +2553,7 @@ PRE(ipc)
    case 1: /* IPCOP_semop */
       SYSCALL_TRACK( pre_mem_read, tid, "semop(sops)", arg5, 
                     arg3 * sizeof(struct sembuf) );
+      tst->sys_flags |= MayBlock;
       break;
    case 2: /* IPCOP_semget */
    case 3: /* IPCOP_semctl */
@@ -2563,6 +2564,7 @@ PRE(ipc)
       if (arg6 != (UInt)NULL)
          SYSCALL_TRACK( pre_mem_read, tid, "semtimedop(timeout)", arg5, 
                         sizeof(struct timespec) );
+      tst->sys_flags |= MayBlock;
       break;
    case 11: /* IPCOP_msgsnd */
    {
@@ -2573,6 +2575,9 @@ PRE(ipc)
                     (UInt)&msgp->mtype, sizeof(msgp->mtype) );
       SYSCALL_TRACK( pre_mem_read, tid, "msgsnd(msgp->mtext)", 
                     (UInt)msgp->mtext, msgsz );
+
+      if ((arg4 & VKI_IPC_NOWAIT) == 0)
+         tst->sys_flags |= MayBlock;
       break;
    }
    case 12: /* IPCOP_msgrcv */
@@ -2588,6 +2593,9 @@ PRE(ipc)
                     (UInt)&msgp->mtype, sizeof(msgp->mtype) );
       SYSCALL_TRACK( pre_mem_write, tid, "msgrcv(msgp->mtext)", 
                     (UInt)msgp->mtext, msgsz );
+
+      if ((arg4 & VKI_IPC_NOWAIT) == 0)
+         tst->sys_flags |= MayBlock;
       break;
    }
    case 13: /* IPCOP_msgget */
@@ -5684,7 +5692,7 @@ static const struct sys_info sys_info[] = {
    SYSBA(gettimeofday,         0),
    SYSB_(getuid,               0),
    SYSB_(getuid32,             0),
-   SYSBA(ipc,                  MayBlock),
+   SYSBA(ipc,                  0),
    SYSBA(ioctl,                        MayBlock),
    SYSBA(kill,                 0),
    SYSB_(link,                 MayBlock),
index 79580fb588714a9fee85dc9fd97ac61710223127..c4b02202ee875528c31833734deb4b392de33c67 100644 (file)
@@ -769,6 +769,14 @@ struct vki_statfs64 {
 #define VKI_FUTEX_FD      2
 #define VKI_FUTEX_REQUEUE 3
 
+/*
+ * linux/ipc.h
+ */
+
+#define VKI_IPC_CREAT  00001000   /* create if key is nonexistent */
+#define VKI_IPC_EXCL   00002000   /* fail if key exists */
+#define VKI_IPC_NOWAIT 00004000   /* return error on wait */
+
 /* 
  * linux/elfcore.h
  */