This is the mail archive of the libc-alpha@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]

[2.16] [PATCH] Skip audit if l_reloc_result is NULL


Hi,

This patch backports the fix for BZ #14831, which is a 2.16 regression
from 2.15. Tested on x32 and ia32.  OK for 2.16 branch?  This patch also
needs backporting:

http://sourceware.org/git/?p=glibc.git;a=commit;h=e510ab5efff3450b723dbe71734e8b22be14d1c6
http://sourceware.org/git/?p=glibc.git;a=commit;h=d072f3f7724d85ceaf230806660235f0cf2f9c3b

for glibc-ports 2.16 branch.

H.J.
---
Cherry-pick commit 2e64d2659d3edaebc792ac596a9863f1626e5c25

Conflicts:
	ChangeLog
	NEWS
---
 ChangeLog        | 13 +++++++++++++
 NEWS             |  2 +-
 elf/Makefile     |  6 +++++-
 elf/dl-runtime.c | 22 +++++++++++++++++++++-
 elf/tst-audit8.c |  1 +
 5 files changed, 41 insertions(+), 3 deletions(-)
 create mode 100644 elf/tst-audit8.c

diff --git a/ChangeLog b/ChangeLog
index 66817c9..368ede1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2012-11-14  H.J. Lu  <hongjiu.lu@intel.com>
+
+	[BZ #14831]
+	* elf/Makefile (tests): Add tst-audit8.
+	($(objpfx)tst-audit8): Also depend on $(common-objpfx)math/libm.so.
+	($(objpfx)tst-audit8.out): New target.
+	(tst-audit8-ENV): New variable.
+	* elf/dl-runtime.c (_dl_profile_fixup): Call _dl_fixup to skip
+	audit if l_reloc_result is NULL.
+	(ELF_MACHINE_RUNTIME_FIXUP_PARAMS): Issue an error if it isn't
+	defined and ELF_MACHINE_RUNTIME_FIXUP_ARGS is defined.
+	* elf/tst-audit8.c: New file.
+
 2012-11-07  Andreas Jaeger  <aj@suse.de>
 
 	[BZ #14809]
diff --git a/NEWS b/NEWS
index 459553b..81af41d 100644
--- a/NEWS
+++ b/NEWS
@@ -9,7 +9,7 @@ Version 2.16.1
 
 * The following bugs are resolved with this release:
 
-  6530, 14195, 14459, 14476, 14562, 14621, 14648, 14756, 14809
+  6530, 14195, 14459, 14476, 14562, 14621, 14648, 14756, 14809, 14865
 
 Version 2.16
 
diff --git a/elf/Makefile b/elf/Makefile
index 0c26ce5..a621a1c 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -138,7 +138,7 @@ tests += loadtest restest1 preloadtest loadfail multiload origtest resolvfail \
 	 tst-dlmodcount tst-dlopenrpath tst-deep1 \
 	 tst-dlmopen1 tst-dlmopen2 tst-dlmopen3 \
 	 unload3 unload4 unload5 unload6 unload7 unload8 tst-global1 order2 \
-	 tst-audit1 tst-audit2 \
+	 tst-audit1 tst-audit2 tst-audit8 \
 	 tst-stackguard1 tst-addr1 tst-thrlock \
 	 tst-unique1 tst-unique2 tst-unique3 tst-unique4 \
 	 tst-initorder tst-initorder2 tst-relsort1
@@ -1024,6 +1024,10 @@ $(objpfx)tst-audit7: $(objpfx)tst-auditmod7a.so
 $(objpfx)tst-audit7.out: $(objpfx)tst-auditmod7b.so
 tst-audit7-ENV = LD_AUDIT=$(objpfx)tst-auditmod7b.so
 
+$(objpfx)tst-audit8: $(common-objpfx)math/libm.so
+$(objpfx)tst-audit8.out: $(objpfx)tst-auditmod1.so
+tst-audit8-ENV = LD_AUDIT=$(objpfx)tst-auditmod1.so
+
 $(objpfx)tst-global1: $(libdl)
 $(objpfx)tst-global1.out: $(objpfx)testobj6.so $(objpfx)testobj2.so
 
diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index fdaa364..009d366 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -1,5 +1,5 @@
 /* On-demand PLT fixup for shared objects.
-   Copyright (C) 1995-2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1995-2012 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
@@ -168,6 +168,26 @@ _dl_profile_fixup (
 {
   void (*mcount_fct) (ElfW(Addr), ElfW(Addr)) = INTUSE(_dl_mcount);
 
+  if (l->l_reloc_result == NULL)
+    {
+      /* BZ #14843: ELF_DYNAMIC_RELOCATE is called before l_reloc_result
+	 is allocated.  We will get here if ELF_DYNAMIC_RELOCATE calls a
+	 resolver function to resolve an IRELATIVE relocation and that
+	 resolver calls a function that is not yet resolved (lazy).  For
+	 example, the resolver in x86-64 libm.so calls __get_cpu_features
+	 defined in libc.so.  Skip audit and resolve the external function
+	 in this case.  */
+      *framesizep = -1;
+      return _dl_fixup (
+# ifdef ELF_MACHINE_RUNTIME_FIXUP_ARGS
+#  ifndef ELF_MACHINE_RUNTIME_FIXUP_PARAMS
+#   error Please define ELF_MACHINE_RUNTIME_FIXUP_PARAMS.
+#  endif
+			ELF_MACHINE_RUNTIME_FIXUP_PARAMS,
+# endif
+			l, reloc_arg);
+    }
+
   /* This is the address in the array where we store the result of previous
      relocations.  */
   struct reloc_result *reloc_result = &l->l_reloc_result[reloc_index];
diff --git a/elf/tst-audit8.c b/elf/tst-audit8.c
new file mode 100644
index 0000000..63656b4
--- /dev/null
+++ b/elf/tst-audit8.c
@@ -0,0 +1 @@
+#include "../io/pwd.c"
-- 
1.7.11.7


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