about summary refs log tree commit diff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorGreg McGary <greg@mcgary.org>2000-07-06 00:48:39 +0000
committerGreg McGary <greg@mcgary.org>2000-07-06 00:48:39 +0000
commit34173b51e7b16366953c6f34f6b6cc0012d63fa4 (patch)
treeb3759f8f6afe37602589befbf3cd6ea6ab1630c9 /sysdeps/generic
parent77432371acbde32fad2c0ee200c94da21dbaf70d (diff)
downloadglibc-34173b51e7b16366953c6f34f6b6cc0012d63fa4.tar.gz
glibc-34173b51e7b16366953c6f34f6b6cc0012d63fa4.tar.xz
glibc-34173b51e7b16366953c6f34f6b6cc0012d63fa4.zip
* sysdeps/generic/bp-checks.h: New file.
* sysdeps/generic/bp-thunks.h: Replace generic thunk definitions 
with list of #include files. 
* sysdeps/unix/make-syscalls.sh: Handle new arg signature 
keyletters a, b, B, f, n, N, P, v, V.  Fixup some indentation. 
Don't generate BP thunk if `V' appears in signature. 
Generate thunks with complete bounds checks. 
* sysdeps/unix/syscalls.list: Refine signatures using new keyletters. 
* sysdeps/unix/inet/syscalls.list: Likewise. 
* sysdeps/unix/mman/syscalls.list: Likewise. 
* sysdeps/unix/sysv/linux/syscalls.list: Likewise. 
* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise. 
* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise. 
* sysdeps/unix/sysv/linux/powerpc/syscalls.list: Likewise.
2000-07-05  Greg McGary  <greg@mcgary.org>

	* sysdeps/generic/bp-checks.h: New file.
	* sysdeps/generic/bp-thunks.h: Replace generic thunk definitions
	with list of #include files.
	* sysdeps/unix/make-syscalls.sh: Handle new arg signature
	keyletters a, b, B, f, n, N, P, v, V.  Fixup some indentation.
	Don't generate BP thunk if `V' appears in signature.
	Generate thunks with complete bounds checks.
	* sysdeps/unix/syscalls.list: Refine signatures using new keyletters.
	* sysdeps/unix/inet/syscalls.list: Likewise.
	* sysdeps/unix/mman/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/ia64/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/mips/syscalls.list: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/syscalls.list: Likewise.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/bp-checks.h98
-rw-r--r--sysdeps/generic/bp-thunks.h232
2 files changed, 132 insertions, 198 deletions
diff --git a/sysdeps/generic/bp-checks.h b/sysdeps/generic/bp-checks.h
new file mode 100644
index 0000000000..a7c54b4955
--- /dev/null
+++ b/sysdeps/generic/bp-checks.h
@@ -0,0 +1,98 @@
+/* Bounded-pointer checking macros for C.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   Contributed by Greg McGary <greg@mcgary.org>
+
+   This file is part of the GNU C Library.  Its master source is NOT part of
+   the C library, however.  The master source lives in the GNU MP Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#ifndef _bp_checks_h_
+# define _bp_checks_h_ 1
+
+# if !__ASSEMBLER__
+
+#  if __BOUNDED_POINTERS__
+
+/* GKM FIXME: when gcc is ready, add real bounds checks */
+#   define BOUNDS_VIOLATED (__builtin_trap (), 0)
+extern int __ubp_memchr (const char *__unbounded, int, unsigned);
+
+/* Verify that pointer's value >= low.  Return pointer value.  */
+#   define CHECK_BOUNDS_LOW(ARG)				\
+  (((__ptrvalue (ARG) < __ptrlow (ARG)) && BOUNDS_VIOLATED),	\
+   __ptrvalue (ARG))
+
+/* Verify that pointer's value < high.  Return pointer value.  */
+#   define CHECK_BOUNDS_HIGH(ARG)				\
+  (((__ptrvalue (ARG) > __ptrhigh (ARG)) && BOUNDS_VIOLATED),	\
+   __ptrvalue (ARG))
+
+/* Check bounds of a pointer seated to a single object.  */
+#   define CHECK_1(ARG) CHECK_N ((ARG), 1)
+
+/* Same as CHECK_1, but tolerate ARG == NULL.  */
+#   define CHECK_1opt(ARG) CHECK_Nopt ((ARG), 1)
+
+/* Check bounds of a pointer seated to an array of N objects.  */
+#   define CHECK_N(ARG, N)				\
+  (((__ptrvalue (ARG) < __ptrlow (ARG)			\
+     || __ptrvalue (ARG) + (N) > __ptrhigh (ARG))	\
+    && BOUNDS_VIOLATED), __ptrvalue (ARG))
+
+/* Same as CHECK_N, but tolerate ARG == NULL.  */
+#   define CHECK_Nopt(ARG, N)				\
+  (((__ptrvalue (ARG)					\
+     && (__ptrvalue (ARG) < __ptrlow (ARG)		\
+	 || __ptrvalue (ARG) + (N) > __ptrhigh (ARG)))	\
+    && BOUNDS_VIOLATED), __ptrvalue (ARG))
+
+/* Check for NUL-terminator within string's bounds.  */
+#   define CHECK_STRING(ARG)					\
+  (((__ptrvalue (ARG) < __ptrlow (ARG)				\
+     || !__ubp_memchr (__ptrvalue (ARG), '\0',			\
+		       (__ptrhigh (ARG) - __ptrvalue (ARG))))	\
+     && BOUNDS_VIOLATED),					\
+   __ptrvalue (ARG))
+
+#  else /* !__BOUNDED_POINTERS__ */
+
+/* Do nothing if not compiling with -fbounded-pointers.  */
+
+#   define BOUNDS_VIOLATED
+#   define CHECK_BOUNDS_LOW(ARG) (ARG)
+#   define CHECK_BOUNDS_HIGH(ARG) (ARG)
+#   define CHECK_1(ARG) (ARG)
+#   define CHECK_1opt(ARG) (ARG)
+#   define CHECK_N(ARG, N) (ARG)
+#   define CHECK_Nopt(ARG, N) (ARG)
+#   define CHECK_STRING(ARG) (ARG)
+
+#  endif /* !__BOUNDED_POINTERS__ */
+
+#  if defined (_IOC_SIZESHIFT) && defined (_IOC_SIZEBITS)
+
+/* Extract the size of the ioctl parameter argument and check its bounds.  */
+#   define CHECK_IOCTL(ARG, CMD) \
+  CHECK_N ((ARG), (((CMD) >> _IOC_SIZESHIFT) & ((1 << _IOC_SIZEBITS) - 1)))
+
+#  else
+#   define CHECK_IOCTL(ARG, CMD) __ptrvalue (ARG)
+#  endif
+
+# endif /* !__ASSEMBLER__ */
+
+#endif /* _bp_checks_h_ */
diff --git a/sysdeps/generic/bp-thunks.h b/sysdeps/generic/bp-thunks.h
index eb0a47b2c1..b036d6ab52 100644
--- a/sysdeps/generic/bp-thunks.h
+++ b/sysdeps/generic/bp-thunks.h
@@ -1,4 +1,4 @@
-/* Bounded-pointer thunk definitions.
+/* Bounded-pointer syscall thunk support.
    Copyright (C) 2000 Free Software Foundation, Inc.
    Contributed by Greg McGary <greg@mcgary.org>
 
@@ -23,203 +23,39 @@
 #ifndef _bpthunks_h_
 #define _bpthunks_h_
 
-#include <libc-symbols.h>
-
-#define BP_ALIAS(STRONG, ALIAS) weak_alias (__BP_##STRONG, __BP_##ALIAS)
-
-#define PV(P) __ptrvalue (P)
-#define SV(S) __ptrvalue (S)
-#define PB(P) __ptrlow (P)
-#define PE(P) __ptrhigh (P)
-#define voidp void *__bounded
-#define charp char *__bounded
-
-/* GKM FIXME: Add code to check bounds.  Right now, they only strip bounds, */
-
-#define BP_THUNK_i_iiip(NAME) __unbounded { \
-  extern int NAME (int, int, int, void *); \
-  int __BP_##NAME (int i0, int i1, int i2, voidp p3) \
-    { return NAME (i0, i1, i2, PV (p3)); } }
-
-#define BP_THUNK_i_iiipi(NAME) __unbounded { \
-  extern int NAME (int, int, int, void *, int); \
-  int __BP_##NAME (int i0, int i1, int i2, voidp p3, int i4) \
-    { return NAME (i0, i1, i2, PV (p3), i4); } }
-
-#define BP_THUNK_i_iiipp(NAME) __unbounded { \
-  extern int NAME (int, int, int, void *, void *); \
-  int __BP_##NAME (int i0, int i1, int i2, voidp p3, voidp p4) \
-    { return NAME (i0, i1, i2, PV (p3), PV (p4)); } }
-
-#define BP_THUNK_i_iip(NAME) __unbounded { \
-  extern int NAME (int, int, void *); \
-  int __BP_##NAME (int i0, int i1, voidp p2) \
-    { return NAME (i0, i1, PV (p2)); } }
-
-#define BP_THUNK_i_iipi(NAME) __unbounded { \
-  extern int NAME (int, int, void *, int); \
-  int __BP_##NAME (int i0, int i1, voidp p2, int i3) \
-    { return NAME (i0, i1, PV (p2), i3); } }
-
-#define BP_THUNK_i_iipp(NAME) __unbounded { \
-  extern int NAME (int, int, void *, void *); \
-  int __BP_##NAME (int i0, int i1, voidp p2, voidp p3) \
-    { return NAME (i0, i1, PV (p2), PV (p3)); } }
-
-#define BP_THUNK_i_ip(NAME) __unbounded { \
-  extern int NAME (int, void *); \
-  int __BP_##NAME (int i0, voidp p1) \
-    { return NAME (i0, PV (p1)); } }
-
-#define BP_THUNK_i_ipi(NAME) __unbounded { \
-  extern int NAME (int, void *, int); \
-  int __BP_##NAME (int i0, voidp p1, int i2) \
-    { return NAME (i0, PV (p1), i2); } }
-
-#define BP_THUNK_i_ipii(NAME) __unbounded { \
-  extern int NAME (int, void *, int, int); \
-  int __BP_##NAME (int i0, voidp p1, int i2, int i3) \
-    { return NAME (i0, PV (p1), i2, i3); } }
-
-#define BP_THUNK_i_ipiii(NAME) __unbounded { \
-  extern int NAME (int, void *, int, int, int); \
-  int __BP_##NAME (int i0, voidp p1, int i2, int i3, int i4) \
-    { return NAME (i0, PV (p1), i2, i3, i4); } }
-
-#define BP_THUNK_i_ipiipi(NAME) __unbounded { \
-  extern int NAME (int, void *, int, int, void *, int); \
-  int __BP_##NAME (int i0, voidp p1, int i2, int i3, voidp p4, int i5) \
-    { return NAME (i0, PV (p1), i2, i3, PV (p4), i5); } }
-
-#define BP_THUNK_i_ipiipp(NAME) __unbounded { \
-  extern int NAME (int, void *, int, int, void *, void *); \
-  int __BP_##NAME (int i0, voidp p1, int i2, int i3, voidp p4, voidp p5) \
-    { return NAME (i0, PV (p1), i2, i3, PV (p4), PV (p5)); } }
-
-#define BP_THUNK_i_ipip(NAME) __unbounded { \
-  extern int NAME (int, void *, int, void *); \
-  int __BP_##NAME (int i0, voidp p1, int i2, voidp p3) \
-    { return NAME (i0, PV (p1), i2, PV (p3)); } }
-
-#define BP_THUNK_i_ipp(NAME) __unbounded { \
-  extern int NAME (int, void *, void *); \
-  int __BP_##NAME (int i0, voidp p1, voidp p2) \
-    { return NAME (i0, PV (p1), PV (p2)); } }
-
-#define BP_THUNK_i_ippi(NAME) __unbounded { \
-  extern int NAME (int, void *, void *, int); \
-  int __BP_##NAME (int i0, voidp p1, voidp p2, int i3) \
-    { return NAME (i0, PV (p1), PV (p2), i3); } }
-
-#define BP_THUNK_i_ipppp(NAME) __unbounded { \
-  extern int NAME (int, void *, void *, void *, void *); \
-  int __BP_##NAME (int i0, voidp p1, voidp p2, voidp p3, voidp p4) \
-    { return NAME (i0, PV (p1), PV (p2), PV (p3), PV (p4)); } }
+/* This header is included by the syscall BP thunks defined in
+   sysd-syscalls, as created by sysdeps/unix/make-syscalls.sh.  It
+   includes all headers that contain prototype declarations for system
+   call functions.  */
 
-#define BP_THUNK_i_isi(NAME) __unbounded { \
-  extern int NAME (int, char *, int); \
-  int __BP_##NAME (int i0, charp s1, int i2) \
-    { return NAME (i0, SV (s1), i2); } }
-
-#define BP_THUNK_i_isip(NAME) __unbounded { \
-  extern int NAME (int, char *, int, void *); \
-  int __BP_##NAME (int i0, charp s1, int i2, voidp p3) \
-    { return NAME (i0, SV (s1), i2, PV (p3)); } }
-
-#define BP_THUNK_i_p(NAME) __unbounded { \
-  extern int NAME (void *); \
-  int __BP_##NAME (voidp p0) \
-    { return NAME (PV (p0)); } }
-
-#define BP_THUNK_i_pi(NAME) __unbounded { \
-  extern int NAME (void *, int); \
-  int __BP_##NAME (voidp p0, int i1) \
-    { return NAME (PV (p0), i1); } }
-
-#define BP_THUNK_i_pii(NAME) __unbounded { \
-  extern int NAME (void *, int, int); \
-  int __BP_##NAME (voidp p0, int i1, int i2) \
-    { return NAME (PV (p0), i1, i2); } }
-
-#define BP_THUNK_i_piii(NAME) __unbounded { \
-  extern int NAME (void *, int, int, int); \
-  int __BP_##NAME (voidp p0, int i1, int i2, int i3) \
-    { return NAME (PV (p0), i1, i2, i3); } }
-
-#define BP_THUNK_i_pp(NAME) __unbounded { \
-  extern int NAME (void *, void *); \
-  int __BP_##NAME (voidp p0, voidp p1) \
-    { return NAME (PV (p0), PV (p1)); } }
-
-#define BP_THUNK_i_pppi(NAME) __unbounded { \
-  extern int NAME (void *, void *, void *, int); \
-  int __BP_##NAME (voidp p0, voidp p1, voidp p2, int i3) \
-    { return NAME (PV (p0), PV (p1), PV (p2), i3); } }
-
-#define BP_THUNK_i_s(NAME) __unbounded { \
-  extern int NAME (char *); \
-  int __BP_##NAME (charp s0) \
-    { return NAME (SV (s0)); } }
-
-#define BP_THUNK_i_si(NAME) __unbounded { \
-  extern int NAME (char *, int); \
-  int __BP_##NAME (charp s0, int i1) \
-    { return NAME (SV (s0), i1); } }
-
-#define BP_THUNK_i_sii(NAME) __unbounded { \
-  extern int NAME (char *, int, int); \
-  int __BP_##NAME (charp s0, int i1, int i2) \
-    { return NAME (SV (s0), i1, i2); } }
-
-#define BP_THUNK_i_sipip(NAME) __unbounded { \
-  extern int NAME (char *, int, void *, int, void *); \
-  int __BP_##NAME (charp s0, int i1, voidp p2, int i3, voidp p4) \
-    { return NAME (SV (s0), i1, PV (p2), i3, PV (p4)); } }
-
-#define BP_THUNK_i_sp(NAME) __unbounded { \
-  extern int NAME (char *, void *); \
-  int __BP_##NAME (charp s0, voidp p1) \
-    { return NAME (SV (s0), PV (p1)); } }
-
-#define BP_THUNK_i_spi(NAME) __unbounded { \
-  extern int NAME (char *, void *, int); \
-  int __BP_##NAME (charp s0, voidp p1, int i2) \
-    { return NAME (SV (s0), PV (p1), i2); } }
-
-#define BP_THUNK_i_spp(NAME) __unbounded { \
-  extern int NAME (char *, void *, void *); \
-  int __BP_##NAME (charp s0, voidp p1, voidp p2) \
-    { return NAME (SV (s0), PV (p1), PV (p2)); } }
-
-#define BP_THUNK_i_ss(NAME) __unbounded { \
-  extern int NAME (char *, char *); \
-  int __BP_##NAME (charp s0, charp s1) \
-    { return NAME (SV (s0), s1); } }
-
-#define BP_THUNK_i_sssip(NAME) __unbounded { \
-  extern int NAME (char *, char *, char *, int, void *); \
-  int __BP_##NAME (charp s0, charp s1, charp s2, int i3, voidp p4) \
-    { return NAME (SV (s0), SV (s1), SV (s2), i3, PV (p4)); } }
-
-/* sstk */
-#define BP_THUNK_p_i(NAME) __unbounded { \
-  extern void *NAME (int); \
-  voidp __BP_##NAME (int i0) \
-    { charp m; PV (m) = PB (m) = NAME (i0); \
-      PE (m) = PV (m) + i0; return m; } }
-
-/* mremap */
-#define BP_THUNK_p_piii(NAME) __unbounded { \
-  extern void *NAME (void *, int, int, int); \
-  voidp __BP_##NAME (voidp p0, int i1, int i2, int i3) \
-    { charp m; PV (m) = PB (m) = NAME (PV (p0), i1, i2, i3); \
-      PE (m) = PV (m) + i2; return m; } }
-
-/* mmap */
-#define BP_THUNK_p_piiiii(NAME) __unbounded { \
-  extern void *NAME (void *, int, int, int, int, int); \
-  voidp __BP_##NAME (voidp p0, int i1, int i2, int i3, int i4, int i5) \
-    { charp m; PV (m) = PB (m) = NAME (PV (p0), i1, i2, i3, i4, i5); \
-      PE (m) = PV (m) + i1; return m; } }
+#include <libc-symbols.h>
+#include <bp-sym.h>
+#include <bp-checks.h>
+#include <stddef.h>
+#include <unistd.h>
+#include <sched.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <utime.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/klog.h>
+#include <sys/mman.h>
+#include <sys/mount.h>
+#include <sys/quota.h>
+#include <sys/resource.h>
+#include <sys/select.h>
+#include <sys/sendfile.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/statfs.h>
+#include <sys/swap.h>
+#include <sys/sysinfo.h>
+#include <sys/time.h>
+#include <sys/times.h>
+#include <sys/timex.h>
+#include <sys/utsname.h>
+#include <sys/vm86.h>
+#include <sys/wait.h>
 
 #endif /* _bpthunks_h_ */