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

[commits] r12350 - in /fsf/trunk/libc: ./ elf/ sysdeps/i386/ sysdeps/ia64/ sysdeps/powerpc/ sysdeps/s390/ sysdeps/sh/ sysdeps/sparc/ s...



Author: eglibc
Date: Mon Dec 20 00:03:26 2010
New Revision: 12350

Log:
Import glibc-mainline for 2010-12-20

Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/elf/Makefile
    fsf/trunk/libc/elf/check-execstack.c
    fsf/trunk/libc/elf/dl-load.c
    fsf/trunk/libc/elf/dl-support.c
    fsf/trunk/libc/elf/rtld.c
    fsf/trunk/libc/sysdeps/i386/stackinfo.h
    fsf/trunk/libc/sysdeps/ia64/stackinfo.h
    fsf/trunk/libc/sysdeps/powerpc/stackinfo.h
    fsf/trunk/libc/sysdeps/s390/stackinfo.h
    fsf/trunk/libc/sysdeps/sh/stackinfo.h
    fsf/trunk/libc/sysdeps/sparc/stackinfo.h
    fsf/trunk/libc/sysdeps/unix/readdir_r.c
    fsf/trunk/libc/sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c
    fsf/trunk/libc/sysdeps/x86_64/stackinfo.h

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Mon Dec 20 00:03:26 2010
@@ -1,6 +1,35 @@
+2010-12-15  Ryan S. Arnold  <rsa@xxxxxxxxxx>
+
+	* elf/Makefile: (check-execstack): Replace $(native-compile) with a
+	similar rule which adds the sysdep directories to the header search in
+	order to pick up the correct platform stackinfo.h.
+	* elf/check-execstack.c (main): Check DEFAULT_STACK_PERMS for PF_X and
+	perform test if it is, otherwise return successfully without testing.
+	* elf/dl-load.c (_dl_map_object_from_fd): Source stack_flags from
+	DEFAULT_STACK_PERMS define in stackinfo.h.
+	* elf/dl-support.c (_dl_stack_flags): Source from DEFAULT_STACK_PERMS
+	defined in stackinfo.h.
+	* elf/rtld.c (_dl_starting_up): Source ._dl_stack_flags from
+	DEFAULT_STACK_PERMS defined in stackinfo.h.
+	* sysdeps/i386/stackinfo.h: Define DEFAULT_STACK_PERMS with PF_X.
+	* sysdeps/ia64/stackinfo.h: Likewise.
+	* sysdeps/s390/stackinfo.h: Likewise.
+	* sysdeps/sh/stackinfo.h: Likewise.
+	* sysdeps/sparc/stackinfo.h: Likewise.
+	* sysdeps/x86_64/stackinfo.h: Likewise.
+	* sysdeps/powerpc/stackinfo.h: Define DEFAULT_STACK_PERMS without
+	PF_X for powerpc64.  Retain PF_X for powerpc32.
+
+2010-12-19  Ulrich Drepper  <drepper@xxxxxxxxx>
+
+	* sysdeps/unix/readdir_r.c (__READDIR_R): Compute reclen more
+	accurately.
+	* sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c: Define
+	GETDENTS_64BIT_ALIGNED.
+
 2010-12-14  Ulrich Drepper  <dreper@xxxxxxxxx>
 
-	* sysdeps/i386/i686/multiarch/strcmp.S: Undo accident checkin.
+	* sysdeps/i386/i686/multiarch/strcmp.S: Undo accidental checkin.
 
 2010-12-10  Andreas Schwab  <schwab@xxxxxxxxxx>
 

Modified: fsf/trunk/libc/elf/Makefile
==============================================================================
--- fsf/trunk/libc/elf/Makefile (original)
+++ fsf/trunk/libc/elf/Makefile Mon Dec 20 00:03:26 2010
@@ -899,8 +899,14 @@
 	$(native-compile)
 
 check-execstack-CFLAGS = -O -Wall -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -std=gnu99
+# Perform the same operation as $(native-compile) but add the sysdeps
+# directories as header search locations.
 $(objpfx)check-execstack: check-execstack.c
-	$(native-compile)
+	$(make-target-directory)
+	$(patsubst %/,cd % &&,$(objpfx)) \
+	$(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) \
+	$(addprefix -I$(shell pwd)/,$(sysdirs)) -I$(shell pwd) \
+	$(firstword $(filter /%,$< $(shell pwd)/$<)) -o $(@F)
 
 check-localplt-CFLAGS = -O -Wall -D_GNU_SOURCE -std=gnu99
 $(objpfx)check-localplt: check-localplt.c

