From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3606 Path: news.gmane.org!not-for-mail From: Timo Teras Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 3/3] [FYI] fix dynamic linker dso loading Date: Wed, 10 Jul 2013 18:47:25 +0300 Message-ID: <20130710184725.40e733de@vostro> References: <1373463541-17170-1-git-send-email-timo.teras@iki.fi> <1373463541-17170-3-git-send-email-timo.teras@iki.fi> <20130710150002.GZ29800@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1373471233 11861 80.91.229.3 (10 Jul 2013 15:47:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Jul 2013 15:47:13 +0000 (UTC) Cc: dalias@aerifal.cx To: musl@lists.openwall.com Original-X-From: musl-return-3610-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jul 10 17:47:15 2013 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Uwwbq-0004H8-63 for gllmg-musl@plane.gmane.org; Wed, 10 Jul 2013 17:47:14 +0200 Original-Received: (qmail 24351 invoked by uid 550); 10 Jul 2013 15:47:13 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 24343 invoked from network); 10 Jul 2013 15:47:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:in-reply-to:references :x-mailer:mime-version:content-type:content-transfer-encoding; bh=FDvlS5EG9vGpPd6t20OLC3CD9F2WBTPa0i1d0qYdpeg=; b=xlNFeRk1stv4xXBWGuZhrpl23W7G2AAljSw4G83mRuHCsrOeBM7CfuOdRaKpPotN8F 5ghSJym2s01brZjhfCYlicoKRV/rFUSEtZQ1lFj/+qB7rchK59ExxVsrr4ZbgY8Ry7aa Ei5r4iaTwTD/A8TXIcaGXQAL580ytblSP5YszUYINnZyS9aibOXI5AsRStoqaQSe045v etUESONR3YwBJDzOGqG+KnjAd7LEGV7eXdYi2sOFGAi0+4itFAJt+Et03XkTpmwf3R5Y nacTYbn/AoH7uez3gmShsFdJJB3u/GFWlENrP1Pp1DKYttpUs+XtnNzBl9FDUCVQDEDB RlWQ== X-Received: by 10.14.149.141 with SMTP id x13mr37036391eej.77.1373471222186; Wed, 10 Jul 2013 08:47:02 -0700 (PDT) Original-Sender: =?UTF-8?Q?Timo_Ter=C3=A4s?= In-Reply-To: <20130710150002.GZ29800@brightrain.aerifal.cx> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.17; i686-pc-linux-gnu) Xref: news.gmane.org gmane.linux.lib.musl.general:3606 Archived-At: On Wed, 10 Jul 2013 11:00:03 -0400 Rich Felker wrote: > On Wed, Jul 10, 2013 at 04:39:01PM +0300, Timo Ter=C3=A4s wrote: > > The phdr entries need to be allocated from heap, so later calls > > to dl_iterate_phdr work properly. Make sure the ARM unwind info > > is not freed. >=20 > I am confused about the motivation for this patch. The program headers > are part of the mapping and are never freed. static void *map_library(int fd, struct dso *dso) { Ehdr buf[(896+sizeof(Ehdr))/sizeof(Ehdr)]; ... ssize_t l =3D read(fd, buf, sizeof buf); ... ph =3D (void *)((char *)buf + eh->e_phoff); ... dso->phdr =3D ph; So no, the program headers are not part of the mapping. At least they are not setup that way currently. Instead dso->phdr points to stack and gets messed up. That's why the: - dso->phdr =3D ph; + dso->phdr =3D malloc(phsize); + memcpy(dso->phdr, ph, phsize); Perhaps the proper fix would be to map them instead then. > > This is not exactly intended to be committed, but shows clearly > > what is wrong with the current implementation. >=20 > Not so clear. :) Hope the above explains the root problem. >=20 > > The reclamation fix should be probably something better, as I > > believe the same applies to GNU_EH_FRAME phdr. >=20 > It definitely does not apply to GNU_EH_FRAME. Seems I misunderstood in hurry what the reclaim_gaps really does. Probably one of the reasons why it has the "huge hack" comment.. :) I believe the "ph->p_type !=3D PT_ARM_EXIDX" additions are not needed after all. - Timo