From schwab@redhat.com Wed Sep 1 15:29:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Wed, 01 Sep 2010 15:29:00 -0000 Subject: [PATCH] Fix handling of collating symbols in regexps Message-ID: 2010-09-01 Andreas Schwab [BZ #11561] * posix/regcomp.c (parse_bracket_exp): When looking up a collating element compare against the associated byte sequence, not its name. --- posix/regcomp.c | 72 ++++++++++++++++++++---------------------------------- 1 files changed, 27 insertions(+), 45 deletions(-) diff --git a/posix/regcomp.c b/posix/regcomp.c index 03ab123..31bd155 100644 --- a/posix/regcomp.c +++ b/posix/regcomp.c @@ -2736,40 +2736,29 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, /* Local function for parse_bracket_exp used in _LIBC environement. Seek the collating symbol entry correspondings to NAME. - Return the index of the symbol in the SYMB_TABLE. */ + Return the index of the symbol in the SYMB_TABLE, + or -1 if not found. */ auto inline int32_t __attribute ((always_inline)) - seek_collating_symbol_entry (name, name_len) - const unsigned char *name; - size_t name_len; + seek_collating_symbol_entry (const unsigned char *name, size_t name_len) { - int32_t hash = elem_hash ((const char *) name, name_len); - int32_t elem = hash % table_size; - if (symb_table[2 * elem] != 0) - { - int32_t second = hash % (table_size - 2) + 1; - - do - { - /* First compare the hashing value. */ - if (symb_table[2 * elem] == hash - /* Compare the length of the name. */ - && name_len == extra[symb_table[2 * elem + 1]] - /* Compare the name. */ - && memcmp (name, &extra[symb_table[2 * elem + 1] + 1], - name_len) == 0) - { - /* Yep, this is the entry. */ - break; - } + int32_t elem; - /* Next entry. */ - elem += second; - } - while (symb_table[2 * elem] != 0); - } - return elem; + for (elem = 0; elem < table_size; elem++) + if (symb_table[2 * elem] != 0) + { + int32_t idx = symb_table[2 * elem + 1]; + /* Skip the name of collating element name. */ + idx += 1 + extra[idx]; + if (/* Compare the length of the name. */ + name_len == extra[idx] + /* Compare the name. */ + && memcmp (name, &extra[idx + 1], name_len) == 0) + /* Yep, this is the entry. */ + return elem; + } + return -1; } /* Local function for parse_bracket_exp used in _LIBC environment. @@ -2778,8 +2767,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, auto inline unsigned int __attribute ((always_inline)) - lookup_collation_sequence_value (br_elem) - bracket_elem_t *br_elem; + lookup_collation_sequence_value (bracket_elem_t *br_elem) { if (br_elem->type == SB_CHAR) { @@ -2807,7 +2795,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, int32_t elem, idx; elem = seek_collating_symbol_entry (br_elem->opr.name, sym_name_len); - if (symb_table[2 * elem] != 0) + if (elem != -1) { /* We found the entry. */ idx = symb_table[2 * elem + 1]; @@ -2825,7 +2813,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, /* Return the collation sequence value. */ return *(unsigned int *) (extra + idx); } - else if (symb_table[2 * elem] == 0 && sym_name_len == 1) + else if (sym_name_len == 1) { /* No valid character. Match it as a single byte character. */ @@ -2847,11 +2835,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, auto inline reg_errcode_t __attribute ((always_inline)) - build_range_exp (sbcset, mbcset, range_alloc, start_elem, end_elem) - re_charset_t *mbcset; - int *range_alloc; - bitset_t sbcset; - bracket_elem_t *start_elem, *end_elem; + build_range_exp (bitset_t sbcset, re_charset_t *mbcset, int *range_alloc, + bracket_elem_t *start_elem, bracket_elem_t *end_elem) { unsigned int ch; uint32_t start_collseq; @@ -2930,25 +2915,22 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, auto inline reg_errcode_t __attribute ((always_inline)) - build_collating_symbol (sbcset, mbcset, coll_sym_alloc, name) - re_charset_t *mbcset; - int *coll_sym_alloc; - bitset_t sbcset; - const unsigned char *name; + build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset, + int *coll_sym_alloc, const unsigned char *name) { int32_t elem, idx; size_t name_len = strlen ((const char *) name); if (nrules != 0) { elem = seek_collating_symbol_entry (name, name_len); - if (symb_table[2 * elem] != 0) + if (elem != -1) { /* We found the entry. */ idx = symb_table[2 * elem + 1]; /* Skip the name of collating element name. */ idx += 1 + extra[idx]; } - else if (symb_table[2 * elem] == 0 && name_len == 1) + else if (name_len == 1) { /* No valid character, treat it as a normal character. */ -- 1.7.2.2 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Fri Sep 10 10:15:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Fri, 10 Sep 2010 10:15:00 -0000 Subject: [PATCH] Work around shortest-stem feature in make 3.82+ Message-ID: make 3.82+ no longer selects pattern rules by order, but by shortest stem, so we need to add more rules to make sure we still get the right matches. Andreas. 2010-09-09 Andreas Schwab * Makeconfig (sysd-rules-patterns): Add rtld-%:rtld-%. (sysd-rules-targets): Remove duplicates. * elf/rtld-Rules ($(objpfx)rtld-%.os): Add pattern rules with rtld-%.$o dependency. --- Makeconfig | 6 +++--- elf/rtld-Rules | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Makeconfig b/Makeconfig index 9778998..807c1d1 100644 --- a/Makeconfig +++ b/Makeconfig @@ -966,7 +966,7 @@ endif # emitted into sysd-rules. A sysdeps Makeconfig fragment can # add its own special object file prefix to this list with e.g. foo-%:% # to have foo-*.? compiled from *.? using $(foo-CPPFLAGS). -sysd-rules-patterns := %:% rtld-%:% m_%:s_% +sysd-rules-patterns := %:% rtld-%:rtld-% rtld-%:% m_%:s_% # Let sysdeps/ subdirs contain a Makeconfig fragment for us to include here. sysdep-makeconfigs := $(wildcard $(+sysdep_dirs:=/Makeconfig)) @@ -975,8 +975,8 @@ include $(sysdep-makeconfigs) endif # Compute just the target patterns. Makeconfig has set sysd-rules-patterns. -sysd-rules-targets := $(foreach p,$(sysd-rules-patterns),\ - $(firstword $(subst :, ,$p))) +sysd-rules-targets := $(sort $(foreach p,$(sysd-rules-patterns),\ + $(firstword $(subst :, ,$p)))) endif # Makeconfig not yet included diff --git a/elf/rtld-Rules b/elf/rtld-Rules index 9f31a56..fc225f2 100644 --- a/elf/rtld-Rules +++ b/elf/rtld-Rules @@ -93,6 +93,12 @@ else # These are the basic compilation rules corresponding to the Makerules ones. # The sysd-rules generated makefile already defines pattern rules for rtld-% # targets built from sysdeps source files. +$(objpfx)rtld-%.os: rtld-%.S $(before-compile) + $(compile-command.S) $(rtld-CPPFLAGS) +$(objpfx)rtld-%.os: rtld-%.s $(before-compile) + $(compile-command.s) $(rtld-CPPFLAGS) +$(objpfx)rtld-%.os: rtld-%.c $(before-compile) + $(compile-command.c) $(rtld-CPPFLAGS) $(objpfx)rtld-%.os: %.S $(before-compile) $(compile-command.S) $(rtld-CPPFLAGS) $(objpfx)rtld-%.os: %.s $(before-compile) @@ -101,6 +107,9 @@ $(objpfx)rtld-%.os: %.c $(before-compile) $(compile-command.c) $(rtld-CPPFLAGS) # The rules for generated source files. +$(objpfx)rtld-%.os: $(objpfx)rtld-%.S $(before-compile); $(compile-command.S) +$(objpfx)rtld-%.os: $(objpfx)rtld-%.s $(before-compile); $(compile-command.s) +$(objpfx)rtld-%.os: $(objpfx)rtld-%.c $(before-compile); $(compile-command.c) $(objpfx)rtld-%.os: $(objpfx)%.S $(before-compile); $(compile-command.S) $(objpfx)rtld-%.os: $(objpfx)%.s $(before-compile); $(compile-command.s) $(objpfx)rtld-%.os: $(objpfx)%.c $(before-compile); $(compile-command.c) -- 1.7.2.2 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From roland@redhat.com Fri Sep 10 10:34:00 2010 From: roland@redhat.com (Roland McGrath) Date: Fri, 10 Sep 2010 10:34:00 -0000 Subject: [PATCH] Work around shortest-stem feature in make 3.82+ In-Reply-To: Andreas Schwab's message of Friday, 10 September 2010 12:15:35 +0200 References: Message-ID: <20100910103412.41A8E405D5@magilla.sf.frob.com> > make 3.82+ no longer selects pattern rules by order, but by shortest > stem, so we need to add more rules to make sure we still get the right > matches. Sweet mother of god, what is that guy thinking? I shudder to think at all the subtle breakage introduced to makefile magic that has worked the same for 20 years now. He's kind of making me regret choosing him as maintainer. Even I have a hard time figuring out what exactly this dismal change could mean for complex uses of pattern rules like we have. From schwab@redhat.com Fri Sep 10 11:11:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Fri, 10 Sep 2010 11:11:00 -0000 Subject: [PATCH] Work around shortest-stem feature in make 3.82+ In-Reply-To: <20100910103412.41A8E405D5@magilla.sf.frob.com> (Roland McGrath's message of "Fri, 10 Sep 2010 03:34:12 -0700 (PDT)") References: <20100910103412.41A8E405D5@magilla.sf.frob.com> Message-ID: You can add your comments to . Andreas. -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Mon Sep 13 07:41:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Mon, 13 Sep 2010 07:41:00 -0000 Subject: [PATCH] Don't try to free rpath strings allocated during startup Message-ID: The stub malloc from dl-minimal.c is used during all of startup until ld.so is re-relocated, so the rpath string allocated so far cannot be freed in the freeres routine. Andreas. 2010-09-13 Andreas Schwab * elf/rtld.c (dl_main): Set GLRO(dl_init_all_dirs) just before re-relocationg ld.so. --- elf/rtld.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/elf/rtld.c b/elf/rtld.c index 80fe0ab..2e266b1 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -2287,6 +2287,10 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", lossage); } + /* Remember the last search directory added at startup, now that + malloc will no longer be the one from dl-minimal.c. */ + GLRO(dl_init_all_dirs) = GL(dl_all_dirs); + if (! prelinked && rtld_multiple_ref) { /* There was an explicit ref to the dynamic linker as a shared lib. -- 1.7.2.2 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Wed Sep 15 08:50:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Wed, 15 Sep 2010 08:50:00 -0000 Subject: [PATCH] Fix register conflict in s390 ____longjmp_chk Message-ID: r1-r3 are call-clobbered registers so CHECK_SP might clobber them. Andreas. 2010-09-14 Andreas Schwab * sysdeps/s390/s390-32/__longjmp.c (__longjmp): Define register variables after CHECK_SP call. * sysdeps/s390/s390-64/__longjmp.c (__longjmp): Likewise. --- sysdeps/s390/s390-32/__longjmp.c | 13 ++++++++----- sysdeps/s390/s390-64/__longjmp.c | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/sysdeps/s390/s390-32/__longjmp.c b/sysdeps/s390/s390-32/__longjmp.c index 4abc0ec..95f8b71 100644 --- a/sysdeps/s390/s390-32/__longjmp.c +++ b/sysdeps/s390/s390-32/__longjmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2000, 2001, 2005, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2000, 2001, 2005, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). @@ -29,16 +29,19 @@ void __longjmp (__jmp_buf env, int val) { - register int r2 __asm ("%r2") = val == 0 ? 1 : val; #ifdef PTR_DEMANGLE - register uintptr_t r3 __asm ("%r3") = THREAD_GET_POINTER_GUARD (); - register void *r1 __asm ("%r1") = (void *) env; + uintptr_t guard = THREAD_GET_POINTER_GUARD (); # ifdef CHECK_SP - CHECK_SP (env, r3); + CHECK_SP (env, guard); # endif #elif defined CHECK_SP CHECK_SP (env, 0); #endif + register int r2 __asm ("%r2") = val == 0 ? 1 : val; +#ifdef PTR_DEMANGLE + register uintptr_t r3 __asm ("%r3") = guard; + register void *r1 __asm ("%r1") = (void *) env; +#endif /* Restore registers and jump back. */ asm volatile ("ld %%f6,48(%1)\n\t" "ld %%f4,40(%1)\n\t" diff --git a/sysdeps/s390/s390-64/__longjmp.c b/sysdeps/s390/s390-64/__longjmp.c index 445bd3b..313b338 100644 --- a/sysdeps/s390/s390-64/__longjmp.c +++ b/sysdeps/s390/s390-64/__longjmp.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001, 2005, 2009 Free Software Foundation, Inc. +/* Copyright (C) 2001, 2005, 2009, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). @@ -29,16 +29,19 @@ void __longjmp (__jmp_buf env, int val) { - register long int r2 __asm ("%r2") = val == 0 ? 1 : val; #ifdef PTR_DEMANGLE - register uintptr_t r3 __asm ("%r3") = THREAD_GET_POINTER_GUARD (); - register void *r1 __asm ("%r1") = (void *) env; + uintptr_t guard = THREAD_GET_POINTER_GUARD (); # ifdef CHECK_SP - CHECK_SP (env, r3); + CHECK_SP (env, guard); # endif #elif defined CHECK_SP CHECK_SP (env, 0); #endif + register long int r2 __asm ("%r2") = val == 0 ? 1 : val; +#ifdef PTR_DEMANGLE + register uintptr_t r3 __asm ("%r3") = guard; + register void *r1 __asm ("%r1") = (void *) env; +#endif /* Restore registers and jump back. */ asm volatile ("ld %%f7,104(%1)\n\t" "ld %%f5,96(%1)\n\t" -- 1.7.2.2 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Fri Sep 17 09:09:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Fri, 17 Sep 2010 09:09:00 -0000 Subject: [PATCH] Move freeres function from ld.so to libc.so Message-ID: dl-close.c isn't included in libc.so, so the freeres function is never executed. Andreas. 2010-09-16 Andreas Schwab * elf/dl-close.c (free_slotinfo, free_mem): Move to... * elf/dl-libc.c (free_slotinfo, free_mem): ... here. --- elf/dl-close.c | 74 ---------------------------------------- elf/dl-libc.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 87 insertions(+), 90 deletions(-) diff --git a/elf/dl-close.c b/elf/dl-close.c index 5b54e9f..9bd91e3 100644 --- a/elf/dl-close.c +++ b/elf/dl-close.c @@ -755,77 +755,3 @@ _dl_close (void *_map) __rtld_lock_unlock_recursive (GL(dl_load_lock)); } - - -static bool __libc_freeres_fn_section -free_slotinfo (struct dtv_slotinfo_list **elemp) -{ - size_t cnt; - - if (*elemp == NULL) - /* Nothing here, all is removed (or there never was anything). */ - return true; - - if (!free_slotinfo (&(*elemp)->next)) - /* We cannot free the entry. */ - return false; - - /* That cleared our next pointer for us. */ - - for (cnt = 0; cnt < (*elemp)->len; ++cnt) - if ((*elemp)->slotinfo[cnt].map != NULL) - /* Still used. */ - return false; - - /* We can remove the list element. */ - free (*elemp); - *elemp = NULL; - - return true; -} - - -libc_freeres_fn (free_mem) -{ - for (Lmid_t nsid = 0; nsid < GL(dl_nns); ++nsid) - if (__builtin_expect (GL(dl_ns)[nsid]._ns_global_scope_alloc, 0) != 0 - && (GL(dl_ns)[nsid]._ns_main_searchlist->r_nlist - // XXX Check whether we need NS-specific initial_searchlist - == GLRO(dl_initial_searchlist).r_nlist)) - { - /* All object dynamically loaded by the program are unloaded. Free - the memory allocated for the global scope variable. */ - struct link_map **old = GL(dl_ns)[nsid]._ns_main_searchlist->r_list; - - /* Put the old map in. */ - GL(dl_ns)[nsid]._ns_main_searchlist->r_list - // XXX Check whether we need NS-specific initial_searchlist - = GLRO(dl_initial_searchlist).r_list; - /* Signal that the original map is used. */ - GL(dl_ns)[nsid]._ns_global_scope_alloc = 0; - - /* Now free the old map. */ - free (old); - } - - if (USE___THREAD || GL(dl_tls_dtv_slotinfo_list) != NULL) - { - /* Free the memory allocated for the dtv slotinfo array. We can do - this only if all modules which used this memory are unloaded. */ -#ifdef SHARED - if (GL(dl_initial_dtv) == NULL) - /* There was no initial TLS setup, it was set up later when - it used the normal malloc. */ - free_slotinfo (&GL(dl_tls_dtv_slotinfo_list)); - else -#endif - /* The first element of the list does not have to be deallocated. - It was allocated in the dynamic linker (i.e., with a different - malloc), and in the static library it's in .bss space. */ - free_slotinfo (&GL(dl_tls_dtv_slotinfo_list)->next); - } - - void *scope_free_list = GL(dl_scope_free_list); - GL(dl_scope_free_list) = NULL; - free (scope_free_list); -} diff --git a/elf/dl-libc.c b/elf/dl-libc.c index 5e303f2..771c9c1 100644 --- a/elf/dl-libc.c +++ b/elf/dl-libc.c @@ -1,5 +1,5 @@ /* Handle loading and unloading shared objects for internal libc purposes. - Copyright (C) 1999-2002,2004,2005,2006,2009 Free Software Foundation, Inc. + Copyright (C) 1999-2002,2004-2006,2009,2010 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Zack Weinberg , 1999. @@ -221,6 +221,34 @@ __libc_dlclose (void *map) libc_hidden_def (__libc_dlclose) +static bool __libc_freeres_fn_section +free_slotinfo (struct dtv_slotinfo_list **elemp) +{ + size_t cnt; + + if (*elemp == NULL) + /* Nothing here, all is removed (or there never was anything). */ + return true; + + if (!free_slotinfo (&(*elemp)->next)) + /* We cannot free the entry. */ + return false; + + /* That cleared our next pointer for us. */ + + for (cnt = 0; cnt < (*elemp)->len; ++cnt) + if ((*elemp)->slotinfo[cnt].map != NULL) + /* Still used. */ + return false; + + /* We can remove the list element. */ + free (*elemp); + *elemp = NULL; + + return true; +} + + libc_freeres_fn (free_mem) { struct link_map *l; @@ -235,20 +263,63 @@ libc_freeres_fn (free_mem) free (old); } - /* Remove all additional names added to the objects. */ for (Lmid_t ns = 0; ns < GL(dl_nns); ++ns) - for (l = GL(dl_ns)[ns]._ns_loaded; l != NULL; l = l->l_next) - { - struct libname_list *lnp = l->l_libname->next; - - l->l_libname->next = NULL; - - while (lnp != NULL) - { - struct libname_list *old = lnp; - lnp = lnp->next; - if (! old->dont_free) - free (old); - } - } + { + /* Remove all additional names added to the objects. */ + for (l = GL(dl_ns)[ns]._ns_loaded; l != NULL; l = l->l_next) + { + struct libname_list *lnp = l->l_libname->next; + + l->l_libname->next = NULL; + + while (lnp != NULL) + { + struct libname_list *old = lnp; + lnp = lnp->next; + if (! old->dont_free) + free (old); + } + } + + if (__builtin_expect (GL(dl_ns)[ns]._ns_global_scope_alloc, 0) != 0 + && (GL(dl_ns)[ns]._ns_main_searchlist->r_nlist + // XXX Check whether we need NS-specific initial_searchlist + == GLRO(dl_initial_searchlist).r_nlist)) + { + /* All object dynamically loaded by the program are unloaded. Free + the memory allocated for the global scope variable. */ + struct link_map **old = GL(dl_ns)[ns]._ns_main_searchlist->r_list; + + /* Put the old map in. */ + GL(dl_ns)[ns]._ns_main_searchlist->r_list + // XXX Check whether we need NS-specific initial_searchlist + = GLRO(dl_initial_searchlist).r_list; + /* Signal that the original map is used. */ + GL(dl_ns)[ns]._ns_global_scope_alloc = 0; + + /* Now free the old map. */ + free (old); + } + } + + if (USE___THREAD || GL(dl_tls_dtv_slotinfo_list) != NULL) + { + /* Free the memory allocated for the dtv slotinfo array. We can do + this only if all modules which used this memory are unloaded. */ +#ifdef SHARED + if (GL(dl_initial_dtv) == NULL) + /* There was no initial TLS setup, it was set up later when + it used the normal malloc. */ + free_slotinfo (&GL(dl_tls_dtv_slotinfo_list)); + else +#endif + /* The first element of the list does not have to be deallocated. + It was allocated in the dynamic linker (i.e., with a different + malloc), and in the static library it's in .bss space. */ + free_slotinfo (&GL(dl_tls_dtv_slotinfo_list)->next); + } + + void *scope_free_list = GL(dl_scope_free_list); + GL(dl_scope_free_list) = NULL; + free (scope_free_list); } -- 1.7.2.3 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Mon Sep 20 08:36:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Mon, 20 Sep 2010 08:36:00 -0000 Subject: [PATCH] Add support for fanotify_mark on sparc32 and s390 Message-ID: On both Sparc and S390 the arguments for functions and syscalls are passed in the same way. Andreas. 2010-09-20 Andreas Schwab * sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Add fanotify_mark * sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list: Likewise. --- sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list | 1 + .../unix/sysv/linux/sparc/sparc32/syscalls.list | 1 + 2 files changed, 2 insertions(+), 0 deletions(-) diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list index d3a05d2..e946d33 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list +++ b/sysdeps/unix/sysv/linux/s390/s390-32/syscalls.list @@ -5,3 +5,4 @@ oldsetrlimit EXTRA setrlimit i:ip __old_setrlimit setrlimit@GLIBC_2.0 vfork - vfork 0 __vfork vfork prlimit64 EXTRA prlimit64 i:iipp prlimit64 +fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list index 8b1d682..3d70185 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list @@ -6,3 +6,4 @@ getresuid - getresuid32 3 getresuid getresgid - getresgid32 3 getresgid prlimit64 EXTRA prlimit64 i:iipp prlimit64 +fanotify_mark EXTRA fanotify_mark i:iiiiis fanotify_mark -- 1.7.2.3 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Tue Sep 21 14:10:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Tue, 21 Sep 2010 14:10:00 -0000 Subject: [PATCH] Fix namespace pollution in pthread_cleanup_push Message-ID: 2010-09-21 Andreas Schwab * sysdeps/pthread/pthread.h (pthread_cleanup_push) [!__EXCEPTIONS]: Mangle local variable not_first_call. (pthread_cleanup_push_defer_np): Likewise. --- nptl/sysdeps/pthread/pthread.h | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nptl/sysdeps/pthread/pthread.h b/nptl/sysdeps/pthread/pthread.h index 44cf9f0..4c83665 100644 --- a/nptl/sysdeps/pthread/pthread.h +++ b/nptl/sysdeps/pthread/pthread.h @@ -650,9 +650,9 @@ __pthread_cleanup_routine (struct __pthread_cleanup_frame *__frame) __pthread_unwind_buf_t __cancel_buf; \ void (*__cancel_routine) (void *) = (routine); \ void *__cancel_arg = (arg); \ - int not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \ - __cancel_buf.__cancel_jmp_buf, 0); \ - if (__builtin_expect (not_first_call, 0)) \ + int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \ + __cancel_buf.__cancel_jmp_buf, 0); \ + if (__builtin_expect (__not_first_call, 0)) \ { \ __cancel_routine (__cancel_arg); \ __pthread_unwind_next (&__cancel_buf); \ @@ -685,9 +685,9 @@ extern void __pthread_unregister_cancel (__pthread_unwind_buf_t *__buf) __pthread_unwind_buf_t __cancel_buf; \ void (*__cancel_routine) (void *) = (routine); \ void *__cancel_arg = (arg); \ - int not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \ - __cancel_buf.__cancel_jmp_buf, 0); \ - if (__builtin_expect (not_first_call, 0)) \ + int __not_first_call = __sigsetjmp ((struct __jmp_buf_tag *) (void *) \ + __cancel_buf.__cancel_jmp_buf, 0); \ + if (__builtin_expect (__not_first_call, 0)) \ { \ __cancel_routine (__cancel_arg); \ __pthread_unwind_next (&__cancel_buf); \ -- 1.7.2.3 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Wed Sep 22 13:03:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Wed, 22 Sep 2010 13:03:00 -0000 Subject: [PATCH] Fix memory leak on init/fini dependency list Message-ID: valgrind reports a memory leak when a program dlopens a library already loaded as a direct dependency. In this case the l_initfini memory allocated in _dl_map_object_deps is not freed because dlclose won't unload the library. On the other hand we must not free the memory allocated by the dummy malloc, so keep a flag whether the initfini memory was allocated during startup. Andreas. 2010-09-22 Andreas Schwab * include/link.h (struct link_map): Add l_free_initfini. * elf/dl-deps.c (_dl_map_object_deps): Set it when assigning l_initfini. * elf/rtld.c (dl_main): Clear it on all objects loaded on startup. * elf/dl-libc.c (free_mem): Free l_initfini if l_free_initfini is set. --- elf/dl-deps.c | 2 ++ elf/dl-libc.c | 6 +++++- elf/rtld.c | 1 + include/link.h | 3 +++ 4 files changed, 11 insertions(+), 1 deletions(-) diff --git a/elf/dl-deps.c b/elf/dl-deps.c index a58de5c..e5b9cdf 100644 --- a/elf/dl-deps.c +++ b/elf/dl-deps.c @@ -478,6 +478,7 @@ _dl_map_object_deps (struct link_map *map, nneeded * sizeof needed[0]); atomic_write_barrier (); l->l_initfini = l_initfini; + l->l_free_initfini = 1; } /* If we have no auxiliary objects just go on to the next map. */ @@ -662,6 +663,7 @@ Filters not supported with LD_TRACE_PRELINKING")); l_initfini[nlist] = NULL; atomic_write_barrier (); map->l_initfini = l_initfini; + map->l_free_initfini = 1; if (l_reldeps != NULL) { atomic_write_barrier (); diff --git a/elf/dl-libc.c b/elf/dl-libc.c index 7be9483..a13fce3 100644 --- a/elf/dl-libc.c +++ b/elf/dl-libc.c @@ -265,13 +265,13 @@ libc_freeres_fn (free_mem) for (Lmid_t ns = 0; ns < GL(dl_nns); ++ns) { - /* Remove all additional names added to the objects. */ for (l = GL(dl_ns)[ns]._ns_loaded; l != NULL; l = l->l_next) { struct libname_list *lnp = l->l_libname->next; l->l_libname->next = NULL; + /* Remove all additional names added to the objects. */ while (lnp != NULL) { struct libname_list *old = lnp; @@ -279,6 +279,10 @@ libc_freeres_fn (free_mem) if (! old->dont_free) free (old); } + + /* Free the initfini dependency list. */ + if (l->l_free_initfini) + free (l->l_initfini); } if (__builtin_expect (GL(dl_ns)[ns]._ns_global_scope_alloc, 0) != 0 diff --git a/elf/rtld.c b/elf/rtld.c index 2e266b1..9a560b3 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -2240,6 +2240,7 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", lnp->dont_free = 1; lnp = lnp->next; } + l->l_free_initfini = 0; if (l != &GL(dl_rtld_map)) _dl_relocate_object (l, l->l_scope, GLRO(dl_lazy) ? RTLD_LAZY : 0, diff --git a/include/link.h b/include/link.h index 9d1fc1a..051b99a 100644 --- a/include/link.h +++ b/include/link.h @@ -192,6 +192,9 @@ struct link_map during LD_TRACE_PRELINKING=1 contains any DT_SYMBOLIC libraries. */ + unsigned int l_free_initfini:1; /* Nonzero if l_initfini can be + freed, ie. not allocated with + the dummy malloc in ld.so. */ /* Collected information about own RPATH directories. */ struct r_search_path_struct l_rpath_dirs; -- 1.7.2.3 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Wed Sep 22 15:00:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Wed, 22 Sep 2010 15:00:00 -0000 Subject: [PATCH] Fix memory leak on init/fini dependency list In-Reply-To: (Ulrich Drepper's message of "Wed, 22 Sep 2010 07:12:15 -0700") References: Message-ID: Ulrich Drepper writes: > On Wed, Sep 22, 2010 at 06:03, Andreas Schwab wrote: >> valgrind reports a memory leak when a program dlopens a library already >> loaded as a direct dependency > > Test case?! #include #include #include int main (int argc, char **argv) { void *handle = dlopen ("libc.so.6", RTLD_LAZY); if (!handle) { fprintf (stderr, "%s\n", dlerror ()); return 1; } dlclose (handle); } Andreas. -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Mon Sep 27 14:26:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Mon, 27 Sep 2010 14:26:00 -0000 Subject: [PATCH] Properly convert f_fsid in statvfs Message-ID: 2010-09-27 Andreas Schwab [BZ #11611] * sysdeps/unix/sysv/linux/internal_statvfs.c (INTERNAL_STATVFS): Mask out sign-bit copies when constructing f_fsid. --- sysdeps/unix/sysv/linux/internal_statvfs.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/sysdeps/unix/sysv/linux/internal_statvfs.c b/sysdeps/unix/sysv/linux/internal_statvfs.c index 0169ae3..83ffb99 100644 --- a/sysdeps/unix/sysv/linux/internal_statvfs.c +++ b/sysdeps/unix/sysv/linux/internal_statvfs.c @@ -228,7 +228,8 @@ INTERNAL_STATVFS (const char *name, struct STATVFS *buf, buf->f_files = fsbuf->f_files; buf->f_ffree = fsbuf->f_ffree; if (sizeof (buf->f_fsid) == sizeof (fsbuf->f_fsid)) - buf->f_fsid = (fsbuf->f_fsid.__val[0] + buf->f_fsid = ((fsbuf->f_fsid.__val[0] + & ((1UL << (8 * sizeof (fsbuf->f_fsid.__val[0]))) - 1)) | ((unsigned long int) fsbuf->f_fsid.__val[1] << (8 * (sizeof (buf->f_fsid) - sizeof (fsbuf->f_fsid.__val[0]))))); -- 1.7.2.3 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different." From schwab@redhat.com Tue Sep 28 13:14:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Tue, 28 Sep 2010 13:14:00 -0000 Subject: [PATCH] Don't try to write to _rtld_global_ro after performing relro protection Message-ID: 2010-09-28 Andreas Schwab * elf/rtld.c (dl_main): Move setting of GLRO(dl_init_all_dirs) before performing relro protection. --- elf/rtld.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/elf/rtld.c b/elf/rtld.c index 9a560b3..201c9cf 100644 --- a/elf/rtld.c +++ b/elf/rtld.c @@ -2168,6 +2168,10 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", we need it in the memory handling later. */ GLRO(dl_initial_searchlist) = *GL(dl_ns)[LM_ID_BASE]._ns_main_searchlist; + /* Remember the last search directory added at startup, now that + malloc will no longer be the one from dl-minimal.c. */ + GLRO(dl_init_all_dirs) = GL(dl_all_dirs); + if (prelinked) { if (main_map->l_info [ADDRIDX (DT_GNU_CONFLICT)] != NULL) @@ -2288,10 +2292,6 @@ ERROR: ld.so: object '%s' cannot be loaded as audit interface: %s; ignored.\n", lossage); } - /* Remember the last search directory added at startup, now that - malloc will no longer be the one from dl-minimal.c. */ - GLRO(dl_init_all_dirs) = GL(dl_all_dirs); - if (! prelinked && rtld_multiple_ref) { /* There was an explicit ref to the dynamic linker as a shared lib. -- 1.7.2.3 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different."