r4531 - in glibc-package/branches/eglibc-2.13/debian: . patches patches/any
Author: aurel32
Date: 2011-02-26 11:11:34 +0000 (Sat, 26 Feb 2011)
New Revision: 4531
Added:
glibc-package/branches/eglibc-2.13/debian/patches/any/cvs-dlopen_memory_leak.diff
glibc-package/branches/eglibc-2.13/debian/patches/any/local-relro-mprotect.diff
Removed:
glibc-package/branches/eglibc-2.13/debian/patches/any/local-relro-mprotect.patch
Modified:
glibc-package/branches/eglibc-2.13/debian/changelog
glibc-package/branches/eglibc-2.13/debian/patches/series
Log:
* Add patches/any/cvs-dlopen_memory_leak.diff to fix a memory leak
in dlopen(). Closes: #195888.
Modified: glibc-package/branches/eglibc-2.13/debian/changelog
===================================================================
--- glibc-package/branches/eglibc-2.13/debian/changelog 2011-02-26 10:40:31 UTC (rev 4530)
+++ glibc-package/branches/eglibc-2.13/debian/changelog 2011-02-26 11:11:34 UTC (rev 4531)
@@ -119,6 +119,8 @@
EGLIBC_RTLD_DEBUG support on non NPTL systems.
* Add patches/any/local-relro-mprotect.patch to not crash with PaX
kernels. Closes: #611195.
+ * Add patches/any/cvs-dlopen_memory_leak.diff to fix a memory leak
+ in dlopen(). Closes: #195888.
[ Samuel Thibault ]
* Add patches/any/cvs-glro_dl_debug_mask.diff to fix build without
Added: glibc-package/branches/eglibc-2.13/debian/patches/any/cvs-dlopen_memory_leak.diff
===================================================================
--- glibc-package/branches/eglibc-2.13/debian/patches/any/cvs-dlopen_memory_leak.diff (rev 0)
+++ glibc-package/branches/eglibc-2.13/debian/patches/any/cvs-dlopen_memory_leak.diff 2011-02-26 11:11:34 UTC (rev 4531)
@@ -0,0 +1,102 @@
+2011-02-23 Andreas Schwab <schwab@redhat.com>
+ Ulrich Drepper <drepper@gmail.com>
+
+ [BZ #12509]
+ * include/link.h (struct link_map): Add l_orig_initfini.
+ * elf/dl-load.c (_dl_map_object_from_fd): Free realname before
+ returning unsuccessfully.
+ * elf/dl-close.c (_dl_close_worker): If this is the last explicit
+ close of a file loaded at startup, restore the original l_initfini
+ list.
+ * elf/dl-deps.c (_dl_map_object_deps): Don't free old l_initfini
+ list, store the pointer.
+ * elf/Makefile ($(objpfx)noload-mem): New rule.
+ (noload-ENV): Define.
+ (tests): Add $(objpfx)noload-mem.
+ * elf/noload.c: Include <memcheck.h>.
+ (main): Call mtrace. Close all opened handles.
+
+diff --git a/elf/dl-close.c b/elf/dl-close.c
+index f6d8dd3..efb2b58 100644
+--- a/elf/dl-close.c
++++ b/elf/dl-close.c
+@@ -1,5 +1,5 @@
+ /* Close a shared object opened by `_dl_open'.
+- Copyright (C) 1996-2007, 2009, 2010 Free Software Foundation, Inc.
++ Copyright (C) 1996-2007, 2009, 2010, 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
+@@ -119,8 +119,17 @@ _dl_close_worker (struct link_map *map)
+ if (map->l_direct_opencount > 0 || map->l_type != lt_loaded
+ || dl_close_state != not_pending)
+ {
+- if (map->l_direct_opencount == 0 && map->l_type == lt_loaded)
+- dl_close_state = rerun;
++ if (map->l_direct_opencount == 0)
++ {
++ if (map->l_type == lt_loaded)
++ dl_close_state = rerun;
++ else if (map->l_type == lt_library)
++ {
++ struct link_map **oldp = map->l_initfini;
++ map->l_initfini = map->l_orig_initfini;
++ _dl_scope_free (oldp);
++ }
++ }
+
+ /* There are still references to this object. Do nothing more. */
+ if (__builtin_expect (GLRO(dl_debug_mask) & DL_DEBUG_FILES, 0))
+diff --git a/elf/dl-deps.c b/elf/dl-deps.c
+index 5288353..d3c27f1 100644
+--- a/elf/dl-deps.c
++++ b/elf/dl-deps.c
+@@ -686,5 +686,5 @@ Filters not supported with LD_TRACE_PRELINKING"));
+ _dl_scope_free (old_l_reldeps);
+ }
+ if (old_l_initfini != NULL)
+- _dl_scope_free (old_l_initfini);
++ map->l_orig_initfini = old_l_initfini;
+ }
+diff --git a/elf/dl-load.c b/elf/dl-load.c
+index 41b5ce7..1ad16a0 100644
+--- a/elf/dl-load.c
++++ b/elf/dl-load.c
+@@ -894,6 +894,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
+ {
+ /* We are not supposed to load the object unless it is already
+ loaded. So return now. */
++ free (realname);
+ __close (fd);
+ return NULL;
+ }
+@@ -912,6 +913,7 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp,
+ _dl_zerofd = _dl_sysdep_open_zero_fill ();
+ if (_dl_zerofd == -1)
+ {
++ free (realname);
+ __close (fd);
+ _dl_signal_error (errno, NULL, NULL,
+ N_("cannot open zero fill device"));
+diff --git a/include/link.h b/include/link.h
+index 9d1fc1a..e877104 100644
+--- a/include/link.h
++++ b/include/link.h
+@@ -1,6 +1,6 @@
+ /* Data structure for communication from the run-time dynamic linker for
+ loaded ELF shared objects.
+- Copyright (C) 1995-2006, 2007, 2009, 2010 Free Software Foundation, Inc.
++ Copyright (C) 1995-2006, 2007, 2009, 2010, 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
+@@ -240,6 +240,9 @@ struct link_map
+
+ /* List of object in order of the init and fini calls. */
+ struct link_map **l_initfini;
++ /* The init and fini list generated at startup, saved when the
++ object is also loaded dynamically. */
++ struct link_map **l_orig_initfini;
+
+ /* List of the dependencies introduced through symbol binding. */
+ struct link_map_reldeps
Copied: glibc-package/branches/eglibc-2.13/debian/patches/any/local-relro-mprotect.diff (from rev 4530, glibc-package/branches/eglibc-2.13/debian/patches/any/local-relro-mprotect.patch)
===================================================================
--- glibc-package/branches/eglibc-2.13/debian/patches/any/local-relro-mprotect.diff (rev 0)
+++ glibc-package/branches/eglibc-2.13/debian/patches/any/local-relro-mprotect.diff 2011-02-26 11:11:34 UTC (rev 4531)
@@ -0,0 +1,18 @@
+http://sources.redhat.com/bugzilla/show_bug.cgi?id=12492
+
+--- elf/dl-load.c
++++ elf/dl-load.c
+@@ -1398,7 +1398,11 @@
+ if (__builtin_expect (p + s <= relro_end, 1))
+ {
+ /* The variable lies in the region protected by RELRO. */
+- __mprotect ((void *) p, s, PROT_READ|PROT_WRITE);
++ if (__mprotect ((void *) p, s, PROT_READ|PROT_WRITE) < 0)
++ {
++ errstring = N_("cannot change memory protections");
++ goto call_lose_errno;
++ }
+ __stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC;
+ __mprotect ((void *) p, s, PROT_READ);
+ }
+
Deleted: glibc-package/branches/eglibc-2.13/debian/patches/any/local-relro-mprotect.patch
===================================================================
--- glibc-package/branches/eglibc-2.13/debian/patches/any/local-relro-mprotect.patch 2011-02-26 10:40:31 UTC (rev 4530)
+++ glibc-package/branches/eglibc-2.13/debian/patches/any/local-relro-mprotect.patch 2011-02-26 11:11:34 UTC (rev 4531)
@@ -1,18 +0,0 @@
-http://sources.redhat.com/bugzilla/show_bug.cgi?id=12492
-
---- elf/dl-load.c
-+++ elf/dl-load.c
-@@ -1398,7 +1398,11 @@
- if (__builtin_expect (p + s <= relro_end, 1))
- {
- /* The variable lies in the region protected by RELRO. */
-- __mprotect ((void *) p, s, PROT_READ|PROT_WRITE);
-+ if (__mprotect ((void *) p, s, PROT_READ|PROT_WRITE) < 0)
-+ {
-+ errstring = N_("cannot change memory protections");
-+ goto call_lose_errno;
-+ }
- __stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC;
- __mprotect ((void *) p, s, PROT_READ);
- }
-
Modified: glibc-package/branches/eglibc-2.13/debian/patches/series
===================================================================
--- glibc-package/branches/eglibc-2.13/debian/patches/series 2011-02-26 10:40:31 UTC (rev 4530)
+++ glibc-package/branches/eglibc-2.13/debian/patches/series 2011-02-26 11:11:34 UTC (rev 4531)
@@ -217,3 +217,5 @@
any/submitted-string2-strcmp.diff
any/cvs-glro_dl_debug_mask.diff
any/submitted-ldsodefs_rtld_debug.diff
+any/local-relro-mprotect.diff
+any/cvs-dlopen_memory_leak.diff
Reply to: