This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

PATCH: BP checks for SysV IPC syscalls


i686:	No build regressions.
	Only one binary difference for non-BP in
	sysdeps/unix/sysv/linux/shmat.c which is insignificant (see patch).
	No runtime test regressions, because there are no sysvipc tests.  8^(
	(but who gives a damn about sysvipc anyway 8^)

OK?

2000-07-26  Greg McGary  <greg@mcgary.org>

	* sysdeps/gnu/bits/msq.h: Qualify kernel's
	data structure pointers as __unbounded.
	* sysdeps/unix/sysv/linux/mips/bits/shm.h: Likewise.
	* sysdeps/generic/bp-semctl.h: New file.
	* sysdeps/unix/sysv/linux/msgctl.c: Qualify kernel's data
	structure pointers as __unbounded.  Check bounds of syscall args.
	* sysdeps/unix/sysv/linux/msgrcv.c: Likewise.
	* sysdeps/unix/sysv/linux/msgsnd.c: Likewise.
	* sysdeps/unix/sysv/linux/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/semop.c: Likewise.
	* sysdeps/unix/sysv/linux/shmat.c: Likewise.
	* sysdeps/unix/sysv/linux/shmctl.c: Likewise.
	* sysdeps/unix/sysv/linux/shmdt.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/msgctl.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/shmctl.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/msgctl.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/shmctl.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/msgctl.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/shmctl.c: Likewise.

Index: sysdeps/gnu/bits/msq.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/gnu/bits/msq.h,v
retrieving revision 1.2
diff -u -p -r1.2 msq.h
--- msq.h	2000/02/25 08:54:44	1.2
+++ msq.h	2000/07/27 03:12:27
@@ -38,13 +38,13 @@ typedef unsigned short int msglen_t;
 struct msqid_ds
 {
   struct ipc_perm msg_perm;	/* structure describing operation permission */
-  struct msg *__msg_first;	/* pointer to first message on queue */
-  struct msg *__msg_last;	/* pointer to last message on queue */
+  struct msg *__unbounded __msg_first; /* pointer to first message on queue */
+  struct msg *__unbounded __msg_last; /* pointer to last message on queue */
   __time_t msg_stime;		/* time of last msgsnd command */
   __time_t msg_rtime;		/* time of last msgrcv command */
   __time_t msg_ctime;		/* time of last change */
-  struct wait_queue *__wwait;	/* ??? */
-  struct wait_queue *__rwait;	/* ??? */
+  struct wait_queue *__unbounded __wwait; /* ??? */
+  struct wait_queue *__unbounded __rwait; /* ??? */
   unsigned short int __msg_cbytes;/* current number of bytes on queue */
   msgqnum_t msg_qnum;		/* number of messages currently on queue */
   msglen_t msg_qbytes;		/* max number of bytes allowed on queue */
Index: sysdeps/unix/sysv/linux/msgctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/msgctl.c,v
retrieving revision 1.6
diff -u -p -r1.6 msgctl.c
--- msgctl.c	2000/03/31 05:14:28	1.6
+++ msgctl.c	2000/07/27 03:12:27
@@ -25,19 +25,20 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include <shlib-compat.h>
+#include <bp-checks.h>
 
 #include "kernel-features.h"
 
 struct __old_msqid_ds
 {
   struct __old_ipc_perm msg_perm;	/* structure describing operation permission */
-  struct msg *__msg_first;		/* pointer to first message on queue */
-  struct msg *__msg_last;		/* pointer to last message on queue */
+  struct msg *__unbounded __msg_first;	/* pointer to first message on queue */
+  struct msg *__unbounded __msg_last;	/* pointer to last message on queue */
   __time_t msg_stime;			/* time of last msgsnd command */
   __time_t msg_rtime;			/* time of last msgrcv command */
   __time_t msg_ctime;			/* time of last change */
-  struct wait_queue *__wwait;		/* ??? */
-  struct wait_queue *__rwait;		/* ??? */
+  struct wait_queue *__unbounded __wwait; /* ??? */
+  struct wait_queue *__unbounded __rwait; /* ??? */
   unsigned short int __msg_cbytes;	/* current number of bytes on queue */
   unsigned short int msg_qnum;		/* number of messages currently on queue */
   unsigned short int msg_qbytes;	/* max number of bytes allowed on queue */
@@ -56,7 +57,7 @@ int __new_msgctl (int, int, struct msqid
 int
 __old_msgctl (int msqid, int cmd, struct __old_msqid_ds *buf)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, CHECK_1 (buf));
 }
 compat_symbol (libc, __old_msgctl, msgctl, GLIBC_2_0);
 #endif
@@ -65,7 +66,8 @@ int
 __new_msgctl (int msqid, int cmd, struct msqid_ds *buf)
 {
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
+			 msqid, cmd | __IPC_64, 0, CHECK_1 (buf));
 #else
   switch (cmd) {
     case MSG_STAT:
@@ -73,7 +75,8 @@ __new_msgctl (int msqid, int cmd, struct
     case IPC_SET:
       break;
     default:
-      return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
+      return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
+			     msqid, cmd, 0, CHECK_1 (buf));
   }
 
   {
@@ -82,7 +85,8 @@ __new_msgctl (int msqid, int cmd, struct
 
     /* Unfortunately there is no way how to find out for sure whether
        we should use old or new msgctl.  */
-    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf);
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
+			     msqid, cmd | __IPC_64, 0, CHECK_1 (buf));
     if (result != -1 || errno != EINVAL)
       return result;
 
@@ -101,7 +105,8 @@ __new_msgctl (int msqid, int cmd, struct
 	    return -1;
 	  }
       }
-    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, &old);
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
+			     msqid, cmd, 0, __ptrvalue (&old));
     if (result != -1 && cmd != IPC_SET)
       {
 	memset(buf, 0, sizeof(*buf));
Index: sysdeps/unix/sysv/linux/msgrcv.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/msgrcv.c,v
retrieving revision 1.6
diff -u -p -r1.6 msgrcv.c
--- msgrcv.c	2000/01/24 12:33:04	1.6
+++ msgrcv.c	2000/07/27 03:12:27
@@ -24,12 +24,13 @@
 #include <sysdep.h>
 #include <sys/syscall.h>
 
+#include <bp-checks.h>
 
 /* Kludge to work around Linux' restriction of only up to five
    arguments to a system call.  */
 struct ipc_kludge
   {
-    void *msgp;
+    void *__unbounded msgp;
     long int msgtyp;
   };
 
@@ -46,8 +47,8 @@ msgrcv (msqid, msgp, msgsz, msgtyp, msgf
      fives parameters to a system call.  */
   struct ipc_kludge tmp;
 
-  tmp.msgp = msgp;
+  tmp.msgp = CHECK_N (msgp, msgsz);
   tmp.msgtyp = msgtyp;
 
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgrcv, msqid, msgsz, msgflg, &tmp);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgrcv, msqid, msgsz, msgflg, __ptrvalue (&tmp));
 }
Index: sysdeps/unix/sysv/linux/msgsnd.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/msgsnd.c,v
retrieving revision 1.6
diff -u -p -r1.6 msgsnd.c
--- msgsnd.c	2000/01/24 12:33:04	1.6
+++ msgsnd.c	2000/07/27 03:12:27
@@ -24,6 +24,8 @@
 #include <sysdep.h>
 #include <sys/syscall.h>
 
+#include <bp-checks.h>
+
 int
 msgsnd (msqid, msgp, msgsz, msgflg)
      int msqid;
@@ -31,5 +33,6 @@ msgsnd (msqid, msgp, msgsz, msgflg)
      size_t msgsz;
      int msgflg;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz, msgflg, (void *)msgp);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgsnd, msqid, msgsz,
+			 msgflg, CHECK_N (msgp, msgsz));
 }
Index: sysdeps/unix/sysv/linux/semctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/semctl.c,v
retrieving revision 1.9
diff -u -p -r1.9 semctl.c
--- semctl.c	2000/03/31 10:21:40	1.9
+++ semctl.c	2000/07/27 03:12:27
@@ -34,10 +34,10 @@ struct __old_semid_ds
   struct __old_ipc_perm sem_perm;	/* operation permission struct */
   __time_t sem_otime;			/* last semop() time */
   __time_t sem_ctime;			/* last time changed by semctl() */
-  struct sem *__sembase;		/* ptr to first semaphore in array */
-  struct sem_queue *__sem_pending;	/* pending operations */
-  struct sem_queue *__sem_pending_last; /* last pending operation */
-  struct sem_undo *__undo;		/* ondo requests on this array */
+  struct sem *__unbounded __sembase;	/* ptr to first semaphore in array */
+  struct sem_queue *__unbounded __sem_pending; /* pending operations */
+  struct sem_queue *__unbounded __sem_pending_last; /* last pending operation */
+  struct sem_undo *__unbounded __undo;	/* ondo requests on this array */
   unsigned short int sem_nsems;		/* number of semaphores in set */
 };
 
@@ -50,6 +50,8 @@ union semun
   struct seminfo *__buf;	/* buffer for IPC_INFO */
 };
 
