Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread Moving the ssp check inside the source code d...



details:   https://anonhg.NetBSD.org/src/rev/2ab8396f245f
branches:  trunk
changeset: 761404:2ab8396f245f
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jan 26 18:11:35 2011 +0000

description:
Moving the ssp check inside the source code does not work properly because
the compiler loses information about the size of the object. So instead of
the hacky #define mess we did before, add a way to inject our function between
the user call and the system call.

diffstat:

 lib/libpthread/pthread_cancelstub.c |  37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)

diffs (78 lines):

diff -r f36f0f18f9e5 -r 2ab8396f245f lib/libpthread/pthread_cancelstub.c
--- a/lib/libpthread/pthread_cancelstub.c       Wed Jan 26 18:08:00 2011 +0000
+++ b/lib/libpthread/pthread_cancelstub.c       Wed Jan 26 18:11:35 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_cancelstub.c,v 1.29 2011/01/25 19:13:26 christos Exp $ */
+/*     $NetBSD: pthread_cancelstub.c,v 1.30 2011/01/26 18:11:35 christos Exp $ */
 
 /*-
  * Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_cancelstub.c,v 1.29 2011/01/25 19:13:26 christos Exp $");
+__RCSID("$NetBSD: pthread_cancelstub.c,v 1.30 2011/01/26 18:11:35 christos Exp $");
 
 #ifndef lint
 
@@ -50,6 +50,8 @@
  */
 #define __LIBC12_SOURCE__
 
+#define __ssp_weak_name(fun)   _cancelstub_ ## fun
+
 #include <sys/msg.h>
 #include <sys/types.h>
 #include <sys/uio.h>
@@ -59,12 +61,7 @@
 #include <mqueue.h>
 #include <poll.h>
 #include <stdarg.h>
-
-#define read _read
 #include <unistd.h>
-#undef read
-ssize_t  read(int, void *, size_t);
-
 
 #include <signal.h>
 #include <sys/mman.h>
@@ -473,16 +470,32 @@
        return retval;
 }
 
+#if _FORTIFY_SOURCE > 0
+#define STUB(fun) __ssp_weak_name(fun)
+ssize_t _sys_readlink(const char * __restrict, char * __restrict, size_t);
 ssize_t
-read(int d, void *buf, size_t nbytes)
+_cancelstub_readlink(const char * __restrict path, char * __restrict buf,
+    size_t bufsiz)
+{
+       return _sys_readlink(path, buf, bufsiz);
+}
+
+char * _sys_getcwd(char *, size_t);
+char *
+_cancelstub_getcwd(char *buf, size_t size)
+{
+       return _sys_getcwd(buf, size);
+}
+#else
+#define STUB(fun) fun
+#endif
+
+ssize_t
+STUB(read)(int d, void *buf, size_t nbytes)
 {
        ssize_t retval;
        pthread_t self;
 
-#ifdef __ssp_check
-       __ssp_check(buf, nbytes, __ssp_bos0);
-#endif
-
        self = pthread__self();
        TESTCANCEL(self);
        retval = _sys_read(d, buf, nbytes);



Home | Main Index | Thread Index | Old Index