This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch, master, updated. glibc-2.13-179-g15a856b


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  15a856b1090669df0aec536edbdf240e71a470ca (commit)
       via  05f399e63428b5129ca54f9edefbf2876f82b75c (commit)
      from  10a52685af7f060284232ce5b9c5935ca2f5c25e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=15a856b1090669df0aec536edbdf240e71a470ca

commit 15a856b1090669df0aec536edbdf240e71a470ca
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sun May 15 10:59:07 2011 -0400

    Make stack canary value harder to read through read overflow

diff --git a/ChangeLog b/ChangeLog
index ed1754d..2460648 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2011-05-15  Ulrich Drepper  <drepper@gmail.com>
 
+	[BZ #10149]
+	* sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_setup_stack_chk_guard):
+	First byte (not low byte) is now always NUL.
+	* sysdeps/generic/dl-osinfo.h (_dl_setup_stack_chk_guard): Likewise.
+
 	* sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_setup_stack_chk_guard):
 	Use non-cancelable interfaces.
 
diff --git a/NEWS b/NEWS
index e12672a..fff94be 100644
--- a/NEWS
+++ b/NEWS
@@ -9,12 +9,13 @@ Version 2.14
 
 * The following bugs are resolved with this release:
 
-  386, 9809, 11257, 11258, 11487, 11532, 11578, 11653, 11668, 11724, 11901,
-  11945, 11947, 11952, 12052, 12083, 12158, 12178, 12200, 12346, 12393,
-  12420, 12432, 12445, 12449, 12453, 12454, 12460, 12469, 12489, 12509,
-  12510, 12511, 12518, 12527, 12541, 12545, 12551, 12582, 12583, 12587,
-  12597, 12601, 12611, 12625, 12626, 12631, 12650, 12653, 12655, 12660,
-  12681, 12685, 12711, 12713, 12714, 12717, 12723, 12724, 12734, 12738
+  386, 9809, 10149, 11257, 11258, 11487, 11532, 11578, 11653, 11668, 11724,
+  11901, 11945, 11947, 11952, 12052, 12083, 12158, 12178, 12200, 12346,
+  12393, 12420, 12432, 12445, 12449, 12453, 12454, 12460, 12469, 12489,
+  12509, 12510, 12511, 12518, 12527, 12541, 12545, 12551, 12582, 12583,
+  12587, 12597, 12601, 12611, 12625, 12626, 12631, 12650, 12653, 12655,
+  12660, 12681, 12685, 12711, 12713, 12714, 12717, 12723, 12724, 12734,
+  12738
 
 * The RPC implementation in libc is obsoleted.  Old programs keep working
   but new programs cannot be linked with the routines in libc anymore.