+#include <bp-checks.h>
+#include <bp-semctl.h>		/* definition of CHECK_SEMCTL needs union semum */
 
 /* Return identifier for array of NSEMS semaphores associated with
    KEY.  */
@@ -72,7 +74,8 @@ __old_semctl (int semid, int semnum, int
 
   va_end (ap);
 
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
+			 CHECK_SEMCTL (&arg, semid, cmd));
 }
 compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
 #endif
@@ -91,16 +94,19 @@ __new_semctl (int semid, int semnum, int
   va_end (ap);
 
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64, &arg);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
+			 CHECK_SEMCTL (&arg, semid, cmd | __IPC_64));
 #else
-  switch (cmd) {
+  switch (cmd)
+    {
     case SEM_STAT:
     case IPC_STAT:
     case IPC_SET:
       break;
     default:
-      return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
-  }
+      return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
+			     CHECK_SEMCTL (&arg, semid, cmd));
+    }
 
   {
     int save_errno = errno, result;
@@ -109,7 +115,8 @@ __new_semctl (int semid, int semnum, int
 
     /* Unfortunately there is no way how to find out for sure whether
        we should use old or new semctl.  */
-    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64, &arg);
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
+			     CHECK_SEMCTL (&arg, semid, cmd | __IPC_64));
     if (result != -1 || errno != EINVAL)
       return result;
 
@@ -128,7 +135,8 @@ __new_semctl (int semid, int semnum, int
 	    return -1;
 	  }
       }
-    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
+			     CHECK_SEMCTL (&arg, semid, cmd));
     if (result != -1 && cmd != IPC_SET)
       {
 	memset(buf, 0, sizeof(*buf));
Index: sysdeps/unix/sysv/linux/semop.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/semop.c,v
retrieving revision 1.6
diff -u -p -r1.6 semop.c
--- semop.c	2000/01/24 12:33:04	1.6
+++ semop.c	2000/07/27 03:12:27
@@ -23,6 +23,7 @@
 
 #include <sysdep.h>
 #include <sys/syscall.h>
+#include <bp-checks.h>
 
 /* Perform user-defined atomical operation of array of semaphores.  */
 
@@ -32,5 +33,6 @@ semop (semid, sops, nsops)
      struct sembuf *sops;
      size_t nsops;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semop, semid, (int) nsops, 0, sops);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_semop,
+			 semid, (int) nsops, 0, CHECK_N (sops, nsops));
 }
Index: sysdeps/unix/sysv/linux/shmat.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/shmat.c,v
retrieving revision 1.9
diff -u -p -r1.9 shmat.c
--- shmat.c	2000/01/24 12:33:04	1.9
+++ shmat.c	2000/07/27 03:12:27
@@ -23,6 +23,7 @@
 
 #include <sysdep.h>
 #include <sys/syscall.h>
+#include <bp-checks.h>
 
 /* Attach the shared memory segment associated with SHMID to the data
    segment of the calling process.  SHMADDR and SHMFLG determine how
@@ -34,11 +35,23 @@ shmat (shmid, shmaddr, shmflg)
      const void *shmaddr;
      int shmflg;
 {
-  long int retval;
-  unsigned long raddr;
+  void *__unbounded result;
+  void *__unbounded raddr;
 
-  retval = INLINE_SYSCALL (ipc, 5, IPCOP_shmat, shmid, shmflg,
-			   (long int) &raddr, (void *) shmaddr);
-  return ((unsigned long int) retval > -(unsigned long int) SHMLBA
-	  ? (void *) retval : (void *) raddr);
+#if __BOUNDED_POINTERS__
+  size_t length = ~0;
+  struct shmid_ds shmds;
+  /* It's unfortunate that we need to make another system call to get
+     the shared memory segment length...  */
+  if (shmctl (shmid, ICP_STAT, &shmds) == 0)
+    length = shmds.shm_segsz;
+#endif
+
+  result = (void *__unbounded) INLINE_SYSCALL (ipc, 5, IPCOP_shmat, shmid, shmflg,
+					       __ptrvalue (&raddr),
+					       __ptrvalue (shmaddr));
+  if ((unsigned long) result <= -(unsigned long) SHMLBA)
+    result = raddr;
+
+  return BOUNDED_N (result, length);
 }
Index: sysdeps/unix/sysv/linux/shmctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/shmctl.c,v
retrieving revision 1.7
diff -u -p -r1.7 shmctl.c
--- shmctl.c	2000/03/31 10:21:40	1.7
+++ shmctl.c	2000/07/27 03:12:27
@@ -26,6 +26,7 @@
 #include <sys/syscall.h>
 #include <bits/wordsize.h>
 #include <shlib-compat.h>
