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

r5906 - in glibc-package/branches/eglibc-2.18/debian: . patches patches/powerpc



Author: adconrad
Date: 2014-01-10 17:37:25 +0000 (Fri, 10 Jan 2014)
New Revision: 5906

Added:
   glibc-package/branches/eglibc-2.18/debian/patches/powerpc/cvs-ppc64-vdso-ifunc.patch
Modified:
   glibc-package/branches/eglibc-2.18/debian/changelog
   glibc-package/branches/eglibc-2.18/debian/patches/series
Log:
debian/patches/powerpc/cvs-ppc64-vdso-ifunc.patch: New upstream fix to
squash undefined behaviour in PowerPC64 vDSO IFUNC symbol resolutions.

Modified: glibc-package/branches/eglibc-2.18/debian/changelog
===================================================================
--- glibc-package/branches/eglibc-2.18/debian/changelog	2014-01-10 17:29:16 UTC (rev 5905)
+++ glibc-package/branches/eglibc-2.18/debian/changelog	2014-01-10 17:37:25 UTC (rev 5906)
@@ -10,6 +10,8 @@
     drop buggy SSE4.2 srtstr implementations in favour of an SSE2 version.
   * debian/patches/any/cvs-ptrace_peeksiginfo_args.diff: Prepend __ prefix
     to ptrace_peeksiginfo_args struct to prevent namespace clash w/ linux.
+  * debian/patches/powerpc/cvs-ppc64-vdso-ifunc.patch: New upstream fix to
+    squash undefined behaviour in PowerPC64 vDSO IFUNC symbol resolutions.
 
   [ Aurelien Jarno ]
   * debian/patches/any/cvs-vfscanf-0e+0.diff: new patch from upstream to

Added: glibc-package/branches/eglibc-2.18/debian/patches/powerpc/cvs-ppc64-vdso-ifunc.patch
===================================================================
--- glibc-package/branches/eglibc-2.18/debian/patches/powerpc/cvs-ppc64-vdso-ifunc.patch	                        (rev 0)
+++ glibc-package/branches/eglibc-2.18/debian/patches/powerpc/cvs-ppc64-vdso-ifunc.patch	2014-01-10 17:37:25 UTC (rev 5906)
@@ -0,0 +1,86 @@
+commit 76a9b9986141b1a7d9fd290c349d27fcee780c7a
+Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
+Date:   Thu Nov 7 05:34:22 2013 -0600
+
+    PowerPC: Fix vDSO missing ODP entries
+    
+    This patch fixes the vDSO symbol used directed in IFUNC resolver where
+    they do not have an associated ODP entry leading to undefined behavior
+    in some cases. It adds an artificial OPD static entry to such cases
+    and set its TOC to non 0 to avoid triggering lazy resolutions.
+
+2013-11-08  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
+
+	* sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h (VDSO_IFUNC_RET):
+	Add artificial ODP entry for vDSO symbol for PPC64.
+	* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Adjust includes.
+	* sysdeps/unix/sysv/linux/powerpc/time.c: Likewise.
+
+diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
+index ba54de4..d189169 100644
+--- a/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
++++ b/sysdeps/unix/sysv/linux/powerpc/bits/libc-vdso.h
+@@ -41,12 +41,32 @@ extern void *__vdso_sigtramp32;
+ 
+ extern void *__vdso_time;
+ 
+-/* This macro is needed for PPC64 to return a skeleton OPD entry of a vDSO
+-   symbol.  This works because _dl_vdso_vsym always return the function
+-   address, and no vDSO symbols use the TOC or chain pointers from the OPD
+-   so we can allow them to be garbage.  */
+ #if defined(__PPC64__) || defined(__powerpc64__)
+-#define VDSO_IFUNC_RET(value)  ((void *) &(value))
++/* The correct solution is for _dl_vdso_vsym to return the address of the OPD
++   for the kernel VDSO function.  That address would then be stored in the
++   __vdso_* variables and returned as the result of the IFUNC resolver function.
++   Yet, the kernel does not contain any OPD entries for the VDSO functions
++   (incomplete implementation).  However, PLT relocations for IFUNCs still expect
++   the address of an OPD to be returned from the IFUNC resolver function (since
++   PLT entries on PPC64 are just copies of OPDs).  The solution for now is to
++   create an artificial static OPD for each VDSO function returned by a resolver
++   function.  The TOC value is set to a non-zero value to avoid triggering lazy
++   symbol resolution via .glink0/.plt0 for a zero TOC (requires thread-safe PLT
++   sequences) when the dynamic linker isn't prepared for it e.g. RTLD_NOW.  None
++   of the kernel VDSO routines use the TOC or AUX values so any non-zero value
++   will work.  Note that function pointer comparisons will not use this artificial
++   static OPD since those are resolved via ADDR64 relocations and will point at
++   the non-IFUNC default OPD for the symbol.  Lastly, because the IFUNC relocations
++   are processed immediately at startup the resolver functions and this code need
++   not be thread-safe, but if the caller writes to a PLT slot it must do so in a
++   thread-safe manner with all the required barriers.  */
++#define VDSO_IFUNC_RET(value)                            \
++  ({                                                     \
++    static Elf64_FuncDesc vdso_opd = { .fd_toc = ~0x0 }; \
++    vdso_opd.fd_func = (Elf64_Addr)value;                \
++    &vdso_opd;                                           \
++  })
++
+ #else
+ #define VDSO_IFUNC_RET(value)  ((void *) (value))
+ #endif
+diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+index 6506d75..48c3f84 100644
+--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
++++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+@@ -22,6 +22,7 @@
+ 
+ # include <dl-vdso.h>
+ # include <bits/libc-vdso.h>
++# include <dl-machine.h>
+ 
+ void *gettimeofday_ifunc (void) __asm__ ("__gettimeofday");
+ 
+diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
+index 66b4eb3..2d77ece 100644
+--- a/sysdeps/unix/sysv/linux/powerpc/time.c
++++ b/sysdeps/unix/sysv/linux/powerpc/time.c
+@@ -20,7 +20,9 @@
+ 
+ # include <time.h>
+ # include <sysdep.h>
++# include <dl-vdso.h>
+ # include <bits/libc-vdso.h>
++# include <dl-machine.h>
+ 
+ void *time_ifunc (void) asm ("time");
+ 

Modified: glibc-package/branches/eglibc-2.18/debian/patches/series
===================================================================
--- glibc-package/branches/eglibc-2.18/debian/patches/series	2014-01-10 17:29:16 UTC (rev 5905)
+++ glibc-package/branches/eglibc-2.18/debian/patches/series	2014-01-10 17:37:25 UTC (rev 5906)
@@ -178,6 +178,7 @@
 mips/cvs-prlimit64.diff
 
 powerpc/local-math-logb.diff
+powerpc/cvs-ppc64-vdso-ifunc.patch
 
 s390/submitted-nexttowardf.diff
 s390/cvs-s390-tls-got-pointer.diff


Reply to: