From schwab@redhat.com Tue Mar 2 15:55:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Tue, 02 Mar 2010 15:55:00 -0000 Subject: [PATCH] Fix setxid race with thread creation Message-ID: When setxid runs in the time window between allocating a thread stack and cloning the new thread this thread does not receive the setxid signal and remains at the wrong xid. Andreas. 2010-03-02 Andreas Schwab * allocatestack.c (get_cached_stack): Initialize setxid_futex to -1. (allocate_stack): Likewise. (setxid_mark_thread): Wait for setxid_futex != -1. * sysdeps/pthread/createthread.c (do_clone): Set setxid_futex after cloning. diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 3c3585f..88f9574 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -213,6 +213,9 @@ get_cached_stack (size_t *sizep, void **memp) return NULL; } + /* Don't allow setxid until cloned. */ + result->setxid_futex = -1; + /* Dequeue the entry. */ stack_list_del (&result->list); @@ -418,6 +421,9 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* The process ID is also the same as that of the caller. */ pd->pid = THREAD_GETMEM (THREAD_SELF, pid); + /* Don't allow setxid until cloned. */ + pd->setxid_futex = -1; + /* Allocate the DTV for this thread. */ if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL) { @@ -557,6 +563,9 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp, /* The process ID is also the same as that of the caller. */ pd->pid = THREAD_GETMEM (THREAD_SELF, pid); + /* Don't allow setxid until cloned. */ + pd->setxid_futex = -1; + /* Allocate the DTV for this thread. */ if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL) { @@ -969,6 +978,10 @@ setxid_mark_thread (struct xid_command *cmdp, struct pthread *t) { int ch; + /* Wait until this thread is cloned. */ + while (t->setxid_futex == -1) + lll_futex_wait (&t->setxid_futex, -1, LLL_PRIVATE); + /* Don't let the thread exit before the setxid handler runs. */ t->setxid_futex = 0; diff --git a/nptl/sysdeps/pthread/createthread.c b/nptl/sysdeps/pthread/createthread.c index 66fafe8..d176bad 100644 --- a/nptl/sysdeps/pthread/createthread.c +++ b/nptl/sysdeps/pthread/createthread.c @@ -52,6 +52,8 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, int clone_flags, int (*fct) (void *), STACK_VARIABLES_PARMS, int stopped) { + int rc; + #ifdef PREPARE_CREATE PREPARE_CREATE; #endif @@ -72,8 +74,14 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr, that cares whether the thread count is correct. */ atomic_increment (&__nptl_nthreads); - if (ARCH_CLONE (fct, STACK_VARIABLES_ARGS, clone_flags, - pd, &pd->tid, TLS_VALUE, &pd->tid) == -1) + rc = ARCH_CLONE (fct, STACK_VARIABLES_ARGS, clone_flags, + pd, &pd->tid, TLS_VALUE, &pd->tid); + + /* Allow setxid from now onwards. */ + pd->setxid_futex = 0; + lll_futex_wake (&pd->setxid_futex, 1, LLL_PRIVATE); + + if (rc == -1) { atomic_decrement (&__nptl_nthreads); /* Oops, we lied for a second. */ -- 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 drepper@redhat.com Fri Mar 5 19:25:00 2010 From: drepper@redhat.com (Ulrich Drepper) Date: Fri, 05 Mar 2010 19:25:00 -0000 Subject: [PATCH] Fix setxid race with thread creation In-Reply-To: References: Message-ID: <4B915A84.2080707@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I've checked in a modified version of the patch. There are some optimizations and a problem with the created thread not waking the setxid thread. Please test it. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEYEARECAAYFAkuRWoQACgkQ2ijCOnn/RHR86QCfca6jl2lukw/deyorckXJJeXA 7W4An2gIqWqQ+nz8iEZsj89r1iuOtKl+ =qG4B -----END PGP SIGNATURE----- From schwab@redhat.com Mon Mar 8 13:57:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Mon, 08 Mar 2010 13:57:00 -0000 Subject: [PATCH] Fix setxid race with thread creation In-Reply-To: <4B915A84.2080707@redhat.com> (Ulrich Drepper's message of "Fri, 05 Mar 2010 11:24:52 -0800") References: <4B915A84.2080707@redhat.com> Message-ID: Ulrich Drepper writes: > I've checked in a modified version of the patch. There are some > optimizations and a problem with the created thread not waking the > setxid thread. Please test it. It does not work at all. 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 drepper@redhat.com Tue Mar 9 06:06:00 2010 From: drepper@redhat.com (Ulrich Drepper) Date: Tue, 09 Mar 2010 06:06:00 -0000 Subject: [PATCH] Fix setxid race with thread creation In-Reply-To: References: <4B915A84.2080707@redhat.com> Message-ID: <4B95E542.1080604@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 03/08/2010 05:57 AM, Andreas Schwab wrote: > It does not work at all. You have to be more specific. I ran the test case in the BZ for 4 hours without any problem. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iEUEARECAAYFAkuV5UIACgkQ2ijCOnn/RHQzIgCXXUZpIGyg86oNgV5+6Cy1rCG4 LgCguccmPa5bJd9qJhkgG/OTfaGBgj0= =TQTw -----END PGP SIGNATURE----- From schwab@redhat.com Tue Mar 9 10:14:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Tue, 09 Mar 2010 10:14:00 -0000 Subject: [PATCH] Fix setxid race with thread creation In-Reply-To: <4B95E542.1080604@redhat.com> (Ulrich Drepper's message of "Mon, 08 Mar 2010 22:05:54 -0800") References: <4B915A84.2080707@redhat.com> <4B95E542.1080604@redhat.com> Message-ID: Ulrich Drepper writes: > On 03/08/2010 05:57 AM, Andreas Schwab wrote: >> It does not work at all. > > You have to be more specific. It does not fix the bug in any way. > I ran the test case in the BZ for 4 hours without any problem. Which test case? 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 Fri Mar 12 09:45:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Fri, 12 Mar 2010 09:45:00 -0000 Subject: [PATCH] Don't underestimate length of DST substitution Message-ID: 2010-03-12 Andreas Schwab * elf/dl-dst.h: Include "trusted-dirs.h". (DL_DST_REQUIRED): Take $LIB into account. --- elf/dl-dst.h | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/elf/dl-dst.h b/elf/dl-dst.h index 76076a6..81be8be 100644 --- a/elf/dl-dst.h +++ b/elf/dl-dst.h @@ -18,6 +18,8 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ +#include "trusted-dirs.h" + /* Determine the number of DST elements in the name. Only if IS_PATH is nonzero paths are recognized (i.e., multiple, ':' separated filenames). */ #define DL_DST_COUNT(name, is_path) \ @@ -39,12 +41,13 @@ \ if (__cnt > 0) \ { \ - size_t origin_len; \ + size_t dst_len; \ /* Now we make a guess how many extra characters on top of the \ length of S we need to represent the result. We know that \ we have CNT replacements. Each at most can use \ - MAX (strlen (ORIGIN), strlen (_dl_platform)) \ - minus 7 (which is the length of "$ORIGIN"). \ + MAX (MAX (strlen (ORIGIN), strlen (_dl_platform)), \ + strlen (DL_DST_LIB)) \ + minus 4 (which is the length of "$LIB"). \ \ First get the origin string if it is not available yet. \ This can only happen for the map of the executable. */ \ @@ -53,14 +56,16 @@ { \ assert ((l)->l_name[0] == '\0'); \ (l)->l_origin = _dl_get_origin (); \ - origin_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \ + dst_len = ((l)->l_origin && (l)->l_origin != (char *) -1 \ ? strlen ((l)->l_origin) : 0); \ } \ else \ - origin_len = (l)->l_origin == (char *) -1 \ + dst_len = (l)->l_origin == (char *) -1 \ ? 0 : strlen ((l)->l_origin); \ - \ - __len += __cnt * (MAX (origin_len, GLRO(dl_platformlen)) - 7); \ + dst_len = MAX (MAX (dst_len, GLRO(dl_platformlen)), \ + strlen (DL_DST_LIB)); \ + if (dst_len > 4) \ + __len += __cnt * (dst_len - 4); \ } \ \ __len; }) @@ -72,7 +77,7 @@ if ((l) == NULL) \ { \ const char *origin = _dl_get_origin (); \ - origin_len = (origin && origin != (char *) -1 ? strlen (origin) : 0); \ + dst_len = (origin && origin != (char *) -1 ? strlen (origin) : 0); \ } \ else #endif -- 1.7.0.1 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 Tue Mar 16 15:26:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Tue, 16 Mar 2010 15:26:00 -0000 Subject: [PATCH] Fix debug statements in resolver Message-ID: * resolv/res_send.c (__libc_res_nsend): Fix printing of server address in debug statement. (send_dg): Pass correct buffer pointer to DprintQ. --- resolv/res_send.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/resolv/res_send.c b/resolv/res_send.c index b0966ae..845b658 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -535,7 +535,10 @@ __libc_res_nsend(res_state statp, const u_char *buf, int buflen, Dprint(statp->options & RES_DEBUG, (stdout, ";; Querying server (# %d) address = %s\n", - ns + 1, inet_ntop(AF_INET6, &nsap->sin6_addr, + ns + 1, inet_ntop(nsap->sin6_family, + (nsap->sin6_family == AF_INET6 + ? &nsap->sin6_addr + : &((struct sockaddr_in *) nsap)->sin_addr), tmpbuf, sizeof (tmpbuf)))); if (__builtin_expect (v_circuit, 0)) { @@ -1201,7 +1204,7 @@ send_dg(res_state statp, DprintQ((statp->options & RES_DEBUG) || (statp->pfcode & RES_PRF_REPLY), (stdout, ";; old answer:\n"), - thisansp, + *thisansp, (*thisresplenp > *thisanssizp) ? *thisanssizp : *thisresplenp); goto wait; @@ -1216,7 +1219,7 @@ send_dg(res_state statp, DprintQ((statp->options & RES_DEBUG) || (statp->pfcode & RES_PRF_REPLY), (stdout, ";; not our server:\n"), - thisansp, + *thisansp, (*thisresplenp > *thisanssizp) ? *thisanssizp : *thisresplenp); goto wait; @@ -1233,7 +1236,7 @@ send_dg(res_state statp, DprintQ(statp->options & RES_DEBUG, (stdout, "server rejected query with EDNS0:\n"), - thisansp, + *thisansp, (*thisresplenp > *thisanssizp) ? *thisanssizp : *thisresplenp); /* record the error */ @@ -1258,7 +1261,7 @@ send_dg(res_state statp, DprintQ((statp->options & RES_DEBUG) || (statp->pfcode & RES_PRF_REPLY), (stdout, ";; wrong query name:\n"), - thisansp, + *thisansp, (*thisresplenp > *thisanssizp) ? *thisanssizp : *thisresplenp); goto wait; @@ -1268,7 +1271,7 @@ send_dg(res_state statp, anhp->rcode == REFUSED) { DprintQ(statp->options & RES_DEBUG, (stdout, "server rejected query:\n"), - thisansp, + *thisansp, (*thisresplenp > *thisanssizp) ? *thisanssizp : *thisresplenp); @@ -1295,7 +1298,7 @@ send_dg(res_state statp, && anhp->aa == 0 && anhp->ra == 0 && anhp->arcount == 0) { DprintQ(statp->options & RES_DEBUG, (stdout, "referred query:\n"), - thisansp, + *thisansp, (*thisresplenp > *thisanssizp) ? *thisanssizp : *thisresplenp); goto next_ns; -- 1.7.0.1 -- 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 Mar 16 17:17:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Tue, 16 Mar 2010 17:17:00 -0000 Subject: [PATCH] Don't reject name server due to empty answer Message-ID: The resolver rejects a name server when it responds with an empty reply (both AA and RA flags cleared) like this: $ dig aaaa @134.178.14.1 www.bom.gov.au. ; <<>> DiG 9.6.1-P3-RedHat-9.6.1-16.P3.fc12 <<>> aaaa @134.178.14.1 www.bom.gov.au. ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58652 ;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;www.bom.gov.au. IN AAAA This only happens when using UDP, the TCP query code happily accepts that as a negative reply. Andreas. * resolv/res_send.c (send_dg): Don't reject name server due to empty answer. --- resolv/res_send.c | 9 --------- 1 files changed, 0 insertions(+), 9 deletions(-) diff --git a/resolv/res_send.c b/resolv/res_send.c index 845b658..d164b55 100644 --- a/resolv/res_send.c +++ b/resolv/res_send.c @@ -1294,15 +1294,6 @@ send_dg(res_state statp, if (!statp->pfcode) return (0); } - if (anhp->rcode == NOERROR && anhp->ancount == 0 - && anhp->aa == 0 && anhp->ra == 0 && anhp->arcount == 0) { - DprintQ(statp->options & RES_DEBUG, - (stdout, "referred query:\n"), - *thisansp, - (*thisresplenp > *thisanssizp) - ? *thisanssizp : *thisresplenp); - goto next_ns; - } if (!(statp->options & RES_IGNTC) && anhp->tc) { /* * To get the rest of answer, -- 1.7.0.1 -- 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 drepper@redhat.com Wed Mar 17 14:20:00 2010 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 17 Mar 2010 14:20:00 -0000 Subject: [PATCH] Don't reject name server due to empty answer In-Reply-To: References: Message-ID: <4BA0E52C.8060701@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 03/16/2010 10:17 AM, Andreas Schwab wrote: > The resolver rejects a name server when it responds with an empty reply > (both AA and RA flags cleared) like this: This code was added for a reason: https://bugzilla.redhat.com/show_bug.cgi?id=162625 Why should this be reverted? Yes, the TCP code should likely be fixed up as well but that's a different story. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAkug5SwACgkQ2ijCOnn/RHRvPACeKkzg3lXy7czgzn7M24IoEAdu 6iIAn3THopqQmmooHpKZVvjeGaklSqqE =5G4u -----END PGP SIGNATURE----- From schwab@redhat.com Mon Mar 22 15:14:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Mon, 22 Mar 2010 15:14:00 -0000 Subject: [PATCH] Fix glob with empty pattern and patterns ending in slash Message-ID: * posix/glob.c (glob): Match only directories when pattern ends in a slash. Return no match when pattern is empty. --- posix/glob.c | 46 ++++++++-------------------------------------- 1 files changed, 8 insertions(+), 38 deletions(-) diff --git a/posix/glob.c b/posix/glob.c index 73081ec..ab1c63f 100644 --- a/posix/glob.c +++ b/posix/glob.c @@ -489,44 +489,6 @@ glob (pattern, flags, errfunc, pglob) *((char *) mempcpy (newp, pattern, dirlen)) = '\0'; dirname = newp; ++filename; - - if (filename[0] == '\0' -#if defined __MSDOS__ || defined WINDOWS32 - && dirname[dirlen - 1] != ':' - && (dirlen < 3 || dirname[dirlen - 2] != ':' - || dirname[dirlen - 1] != '/') -#endif - && dirlen > 1) - /* "pattern/". Expand "pattern", appending slashes. */ - { - int orig_flags = flags; - if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\') - { - /* "pattern\\/". Remove the final backslash if it hasn't - been quoted. */ - char *p = (char *) &dirname[dirlen - 1]; - - while (p > dirname && p[-1] == '\\') --p; - if ((&dirname[dirlen] - p) & 1) - { - *(char *) &dirname[--dirlen] = '\0'; - flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC); - } - } - int val = glob (dirname, flags | GLOB_MARK, errfunc, pglob); - if (val == 0) - pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK) - | (flags & GLOB_MARK)); - else if (val == GLOB_NOMATCH && flags != orig_flags) - { - /* Make sure globfree (&dirs); is a nop. */ - dirs.gl_pathv = NULL; - flags = orig_flags; - oldcount = pglob->gl_pathc + pglob->gl_offs; - goto no_matches; - } - return val; - } } if (!(flags & GLOB_APPEND)) @@ -549,6 +511,14 @@ glob (pattern, flags, errfunc, pglob) oldcount = pglob->gl_pathc + pglob->gl_offs; + /* An empty pattern cannot match any file name. */ + if (pattern[0] == '\0') + { + /* Make sure globfree (&dirs); is a nop. */ + dirs.gl_pathv = NULL; + goto no_matches; + } + #ifndef VMS if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~') { -- 1.7.0.1 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 jakub@redhat.com Tue Mar 23 10:34:00 2010 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 23 Mar 2010 10:34:00 -0000 Subject: [PATCH] Fix handling of STB_GNU_UNIQUE in LD_TRACE_PRELINKING Message-ID: <20100323103348.GE3601@sunsite.ms.mff.cuni.cz> Hi! The STB_GNU_UNIQUE hash table breaks computation of conflicts during LD_TRACE_PRELINKING, thus prelink doesn't add relocations into .gnu.conflict section and programs might misbehave at runtime when prelinked. The problem is that to detect a conflict, _dl_debug_bindings in addition to the normal lookup does also a lookup in undef_map->l_local_scope[0], and if the lookup has different result, reports a conflict, otherwise just non-conflicting lookup. But, as STB_GNU_UNIQUE hash table for such symbols always gives the first lookup that entered the hash table, conflicts are never reported for STB_GNU_UNIQUE lookups. Attached are two possible patches. The second, shorter one, is all that is needed currently (I believe). The difference between the patches is in handling libraries with DT_SYMBOLIC and STB_GNU_UNIQUE symbols. Apparently current GNU ld if there is a relocation against STB_GNU_UNIQUE symbol defined in the library itself, doesn't emit any relocation and resolves at link time (possibly through a relative relocation). Is that what we want though? Then the STB_GNU_UNIQUE symbols aren't really unique... If we want to change ld(1) behavior to always emit dynamic relocations against STB_GNU_UNIQUE symbols defined in the library even for -Wl,-Bsymbolic, then I'm afraid we need something like the former patch. It can be pessimizing, reporting a conflict even when there is really none, but I don't see how else to do this cheaply. And, -Wl,-Bsymbolic is very rare I believe, so I don't care about that too much. Jakub -------------- next part -------------- 2010-03-23 Jakub Jelinek * elf/dl-lookup.c (do_lookup_x): If tab->entries is NULL, but tab->size != 0, just unlock and goto success, without allocating anything or entering anything into the hash table. (_dl_debug_bindings): Temporarily set tab->entries to NULL around do_lookup_x in undef_map->l_local_scope[0]. If undef_map->l_symbolic_in_local_scope, lookup also in symbolic_searchlist of following libraries in l_local_scope that have DT_SYMBOLIC set. * elf/dl-deps.c (_dl_map_object_deps): Compute l_symbolic_in_local_scope. * include/link.h (struct link_map): Add l_symbolic_in_local_scope bitfield. --- libc/elf/dl-deps.c.jj 2009-05-16 19:23:29.000000000 +0200 +++ libc/elf/dl-deps.c 2010-03-23 09:24:57.000000000 +0100 @@ -1,5 +1,5 @@ /* Load the dependencies of a mapped object. - Copyright (C) 1996-2003, 2004, 2005, 2006, 2007 + Copyright (C) 1996-2003, 2004, 2005, 2006, 2007, 2010 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -554,7 +554,12 @@ Filters not supported with LD_TRACE_PREL cnt = _dl_build_local_scope (l_initfini, l); assert (cnt <= nlist); for (j = 0; j < cnt; j++) - l_initfini[j]->l_reserved = 0; + { + l_initfini[j]->l_reserved = 0; + if (j && __builtin_expect (l_initfini[j]->l_info[DT_SYMBOLIC] + != NULL, 0)) + l->l_symbolic_in_local_scope = true; + } l->l_local_scope[0] = (struct r_scope_elem *) malloc (sizeof (struct r_scope_elem) --- libc/elf/dl-lookup.c.jj 2009-12-16 00:10:37.000000000 +0100 +++ libc/elf/dl-lookup.c 2010-03-23 10:00:35.000000000 +0100 @@ -1,5 +1,6 @@ /* Look up a symbol in the loaded objects. - Copyright (C) 1995-2005, 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 1995-2005, 2006, 2007, 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 @@ -414,6 +415,20 @@ do_lookup_x (const char *undef_name, uin assert (!RTLD_CHECK_FOREIGN_CALL); #endif +#ifdef SHARED + /* If tab->entries is NULL, but tab->size is not, it means + this is the second, conflict finding, lookup for + LD_TRACE_PRELINKING in _dl_debug_bindings. Don't + allocate anything and don't enter anything into the + hash table. */ + if (__builtin_expect (tab->size, 0)) + { + assert (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK); + __rtld_lock_unlock_recursive (tab->lock); + goto success; + } +#endif + #define INITIAL_NUNIQUE_SYM_TABLE 31 size = INITIAL_NUNIQUE_SYM_TABLE; entries = calloc (sizeof (struct unique_sym), size); @@ -917,13 +932,48 @@ _dl_debug_bindings (const char *undef_na { const uint_fast32_t new_hash = dl_new_hash (undef_name); unsigned long int old_hash = 0xffffffff; + struct unique_sym *saved_entries + = GL(dl_ns)[LM_ID_BASE]._ns_unique_sym_table.entries; + GL(dl_ns)[LM_ID_BASE]._ns_unique_sym_table.entries = NULL; do_lookup_x (undef_name, new_hash, &old_hash, *ref, &val, undef_map->l_local_scope[0], 0, version, 0, NULL, type_class, undef_map); - if (val.s != value->s || val.m != value->m) conflict = 1; + else if (__builtin_expect (undef_map->l_symbolic_in_local_scope, 0) + && val.s + && __builtin_expect (ELFW(ST_BIND) (val.s->st_info), + STB_GLOBAL) == STB_GNU_UNIQUE) + { + /* If it is STB_GNU_UNIQUE and undef_map's l_local_scope + contains any DT_SYMBOLIC libraries, unfortunately there + can be conflicts even if the above is equal. As symbol + resolution goes from the last library to the first and + if a STB_GNU_UNIQUE symbol is found in some late DT_SYMBOLIC + library, it would be the one that is looked up. */ + struct sym_val val2 = { NULL, NULL }; + size_t n; + struct r_scope_elem *scope = undef_map->l_local_scope[0]; + + for (n = 0; n < scope->r_nlist; n++) + if (scope->r_list[n] == val.m) + break; + + for (n++; n < scope->r_nlist; n++) + if (scope->r_list[n]->l_info[DT_SYMBOLIC] != NULL + && do_lookup_x (undef_name, new_hash, &old_hash, *ref, + &val2, + &scope->r_list[n]->l_symbolic_searchlist, + 0, version, 0, NULL, type_class, + undef_map) > 0) + { + conflict = 1; + val = val2; + break; + } + } + GL(dl_ns)[LM_ID_BASE]._ns_unique_sym_table.entries = saved_entries; } if (value->s) --- libc/include/link.h.jj 2009-12-16 00:10:37.000000000 +0100 +++ libc/include/link.h 2010-03-23 09:27:18.000000000 +0100 @@ -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 Free Software Foundation, Inc. + Copyright (C) 1995-2006, 2007, 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 @@ -188,6 +188,10 @@ struct link_map unsigned int l_contiguous:1; /* Nonzero if inter-segment holes are mprotected or if no holes are present at all. */ + unsigned int l_symbolic_in_local_scope:1; /* Nonzero if l_local_scope + during LD_TRACE_PRELINKING=1 + contains any DT_SYMBOLIC + libraries. */ /* Collected information about own RPATH directories. */ struct r_search_path_struct l_rpath_dirs; -------------- next part -------------- 2010-03-23 Jakub Jelinek * elf/dl-lookup.c (do_lookup_x): If tab->entries is NULL, but tab->size != 0, just unlock and goto success, without allocating anything or entering anything into the hash table. (_dl_debug_bindings): Temporarily set tab->entries to NULL around do_lookup_x in undef_map->l_local_scope[0]. --- libc/elf/dl-lookup.c.jj 2009-12-16 00:10:37.000000000 +0100 +++ libc/elf/dl-lookup.c 2010-03-23 11:03:45.850560036 +0100 @@ -1,5 +1,6 @@ /* Look up a symbol in the loaded objects. - Copyright (C) 1995-2005, 2006, 2007, 2009 Free Software Foundation, Inc. + Copyright (C) 1995-2005, 2006, 2007, 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 @@ -414,6 +415,20 @@ do_lookup_x (const char *undef_name, uin assert (!RTLD_CHECK_FOREIGN_CALL); #endif +#ifdef SHARED + /* If tab->entries is NULL, but tab->size is not, it means + this is the second, conflict finding, lookup for + LD_TRACE_PRELINKING in _dl_debug_bindings. Don't + allocate anything and don't enter anything into the + hash table. */ + if (__builtin_expect (tab->size, 0)) + { + assert (GLRO(dl_debug_mask) & DL_DEBUG_PRELINK); + __rtld_lock_unlock_recursive (tab->lock); + goto success; + } +#endif + #define INITIAL_NUNIQUE_SYM_TABLE 31 size = INITIAL_NUNIQUE_SYM_TABLE; entries = calloc (sizeof (struct unique_sym), size); @@ -917,13 +932,17 @@ _dl_debug_bindings (const char *undef_na { const uint_fast32_t new_hash = dl_new_hash (undef_name); unsigned long int old_hash = 0xffffffff; + struct unique_sym *saved_entries + = GL(dl_ns)[LM_ID_BASE]._ns_unique_sym_table.entries; + GL(dl_ns)[LM_ID_BASE]._ns_unique_sym_table.entries = NULL; do_lookup_x (undef_name, new_hash, &old_hash, *ref, &val, undef_map->l_local_scope[0], 0, version, 0, NULL, type_class, undef_map); if (val.s != value->s || val.m != value->m) conflict = 1; + GL(dl_ns)[LM_ID_BASE]._ns_unique_sym_table.entries = saved_entries; } if (value->s) From drepper@redhat.com Wed Mar 24 17:16:00 2010 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 Mar 2010 17:16:00 -0000 Subject: [PATCH] Fix handling of STB_GNU_UNIQUE in LD_TRACE_PRELINKING In-Reply-To: <20100323103348.GE3601@sunsite.ms.mff.cuni.cz> References: <20100323103348.GE3601@sunsite.ms.mff.cuni.cz> Message-ID: <4BAA48D7.3010308@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 03/23/2010 03:33 AM, Jakub Jelinek wrote: > Attached are two possible patches. The second, shorter one, is all that is > needed currently (I believe). The difference between the patches is in > handling libraries with DT_SYMBOLIC and STB_GNU_UNIQUE symbols. Apparently > current GNU ld if there is a relocation against STB_GNU_UNIQUE symbol > defined in the library itself, doesn't emit any relocation and resolves at > link time (possibly through a relative relocation). Is that what we want > though? Then the STB_GNU_UNIQUE symbols aren't really unique... Right. The linker has to be fixed. I've applied the first patch. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAkuqSNcACgkQ2ijCOnn/RHQkNACgu14Wmhn6JxpmuDbE3PEUG82a qO8AniThFZts0yE1zJ+IXaBQjD3P1XOW =2rjh -----END PGP SIGNATURE----- From drepper@redhat.com Wed Mar 24 19:01:00 2010 From: drepper@redhat.com (Ulrich Drepper) Date: Wed, 24 Mar 2010 19:01:00 -0000 Subject: [PATCH] Fix glob with empty pattern and patterns ending in slash In-Reply-To: References: Message-ID: <4BAA6184.2090503@redhat.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I see the problem with empty patterns and check in a slightly changed patch for that. What is the issue with trailing slashes? I need a test case. For the other change there also should have been a test case. - -- ??? Ulrich Drepper ??? Red Hat, Inc. ??? 444 Castro St ??? Mountain View, CA ??? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAkuqYYQACgkQ2ijCOnn/RHT3uwCeOczWg6VpNUuL7mg1LprYP0DU ZoYAn2t8oVH/EoajN6IQZsiIrmXEqk34 =0+ar -----END PGP SIGNATURE----- From schwab@redhat.com Thu Mar 25 10:07:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Thu, 25 Mar 2010 10:07:00 -0000 Subject: [PATCH] Fix glob with empty pattern and patterns ending in slash In-Reply-To: <4BAA6184.2090503@redhat.com> (Ulrich Drepper's message of "Wed, 24 Mar 2010 12:01:24 -0700") References: <4BAA6184.2090503@redhat.com> Message-ID: Ulrich Drepper writes: > What is the issue with trailing slashes? It's inconsistent. Globbing with "*/" returns only directories, but "**/" or "?*/" returns all files with directories marked. Either result could be the intented one, but IMHO the first one is more useful, and consistent with globbing in bash and other shells. 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 Thu Mar 25 17:54:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Thu, 25 Mar 2010 17:54:00 -0000 Subject: [PATCH] Fix spurious UNAVAIL status when using gethostbyname4_r nss function Message-ID: With "hosts: files nis dns" but no nis configured lookup spuriously fails. Andreas. 2010-03-25 Andreas Schwab * sysdeps/posix/getaddrinfo.c (gaih_inet): Reset no_data before each action. diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 62c38f6..8803c59 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -189,7 +189,6 @@ gaih_inet_serv (const char *servicename, const struct gaih_typeproto *tp, struct hostent th; \ struct hostent *h; \ char *localcanon = NULL; \ - no_data = 0; \ while (1) { \ rc = 0; \ status = DL_CALL_FCT (fct, (name, _family, &th, tmpbuf, tmpbuflen, \ @@ -702,6 +701,7 @@ gaih_inet (const char *name, const struct gaih_service *service, while (!no_more) { + no_data = 0; nss_gethostbyname4_r fct4 = __nss_lookup_function (nip, "gethostbyname4_r"); if (fct4 != NULL) -- 1.7.0.1 -- 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 Mar 26 09:13:00 2010 From: schwab@redhat.com (Andreas Schwab) Date: Fri, 26 Mar 2010 09:13:00 -0000 Subject: [PATCH] Fix spurious UNAVAIL status when using gethostbyname4_r nss function In-Reply-To: (Andreas Schwab's message of "Thu, 25 Mar 2010 18:54:21 +0100") References: Message-ID: With "hosts: files nis dns" but no nis configured lookup spuriously fails. (I didn't intent to remove the assignment in gethosts.) Andreas. 2010-03-25 Andreas Schwab * sysdeps/posix/getaddrinfo.c (gaih_inet): Reset no_data before each action. diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c index 62c38f6..8b7e38f 100644 --- a/sysdeps/posix/getaddrinfo.c +++ b/sysdeps/posix/getaddrinfo.c @@ -702,6 +702,7 @@ gaih_inet (const char *name, const struct gaih_service *service, while (!no_more) { + no_data = 0; nss_gethostbyname4_r fct4 = __nss_lookup_function (nip, "gethostbyname4_r"); if (fct4 != NULL) -- 1.7.0.1 -- Andreas Schwab, schwab@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different."