+#include <bp-checks.h>
 
 #include "kernel-features.h"
 
@@ -40,8 +41,8 @@ struct __old_shmid_ds
   __ipc_pid_t shm_lpid;			/* pid of last shmop */
   unsigned short int shm_nattch;	/* number of current attaches */
   unsigned short int __shm_npages;	/* size of segment (pages) */
-  unsigned long int *__shm_pages;	/* array of ptrs to frames -> SHMMAX */
-  struct vm_area_struct *__attaches;	/* descriptors for attaches */
+  unsigned long int *__unbounded __shm_pages; /* array of ptrs to frames -> SHMMAX */
+  struct vm_area_struct *__unbounded __attaches; /* descriptors for attaches */
 };
 
 struct __old_shminfo
@@ -63,7 +64,8 @@ int __new_shmctl (int, int, struct shmid
 int
 __old_shmctl (int shmid, int cmd, struct __old_shmid_ds *buf)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid,
+			 cmd, 0, CHECK_1opt (buf));
 }
 compat_symbol (libc, __old_shmctl, shmctl, GLIBC_2_0);
 #endif
@@ -72,7 +74,7 @@ int
 __new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
 {
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd | __IPC_64, 0, CHECK_1 (buf));
 #else
   switch (cmd) {
     case SHM_STAT:
@@ -83,7 +85,7 @@ __new_shmctl (int shmid, int cmd, struct
 #endif
       break;
     default:
-      return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
+      return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, CHECK_1 (buf));
   }
 
   {
@@ -92,7 +94,7 @@ __new_shmctl (int shmid, int cmd, struct
 
     /* Unfortunately there is no way how to find out for sure whether
        we should use old or new shmctl.  */
-    result = INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf);
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd | __IPC_64, 0, CHECK_1 (buf));
     if (result != -1 || errno != EINVAL)
       return result;
 
@@ -109,7 +111,7 @@ __new_shmctl (int shmid, int cmd, struct
 	    return -1;
 	  }
       }
-    result = INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, &old);
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, __ptrvalue (&old));
     if (result != -1 && (cmd == SHM_STAT || cmd == IPC_STAT))
       {
 	memset(buf, 0, sizeof(*buf));
Index: sysdeps/unix/sysv/linux/shmdt.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/shmdt.c,v
retrieving revision 1.6
diff -u -p -r1.6 shmdt.c
--- shmdt.c	2000/01/24 12:33:04	1.6
+++ shmdt.c	2000/07/27 03:12:27
@@ -31,5 +31,5 @@ int
 shmdt (shmaddr)
      const void *shmaddr;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmdt, 0, 0, 0, (void *) shmaddr);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_shmdt, 0, 0, 0, __ptrvalue ((void *) shmaddr));
 }
Index: sysdeps/unix/sysv/linux/alpha/msgctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/alpha/msgctl.c,v
retrieving revision 1.4
diff -u -p -r1.4 msgctl.c
--- msgctl.c	2000/04/22 06:54:09	1.4
+++ msgctl.c	2000/07/27 03:12:27
@@ -24,19 +24,20 @@
 #include <sysdep.h>
 #include <string.h>
 #include <sys/syscall.h>
+#include <bp-checks.h>
 
 #include "kernel-features.h"
 
 struct __old_msqid_ds
 {
   struct __old_ipc_perm msg_perm;	/* structure describing operation permission */
-  struct msg *__msg_first;		/* pointer to first message on queue */
-  struct msg *__msg_last;		/* pointer to last message on queue */
+  struct msg *__unbounded __msg_first;	/* pointer to first message on queue */
+  struct msg *__unbounded __msg_last;	/* pointer to last message on queue */
   __time_t msg_stime;			/* time of last msgsnd command */
   __time_t msg_rtime;			/* time of last msgrcv command */
   __time_t msg_ctime;			/* time of last change */
-  struct wait_queue *__wwait;		/* ??? */
-  struct wait_queue *__rwait;		/* ??? */
+  struct wait_queue *__unbounded __wwait; /* ??? */
+  struct wait_queue *__unbounded __rwait; /* ??? */
   unsigned short int __msg_cbytes;	/* current number of bytes on queue */
   unsigned short int msg_qnum;		/* number of messages currently on queue */
   unsigned short int msg_qbytes;	/* max number of bytes allowed on queue */
@@ -57,7 +58,7 @@ __new_msgctl (int msqid, int cmd, struct
      of time.  However, msg_qnum and msg_qbytes changed size at
      the same time the size of uid changed elsewhere.  */
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (msgctl, 3, msqid, cmd | __IPC_64, buf);
+  return INLINE_SYSCALL (msgctl, 3, msqid, cmd | __IPC_64, CHECK_1 (buf));
 #else
   switch (cmd) {
     case MSG_STAT:
@@ -65,7 +66,7 @@ __new_msgctl (int msqid, int cmd, struct
     case IPC_SET:
       break;
     default:
-      return INLINE_SYSCALL (msgctl, 3, msqid, cmd, buf);
+      return INLINE_SYSCALL (msgctl, 3, msqid, cmd, CHECK_1 (buf));
   }
 
   {
@@ -74,7 +75,7 @@ __new_msgctl (int msqid, int cmd, struct
 
     /* Unfortunately there is no way how to find out for sure whether
        we should use old or new msgctl.  */
-    result = INLINE_SYSCALL (msgctl, 3, msqid, cmd | __IPC_64, buf);
+    result = INLINE_SYSCALL (msgctl, 3, msqid, cmd | __IPC_64, CHECK_1 (buf));
     if (result != -1 || errno != EINVAL)
       return result;
 
@@ -93,7 +94,7 @@ __new_msgctl (int msqid, int cmd, struct
 	    return -1;
 	  }
       }
-    result = INLINE_SYSCALL (msgctl, 3, msqid, cmd, &old);
+    result = INLINE_SYSCALL (msgctl, 3, msqid, cmd, __ptrvalue (&old));
     if (result != -1 && cmd != IPC_SET)
       {
 	memset(buf, 0, sizeof(*buf));
@@ -120,4 +121,3 @@ __new_msgctl (int msqid, int cmd, struct
 
 #include <shlib-compat.h>
 versioned_symbol (libc, __new_msgctl, msgctl, GLIBC_2_2);
-
Index: sysdeps/unix/sysv/linux/alpha/semctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/alpha/semctl.c,v
retrieving revision 1.3
diff -u -p -r1.3 semctl.c
--- semctl.c	2000/04/22 06:54:21	1.3
+++ semctl.c	2000/07/27 03:12:27
@@ -49,6 +49,9 @@ union semun
   struct seminfo *__buf;	/* buffer for IPC_INFO */
 };
 
+#include <bp-checks.h>
+#include <bp-semctl.h>		/* definition of CHECK_SEMCTL needs union semum */
+
 extern int __syscall_semctl (int, int, int, void *);
 
 /* Return identifier for array of NSEMS semaphores associated with
@@ -69,7 +72,8 @@ __new_semctl (int semid, int semnum, int
   va_end (ap);
 
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd | __IPC_64, &arg);
+  return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd | __IPC_64,
+			 CHECK_SEMCTL (&arg, semid, cmd | __IPC_64));
 #else
   switch (cmd) {
     case SEM_STAT:
@@ -77,7 +81,8 @@ __new_semctl (int semid, int semnum, int
     case IPC_SET:
       break;
     default:
-      return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd, &arg);
+      return INLINE_SYSCALL (semctl, 4, semid, semnum, cmd,
+			     CHECK_SEMCTL (&arg, semid, cmd));
   }
 
   {
@@ -87,7 +92,8 @@ __new_semctl (int semid, int semnum, int
 
     /* Unfortunately there is no way how to find out for sure whether
        we should use old or new semctl.  */
-    result = INLINE_SYSCALL (semctl, 4, semid, semnum, cmd | __IPC_64, &arg);
+    result = INLINE_SYSCALL (semctl, 4, semid, semnum, cmd | __IPC_64,
+			     CHECK_SEMCTL (&arg, semid, cmd | __IPC_64));
     if (result != -1 || errno != EINVAL)
       return result;
 
@@ -106,7 +112,8 @@ __new_semctl (int semid, int semnum, int
 	    return -1;
 	  }
       }
-    result = INLINE_SYSCALL (semctl, 4, semid, semnum, cmd, &arg);
+    result = INLINE_SYSCALL (semctl, 4, semid, semnum, cmd,
+			     CHECK_SEMCTL (&arg, semid, cmd));
     if (result != -1 && cmd != IPC_SET)
       {
 	memset(buf, 0, sizeof(*buf));
Index: sysdeps/unix/sysv/linux/alpha/shmctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/alpha/shmctl.c,v
retrieving revision 1.3
diff -u -p -r1.3 shmctl.c
--- shmctl.c	2000/04/22 06:54:35	1.3
+++ shmctl.c	2000/07/27 03:12:27
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include <bits/wordsize.h>
+#include <bp-checks.h>
 
 #include "kernel-features.h"
 
@@ -39,8 +40,8 @@ struct __old_shmid_ds
   __ipc_pid_t shm_lpid;			/* pid of last shmop */
   unsigned short int shm_nattch;	/* number of current attaches */
   unsigned short int __shm_npages;	/* size of segment (pages) */
-  unsigned long int *__shm_pages;	/* array of ptrs to frames -> SHMMAX */
-  struct vm_area_struct *__attaches;	/* descriptors for attaches */
+  unsigned long int *__unbounded __shm_pages; /* array of ptrs to frames -> SHMMAX */
+  struct vm_area_struct *__unbounded __attaches; /* descriptors for attaches */
 };
 
 struct __old_shminfo
@@ -61,7 +62,7 @@ int
 __new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
 {
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (shmctl, 3, shmid, cmd | __IPC_64, buf);
+  return INLINE_SYSCALL (shmctl, 3, shmid, cmd | __IPC_64, CHECK_1 (buf));
 #else
   switch (cmd) {
     case SHM_STAT:
@@ -70,7 +71,7 @@ __new_shmctl (int shmid, int cmd, struct
     case IPC_INFO:
       break;
     default:
-      return INLINE_SYSCALL (shmctl, 3, shmid, cmd, buf);
+      return INLINE_SYSCALL (shmctl, 3, shmid, cmd, CHECK_1 (buf));
   }
 
   {
@@ -79,7 +80,7 @@ __new_shmctl (int shmid, int cmd, struct
 
     /* Unfortunately there is no way how to find out for sure whether
        we should use old or new shmctl.  */
-    result = INLINE_SYSCALL (shmctl, 3, shmid, cmd | __IPC_64, buf);
+    result = INLINE_SYSCALL (shmctl, 3, shmid, cmd | __IPC_64, CHECK_1 (buf));
     if (result != -1 || errno != EINVAL)
       return result;
 
@@ -96,7 +97,7 @@ __new_shmctl (int shmid, int cmd, struct
 	    return -1;
 	  }
       }
-    result = INLINE_SYSCALL (shmctl, 3, shmid, cmd, &old);
+    result = INLINE_SYSCALL (shmctl, 3, shmid, cmd, __ptrvalue (&old));
     if (result != -1 && (cmd == SHM_STAT || cmd == IPC_STAT))
       {
 	memset(buf, 0, sizeof(*buf));
Index: sysdeps/unix/sysv/linux/i386/msgctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/i386/msgctl.c,v
retrieving revision 1.3
diff -u -p -r1.3 msgctl.c
--- msgctl.c	2000/03/31 05:14:28	1.3
+++ msgctl.c	2000/07/27 03:12:28
@@ -24,6 +24,7 @@
 #include <sysdep.h>
 #include <string.h>
 #include <sys/syscall.h>
+#include <bp-checks.h>
 
 #include "kernel-features.h"
 #include <shlib-compat.h>
@@ -31,13 +32,13 @@
 struct __old_msqid_ds
 {
   struct __old_ipc_perm msg_perm;	/* structure describing operation permission */
-  struct msg *__msg_first;		/* pointer to first message on queue */
-  struct msg *__msg_last;		/* pointer to last message on queue */
+  struct msg *__unbounded __msg_first;	/* pointer to first message on queue */
+  struct msg *__unbounded __msg_last;	/* pointer to last message on queue */
   __time_t msg_stime;			/* time of last msgsnd command */
   __time_t msg_rtime;			/* time of last msgrcv command */
   __time_t msg_ctime;			/* time of last change */
-  struct wait_queue *__wwait;		/* ??? */
-  struct wait_queue *__rwait;		/* ??? */
+  struct wait_queue *__unbounded __wwait; /* ??? */
+  struct wait_queue *__unbounded __rwait; /* ??? */
   unsigned short int __msg_cbytes;	/* current number of bytes on queue */
   unsigned short int msg_qnum;		/* number of messages currently on queue */
   unsigned short int msg_qbytes;	/* max number of bytes allowed on queue */
@@ -64,7 +65,8 @@ extern int __libc_missing_32bit_uids;
 int
 __old_msgctl (int msqid, int cmd, struct __old_msqid_ds *buf)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
+			 msqid, cmd, 0, CHECK_1 (buf));
 }
 compat_symbol (libc, __old_msgctl, msgctl, GLIBC_2_0);
 #endif
@@ -73,7 +75,8 @@ int
 __new_msgctl (int msqid, int cmd, struct msqid_ds *buf)
 {
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
+			 msqid, cmd | __IPC_64, 0, CHECK_1 (buf));
 #else
   switch (cmd) {
     case MSG_STAT:
@@ -81,7 +84,8 @@ __new_msgctl (int msqid, int cmd, struct
     case IPC_SET:
       break;
     default:
-      return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
+      return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
+			     msqid, cmd, 0, CHECK_1 (buf));
   }
 
   {
@@ -105,7 +109,8 @@ __new_msgctl (int msqid, int cmd, struct
 	  }
 	if (__libc_missing_32bit_uids <= 0)
 	  {
-	    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd | __IPC_64, 0, buf);
+	    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
+				     msqid, cmd | __IPC_64, 0, CHECK_1 (buf));
 	    return result;
 	  }
       }
@@ -124,7 +129,8 @@ __new_msgctl (int msqid, int cmd, struct
 	    return -1;
 	  }
       }
-    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, &old);
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_msgctl,
+			     msqid, cmd, 0, __ptrvalue (&old));
     if (result != -1 && cmd != IPC_SET)
       {
 	memset(buf, 0, sizeof(*buf));
Index: sysdeps/unix/sysv/linux/i386/semctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/i386/semctl.c,v
retrieving revision 1.3
diff -u -p -r1.3 semctl.c
--- semctl.c	2000/03/31 05:14:28	1.3
+++ semctl.c	2000/07/27 03:12:28
@@ -50,6 +50,9 @@ union semun
   struct seminfo *__buf;	/* buffer for IPC_INFO */
 };
 
+#include <bp-checks.h>
+#include <bp-semctl.h>		/* definition of CHECK_SEMCTL needs union semum */
+
 #ifdef __NR_getuid32
 # if __ASSUME_32BITUIDS == 0
 /* This variable is shared with all files that need to check for 32bit
@@ -79,7 +82,8 @@ __old_semctl (int semid, int semnum, int
 
   va_end (ap);
 
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
+			 CHECK_SEMCTL (&arg, semid, cmd));
 }
 compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
 #endif
@@ -98,7 +102,8 @@ __new_semctl (int semid, int semnum, int
   va_end (ap);
 
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64, &arg);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
+			 CHECK_SEMCTL (&arg, semid, cmd | __IPC_64));
 #else
   switch (cmd) {
     case SEM_STAT:
@@ -106,7 +111,8 @@ __new_semctl (int semid, int semnum, int
     case IPC_SET:
       break;
     default:
-      return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
+      return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
+			     CHECK_SEMCTL (&arg, semid, cmd));
   }
 
   {
@@ -131,7 +137,8 @@ __new_semctl (int semid, int semnum, int
 	  }
 	if (__libc_missing_32bit_uids <= 0)
 	  {
-	    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64, &arg);
+	    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
+				     CHECK_SEMCTL (&arg, semid, cmd | __IPC_64));
 	    return result;
 	  }
       }
@@ -151,7 +158,8 @@ __new_semctl (int semid, int semnum, int
 	    return -1;
 	  }
       }
-    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
+			     CHECK_SEMCTL (&arg, semid, cmd));
     if (result != -1 && cmd != IPC_SET)
       {
 	memset(buf, 0, sizeof(*buf));
Index: sysdeps/unix/sysv/linux/i386/shmctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/i386/shmctl.c,v
retrieving revision 1.4
diff -u -p -r1.4 shmctl.c
--- shmctl.c	2000/03/31 05:14:28	1.4
+++ shmctl.c	2000/07/27 03:12:28
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <sys/syscall.h>
 #include <bits/wordsize.h>
+#include <bp-checks.h>
 
 #include "kernel-features.h"
 #include <shlib-compat.h>
@@ -40,8 +41,8 @@ struct __old_shmid_ds
   __ipc_pid_t shm_lpid;			/* pid of last shmop */
   unsigned short int shm_nattch;	/* number of current attaches */
   unsigned short int __shm_npages;	/* size of segment (pages) */
-  unsigned long int *__shm_pages;	/* array of ptrs to frames -> SHMMAX */
-  struct vm_area_struct *__attaches;	/* descriptors for attaches */
+  unsigned long int *__unbounded __shm_pages; /* array of ptrs to frames -> SHMMAX */
+  struct vm_area_struct *__unbounded __attaches; /* descriptors for attaches */
 };
 
 struct __old_shminfo
@@ -71,7 +72,8 @@ int __new_shmctl (int, int, struct shmid
 int
 __old_shmctl (int shmid, int cmd, struct __old_shmid_ds *buf)
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl,
+			 shmid, cmd, 0, CHECK_1 (buf));
 }
 compat_symbol (libc, __old_shmctl, shmctl, GLIBC_2_0);
 #endif
@@ -80,7 +82,8 @@ int
 __new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
 {
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd | __IPC_64, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl,
+			 shmid, cmd | __IPC_64, 0, CHECK_1 (buf));
 #else
   switch (cmd) {
     case SHM_STAT:
@@ -91,7 +94,8 @@ __new_shmctl (int shmid, int cmd, struct
 # endif
       break;
     default:
-      return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
+      return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl,
+			     shmid, cmd, 0, CHECK_1 (buf));
   }
 
   {
@@ -114,8 +118,8 @@ __new_shmctl (int shmid, int cmd, struct
 	    __set_errno(save_errno);
 	  }
 	if (__libc_missing_32bit_uids <= 0)
-	  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd | __IPC_64,
-				 0, buf);
+	  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl,
+				 shmid, cmd | __IPC_64, 0, CHECK_1 (buf));
       }
 # endif
 
@@ -131,7 +135,8 @@ __new_shmctl (int shmid, int cmd, struct
 	    return -1;
 	  }
       }
-    result = INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, &old);
+    result = INLINE_SYSCALL (ipc, 5, IPCOP_shmctl,
+			     shmid, cmd, 0, __ptrvalue (&old));
     if (result != -1 && (cmd == SHM_STAT || cmd == IPC_STAT))
       {
 	memset(buf, 0, sizeof(*buf));
Index: sysdeps/unix/sysv/linux/mips/bits/shm.h
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/mips/bits/shm.h,v
retrieving revision 1.2
diff -u -p -r1.2 shm.h
--- shm.h	1997/11/26 04:09:49	1.2
+++ shm.h	2000/07/27 03:12:28
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -48,8 +48,8 @@ struct shmid_ds
     long int shm_lpid;			/* pid of last shmop */
     unsigned short int shm_nattch;	/* number of current attaches */
     unsigned short int __shm_npages;	/* size of segment (pages) */
-    unsigned long int *__shm_pages;	/* array of ptrs to frames -> SHMMAX */
-    struct vm_area_struct *__attaches;	/* descriptors for attaches */
+    unsigned long int *__unbounded __shm_pages;	/* array of ptrs to frames -> SHMMAX */
+    struct vm_area_struct *__unbounded __attaches; /* descriptors for attaches */
   };
 
 #ifdef __USE_MISC