Modified: fsf/trunk/libc/elf/check-execstack.c
==============================================================================
--- fsf/trunk/libc/elf/check-execstack.c (original)
+++ fsf/trunk/libc/elf/check-execstack.c Mon Dec 20 00:03:26 2010
@@ -1,5 +1,5 @@
 /* Check for executable stacks in DSOs.
-   Copyright (C) 2009 Free Software Foundation, Inc.
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contribute by Ulrich Drepper <drepper@xxxxxxxxxx>. 2009.
 
@@ -26,6 +26,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <stackinfo.h>
 
 
 #ifdef BITS
@@ -150,9 +151,13 @@
   int cnt;
   int result = 0;
 
-  for (cnt = 1; cnt < argc; ++cnt)
-    result |= handle_file (argv[cnt]);
-
+  /* We can return successfully, i.e., not fail, if PF_X isn't present.  If it
+   * is present then check for the GNU_STACK header.  */
+  if (DEFAULT_STACK_PERMS & PF_X)
+    {
+      for (cnt = 1; cnt < argc; ++cnt)
+	result |= handle_file (argv[cnt]);
+     }
   return result;
 }
 #endif

Modified: fsf/trunk/libc/elf/dl-load.c
==============================================================================
--- fsf/trunk/libc/elf/dl-load.c (original)
+++ fsf/trunk/libc/elf/dl-load.c Mon Dec 20 00:03:26 2010
@@ -984,8 +984,10 @@
 	}
     }
 
-  /* Presumed absent PT_GNU_STACK.  */
-  uint_fast16_t stack_flags = PF_R|PF_W|PF_X;
+   /* On most platforms presume that PT_GNU_STACK is absent and the stack is
+    * executable.  Other platforms default to a nonexecutable stack and don't
+    * need PT_GNU_STACK to do so.  */
+   uint_fast16_t stack_flags = DEFAULT_STACK_PERMS;
 
   {
     /* Scan the program header table, collecting its load commands.  */

Modified: fsf/trunk/libc/elf/dl-support.c
==============================================================================
--- fsf/trunk/libc/elf/dl-support.c (original)
+++ fsf/trunk/libc/elf/dl-support.c Mon Dec 20 00:03:26 2010
@@ -32,6 +32,7 @@
 #include <dl-procinfo.h>
 #include <unsecvars.h>
 #include <hp-timing.h>
+#include <stackinfo.h>
 
 extern char *__progname;
 char **_dl_argv = &__progname;	/* This is checked for some error messages.  */
@@ -134,8 +135,9 @@
    setting _dl_hwcap nonzero below, but we do anyway.  */
 uint64_t _dl_hwcap_mask __attribute__ ((nocommon));
 
-/* Prevailing state of the stack, PF_X indicating it's executable.  */
-ElfW(Word) _dl_stack_flags = PF_R|PF_W|PF_X;
+/* Prevailing state of the stack.  Generally this includes PF_X, indicating it's
+ * executable but this isn't true for all platforms.  */
+ElfW(Word) _dl_stack_flags = DEFAULT_STACK_PERMS;
 
 /* If loading a shared object requires that we make the stack executable
    when it was not, we do it by calling this function.

Modified: fsf/trunk/libc/elf/rtld.c
==============================================================================
--- fsf/trunk/libc/elf/rtld.c (original)
+++ fsf/trunk/libc/elf/rtld.c Mon Dec 20 00:03:26 2010
@@ -40,6 +40,7 @@
 #include <dl-osinfo.h>
 #include <dl-procinfo.h>
 #include <tls.h>
+#include <stackinfo.h>
 
 #include <assert.h>
 
@@ -122,8 +123,9 @@
    (except those which cannot be added for some reason).  */
 struct rtld_global _rtld_global =
   {
-    /* Default presumption without further information is executable stack.  */
-    ._dl_stack_flags = PF_R|PF_W|PF_X,
+    /* Generally the default presumption without further information is an
+     * executable stack but this is not true for all platforms.  */
+    ._dl_stack_flags = DEFAULT_STACK_PERMS,
 #ifdef _LIBC_REENTRANT
     ._dl_load_lock = _RTLD_LOCK_RECURSIVE_INITIALIZER,
     ._dl_load_write_lock = _RTLD_LOCK_RECURSIVE_INITIALIZER,

Modified: fsf/trunk/libc/sysdeps/i386/stackinfo.h
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/stackinfo.h (original)
+++ fsf/trunk/libc/sysdeps/i386/stackinfo.h Mon Dec 20 00:03:26 2010
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2009, 2010 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
@@ -22,8 +22,14 @@
 #ifndef _STACKINFO_H
 #define _STACKINFO_H	1
 
+#include <elf.h>
+
 /* On x86 the stack grows down.  */
 #define _STACK_GROWS_DOWN	1
+
+/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
+ * present, but it is presumed absent.  */
+#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
 
 /* Access to the stack pointer.  The macros are used in alloca_account
    for which they need to act as barriers as well, hence the additional

Modified: fsf/trunk/libc/sysdeps/ia64/stackinfo.h
==============================================================================
--- fsf/trunk/libc/sysdeps/ia64/stackinfo.h (original)
+++ fsf/trunk/libc/sysdeps/ia64/stackinfo.h Mon Dec 20 00:03:26 2010
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2010 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
@@ -22,8 +22,14 @@
 #ifndef _STACKINFO_H
 #define _STACKINFO_H	1
 
+#include <elf.h>
+
 /* On IA-64 the stack grows down.  The register stack is of no concern
    here.  */
 #define _STACK_GROWS_DOWN	1
 
+/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
+ * present, but it is presumed absent.  */
+#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
+
 #endif	/* stackinfo.h */

Modified: fsf/trunk/libc/sysdeps/powerpc/stackinfo.h
==============================================================================
--- fsf/trunk/libc/sysdeps/powerpc/stackinfo.h (original)
+++ fsf/trunk/libc/sysdeps/powerpc/stackinfo.h Mon Dec 20 00:03:26 2010
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2010 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
@@ -22,7 +22,18 @@
 #ifndef _STACKINFO_H
 #define _STACKINFO_H	1
 
+#include <elf.h>
+
 /* On PPC the stack grows down.  */
 #define _STACK_GROWS_DOWN	1
 
+#if __WORDSIZE == 64
+/* PPC64 doesn't need an executable stack and doesn't need PT_GNU_STACK
+ * to make the stack nonexecutable.  */
+# define DEFAULT_STACK_PERMS (PF_R|PF_W)
+#else
+/* PF_X can be overridden if PT_GNU_STACK is present but is presumed absent.  */
+# define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
+#endif
+
 #endif	/* stackinfo.h */

Modified: fsf/trunk/libc/sysdeps/s390/stackinfo.h
==============================================================================
--- fsf/trunk/libc/sysdeps/s390/stackinfo.h (original)
+++ fsf/trunk/libc/sysdeps/s390/stackinfo.h Mon Dec 20 00:03:26 2010
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2010 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
@@ -22,7 +22,13 @@
 #ifndef _STACKINFO_H
 #define _STACKINFO_H	1
 
+#include <elf.h>
+
 /* On s390 the stack grows down.  */
 #define _STACK_GROWS_DOWN	1
 
+/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
+ * present, but it is presumed absent.  */
+#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
+
 #endif	/* stackinfo.h */

Modified: fsf/trunk/libc/sysdeps/sh/stackinfo.h
==============================================================================
--- fsf/trunk/libc/sysdeps/sh/stackinfo.h (original)
+++ fsf/trunk/libc/sysdeps/sh/stackinfo.h Mon Dec 20 00:03:26 2010
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2010 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
@@ -22,7 +22,13 @@
 #ifndef _STACKINFO_H
 #define _STACKINFO_H	1
 
+#include <elf.h>
+
 /* On SH the stack grows down.  */
 #define _STACK_GROWS_DOWN	1
 
+/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
+ * present, but it is presumed absent.  */
+#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
+
 #endif	/* stackinfo.h */

Modified: fsf/trunk/libc/sysdeps/sparc/stackinfo.h
==============================================================================
--- fsf/trunk/libc/sysdeps/sparc/stackinfo.h (original)
+++ fsf/trunk/libc/sysdeps/sparc/stackinfo.h Mon Dec 20 00:03:26 2010
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2010 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
@@ -22,7 +22,13 @@
 #ifndef _STACKINFO_H
 #define _STACKINFO_H	1
 
+#include <elf.h>
+
 /* On sparc the stack grows down.  */
 #define _STACK_GROWS_DOWN	1
 
+/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
+ * present, but it is presumed absent.  */
+#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
+
 #endif	/* stackinfo.h */

Modified: fsf/trunk/libc/sysdeps/unix/readdir_r.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/readdir_r.c (original)
+++ fsf/trunk/libc/sysdeps/unix/readdir_r.c Mon Dec 20 00:03:26 2010
@@ -117,7 +117,8 @@
 #ifdef GETDENTS_64BIT_ALIGNED
       /* The d_reclen value might include padding which is not part of
 	 the DIRENT_TYPE data structure.  */
-      reclen = MIN (reclen, sizeof (DIRENT_TYPE));
+      reclen = MIN (reclen,
+		    offsetof (DIRENT_TYPE, d_name) + sizeof (dp->d_name));
 #endif
       *result = memcpy (entry, dp, reclen);
 #ifdef GETDENTS_64BIT_ALIGNED

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/wordsize-64/readdir_r.c Mon Dec 20 00:03:26 2010
@@ -1,4 +1,5 @@
 #define readdir64_r __no_readdir64_r_decl
+#define GETDENTS_64BIT_ALIGNED 1
 #include <sysdeps/unix/readdir_r.c>
 #undef readdir64_r
 weak_alias (__readdir_r, readdir64_r)

Modified: fsf/trunk/libc/sysdeps/x86_64/stackinfo.h
==============================================================================
--- fsf/trunk/libc/sysdeps/x86_64/stackinfo.h (original)
+++ fsf/trunk/libc/sysdeps/x86_64/stackinfo.h Mon Dec 20 00:03:26 2010
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2009 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2009, 2010 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
@@ -22,8 +22,14 @@
 #ifndef _STACKINFO_H
 #define _STACKINFO_H	1
 
+#include <elf.h>
+
 /* On x86_64 the stack grows down.  */
 #define _STACK_GROWS_DOWN	1
+
+/* Default to an executable stack.  PF_X can be overridden if PT_GNU_STACK is
+ * present, but it is presumed absent.  */
+#define DEFAULT_STACK_PERMS (PF_R|PF_W|PF_X)
 
 /* Access to the stack pointer.  The macros are used in alloca_account
    for which they need to act as barriers as well, hence the additional