From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17994 invoked by alias); 18 Jun 2007 15:47:49 -0000 Received: (qmail 17977 invoked by uid 22791); 18 Jun 2007 15:47:49 -0000 X-Spam-Check-By: sourceware.org Received: from sunsite.ms.mff.cuni.cz (HELO sunsite.mff.cuni.cz) (195.113.15.26) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 18 Jun 2007 15:47:39 +0000 Received: from sunsite.mff.cuni.cz (localhost.localdomain [127.0.0.1]) by sunsite.mff.cuni.cz (8.13.8/8.13.8) with ESMTP id l5IFpQuq027860; Mon, 18 Jun 2007 17:51:26 +0200 Received: (from jakub@localhost) by sunsite.mff.cuni.cz (8.13.8/8.13.8/Submit) id l5IFpQln027859; Mon, 18 Jun 2007 17:51:26 +0200 Date: Mon, 18 Jun 2007 15:47:00 -0000 From: Jakub Jelinek To: Ulrich Drepper Cc: Glibc hackers Subject: [PATCH] Fix LD_AUDIT=foo.so:bar.so /bin/true Message-ID: <20070618155125.GZ3081@sunsite.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.2i Mailing-List: contact libc-hacker-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-hacker-owner@sourceware.org X-SW-Source: 2007-06/txt/msg00015.txt.bz2 Hi! When audit_list contains more than one list entry, init_tls is called multiple times which screws up all TLS handling. When it is called the second time, it will change GL(dl_tls_static_nelem) and then return NULL as GL(dl_initial_dtv) != NULL. As tcbp is set to that unconditionally, init_tls will be called after that loop once again, changing GL(dl_tls_static_nelem) again. This patch cures it. 2007-06-18 Jakub Jelinek * elf/rtld.c (dl_main): Don't call init_tls more than once. --- libc/elf/rtld.c.jj 2007-06-18 15:27:28.000000000 +0200 +++ libc/elf/rtld.c 2007-06-18 17:10:14.000000000 +0200 @@ -1400,6 +1400,11 @@ of this helper program; chances are you /* Iterate over all entries in the list. The order is important. */ struct audit_ifaces *last_audit = NULL; struct audit_list *al = audit_list->next; + + /* Since we start using the auditing DSOs right away we need to + initialize the data structures now. */ + tcbp = init_tls (); + do { int tls_idx = GL(dl_tls_max_dtv_idx); @@ -1410,10 +1415,6 @@ of this helper program; chances are you no DF_STATIC_TLS bit is set. The reason is that we know glibc will use the static model. */ - /* Since we start using the auditing DSOs right away we need to - initialize the data structures now. */ - tcbp = init_tls (); - struct dlmopen_args dlmargs; dlmargs.fname = al->name; dlmargs.map = NULL; Jakub