Index: sysdeps/unix/sysv/linux/sparc/sparc64/msgctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/sparc/sparc64/msgctl.c,v
retrieving revision 1.2
diff -u -p -r1.2 msgctl.c
--- msgctl.c	2000/01/24 12:32:12	1.2
+++ msgctl.c	2000/07/27 03:12:28
@@ -23,6 +23,7 @@
 
 #include <sysdep.h>
 #include <sys/syscall.h>
+#include <bp-checks.h>
 
 /* Allows to control internal state and destruction of message queue
    objects.  */
@@ -33,5 +34,5 @@ msgctl (msqid, cmd, buf)
      int cmd;
      struct msqid_ds *buf;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_msgctl, msqid, cmd, 0, CHECK_1 (buf));
 }
Index: sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/sparc/sparc64/semctl.c,v
retrieving revision 1.2
diff -u -p -r1.2 semctl.c
--- semctl.c	2000/01/24 12:32:12	1.2
+++ semctl.c	2000/07/27 03:12:28
@@ -34,6 +34,8 @@ union semun
   struct seminfo *__buf;	/* buffer for IPC_INFO */
 };
 
+#include <bp-checks.h>
+#include <bp-semctl.h>		/* definition of CHECK_SEMCTL needs union semum */
 
 /* Return identifier for array of NSEMS semaphores associated with
    KEY.  */
@@ -51,5 +53,6 @@ semctl (int semid, int semnum, int cmd, 
 
   va_end (ap);
 
-  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, &arg);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
+			 CHECK_SEMCTL (&arg, semid, cmd));
 }
Index: sysdeps/unix/sysv/linux/sparc/sparc64/shmctl.c
===================================================================
RCS file: /cvs/glibc/libc/sysdeps/unix/sysv/linux/sparc/sparc64/shmctl.c,v
retrieving revision 1.2
diff -u -p -r1.2 shmctl.c
--- shmctl.c	2000/01/24 12:32:12	1.2
+++ shmctl.c	2000/07/27 03:12:28
@@ -23,6 +23,7 @@
 
 #include <sysdep.h>
 #include <sys/syscall.h>
+#include <bp-checks.h>
 
 /* Provide operations to control over shared memory segments.  */
 
@@ -32,5 +33,5 @@ shmctl (shmid, cmd, buf)
      int cmd;
      struct shmid_ds *buf;
 {
-  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, buf);
+  return INLINE_SYSCALL (ipc, 5, IPCOP_shmctl, shmid, cmd, 0, CHECK_1 (buf));
 }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]