diff --git a/sysdeps/generic/dl-osinfo.h b/sysdeps/generic/dl-osinfo.h
index 4b880da..3af064c 100644
--- a/sysdeps/generic/dl-osinfo.h
+++ b/sysdeps/generic/dl-osinfo.h
@@ -1,5 +1,5 @@
 /* Operating system specific code for generic dynamic loader functions.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2011 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
@@ -17,23 +17,35 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <endian.h>
 #include <stdint.h>
 
 static inline uintptr_t __attribute__ ((always_inline))
 _dl_setup_stack_chk_guard (void *dl_random)
 {
-  uintptr_t ret;
+  union
+  {
+    uintptr_t num;
+    unsigned char bytes[sizeof (uintptr_t)];
+  } ret = { 0 };
+
   if (dl_random == NULL)
     {
-      ret = 0;
-      unsigned char *p = (unsigned char *) &ret;
-      p[sizeof (ret) - 1] = 255;
-      p[sizeof (ret) - 2] = '\n';
-      p[0] = 0;
+      ret.bytes[sizeof (ret) - 2] = 255;
+      ret.bytes[sizeof (ret) - 3] = '\n';
     }
   else
-    memcpy (&ret, dl_random, sizeof (ret));
-  return ret;
+    {
+      memcpy (ret.bytes, dl_random, sizeof (ret));
+#if BYTE_ORDER == LITTLE_ENDIAN
+      ret.num &= ~0xff;
+#elif BYTE_ORDER == BIG_ENDIAN
+      ret.num &= ~(0xff << (8 * (sizeof (ret) - 1)));
+#else
+# error "BYTE_ORDER unknown"
+#endif
+    }
+  return ret.num;
 }
 
 static inline uintptr_t __attribute__ ((always_inline))
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index ffe5d58..eb7fedc 100644
--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -19,6 +19,7 @@
 
 #include <kernel-features.h>
 #include <dl-sysdep.h>
+#include <endian.h>
 #include <fcntl.h>
 #include <stdint.h>
 #include <not-cancel.h>
@@ -63,32 +64,46 @@ dl_fatal (const char *str)
 static inline uintptr_t __attribute__ ((always_inline))
 _dl_setup_stack_chk_guard (void *dl_random)
 {
-  uintptr_t ret;
+  union
+  {
+    uintptr_t num;
+    unsigned char bytes[sizeof (uintptr_t)];
+  } ret;
+
 #ifndef __ASSUME_AT_RANDOM
   if (__builtin_expect (dl_random == NULL, 0))
     {
+      const size_t filllen = sizeof (ret.bytes) - 1;
+      ret.num = 0;
 # ifdef ENABLE_STACKGUARD_RANDOMIZE
       int fd = open_not_cancel_2 ("/dev/urandom", O_RDONLY);
       if (fd >= 0)
 	{
-	  ssize_t reslen = read_not_cancel (fd, &ret, sizeof (ret));
+	  ssize_t reslen = read_not_cancel (fd, ret.bytes + 1, filllen);
 	  close_not_cancel_no_status (fd);
-	  if (reslen == (ssize_t) sizeof (ret))
-	    return ret;
+	  if (reslen == (ssize_) filllen)
+	    return ret.num;
 	}
 # endif
-      ret = 0;
-      unsigned char *p = (unsigned char *) &ret;
-      p[sizeof (ret) - 1] = 255;
-      p[sizeof (ret) - 2] = '\n';
+      ret.bytes[filllen - 2] = 255;
+      ret.bytes[filllen - 3] = '\n';
     }
   else
 #endif
-    /* We need in the moment only 8 bytes on 32-bit platforms and 16
-       bytes on 64-bit platforms.  Therefore we can use the data
-       directly and not use the kernel-provided data to seed a PRNG.  */
-    memcpy (&ret, dl_random, sizeof (ret));
-  return ret;
+    {
+      /* We need in the moment only 8 bytes on 32-bit platforms and 16
+	 bytes on 64-bit platforms.  Therefore we can use the data
+	 directly and not use the kernel-provided data to seed a PRNG.  */
+      memcpy (ret.bytes, dl_random, sizeof (ret));
+#if BYTE_ORDER == LITTLE_ENDIAN
+      ret.num &= ~0xff;
+#elif BYTE_ORDER == BIG_ENDIAN
+      ret.num &= ~(0xff << (8 * (sizeof (ret) - 1)));
+#else
+# error "BYTE_ORDER unknown"
+#endif
+    }
+  return ret.num;
 }
 
 static inline uintptr_t __attribute__ ((always_inline))

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=05f399e63428b5129ca54f9edefbf2876f82b75c

commit 05f399e63428b5129ca54f9edefbf2876f82b75c
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sun May 15 09:40:30 2011 -0400

    Use non-cancelable interfaces in setup code

diff --git a/ChangeLog b/ChangeLog
index f9ab6db..ed1754d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2011-05-15  Ulrich Drepper  <drepper@gmail.com>
 
+	* sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_setup_stack_chk_guard):
+	Use non-cancelable interfaces.
+
 	[BZ #9809]
 	* locale/iso-639.def: Add entry for Sorani.
 
diff --git a/sysdeps/unix/sysv/linux/dl-osinfo.h b/sysdeps/unix/sysv/linux/dl-osinfo.h
index df07869..ffe5d58 100644
--- a/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ b/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -1,5 +1,5 @@
 /* Operating system specific code for generic dynamic loader functions.  Linux.
-   Copyright (C) 2000-2002,2004-2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2000-2002,2004-2009,2011 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
@@ -21,6 +21,7 @@
 #include <dl-sysdep.h>
 #include <fcntl.h>
 #include <stdint.h>
+#include <not-cancel.h>
 
 #ifndef MIN
 # define MIN(a,b) (((a)<(b))?(a):(b))
@@ -67,11 +68,11 @@ _dl_setup_stack_chk_guard (void *dl_random)
   if (__builtin_expect (dl_random == NULL, 0))
     {
 # ifdef ENABLE_STACKGUARD_RANDOMIZE
-      int fd = __open ("/dev/urandom", O_RDONLY);
+      int fd = open_not_cancel_2 ("/dev/urandom", O_RDONLY);
       if (fd >= 0)
 	{
-	  ssize_t reslen = __read (fd, &ret, sizeof (ret));
-	  __close (fd);
+	  ssize_t reslen = read_not_cancel (fd, &ret, sizeof (ret));
+	  close_not_cancel_no_status (fd);
 	  if (reslen == (ssize_t) sizeof (ret))
 	    return ret;
 	}

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                           |    8 ++++++
 NEWS                                |   13 +++++----
 sysdeps/generic/dl-osinfo.h         |   30 +++++++++++++++------
 sysdeps/unix/sysv/linux/dl-osinfo.h |   48 +++++++++++++++++++++++-----------
 4 files changed, 68 insertions(+), 31 deletions(-)


hooks/post-receive
-- 
GNU C Library master sources


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