From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/3607 Path: news.gmane.org!not-for-mail From: Richard Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 3/3] [FYI] fix dynamic linker dso loading Date: Wed, 10 Jul 2013 12:52:23 -0400 Message-ID: <20130710165223.GA29800@brightrain.aerifal.cx> 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> <20130710184725.40e733de@vostro> 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: 8bit X-Trace: ger.gmane.org 1373475156 26209 80.91.229.3 (10 Jul 2013 16:52:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 10 Jul 2013 16:52:36 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-3611-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jul 10 18:52:38 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 1Uwxd8-00044h-5C for gllmg-musl@plane.gmane.org; Wed, 10 Jul 2013 18:52:38 +0200 Original-Received: (qmail 13417 invoked by uid 550); 10 Jul 2013 16:52:37 -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 13402 invoked from network); 10 Jul 2013 16:52:37 -0000 Content-Disposition: inline In-Reply-To: <20130710184725.40e733de@vostro> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:3607 Archived-At: On Wed, Jul 10, 2013 at 06:47:25PM +0300, Timo Teras wrote: > On Wed, 10 Jul 2013 11:00:03 -0400 > Rich Felker wrote: > > > On Wed, Jul 10, 2013 at 04:39:01PM +0300, Timo Teräs 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. > > > > 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 = read(fd, buf, sizeof buf); > .... > ph = (void *)((char *)buf + eh->e_phoff); > .... > dso->phdr = ph; > > So no, the program headers are not part of the mapping. At least they > are not setup that way currently. Indeed, this is purely my fault for failing to review this part of the patch when it was committed. I was not aware that dso->phdr was being pointed to the wrong memory; presumably it "happened to work" for some tests I did at the time. I will fix it. > Instead dso->phdr points to stack and gets messed up. That's why the: > - dso->phdr = ph; > + dso->phdr = malloc(phsize); > + memcpy(dso->phdr, ph, phsize); > > Perhaps the proper fix would be to map them instead then. They are already mapped anyway; the pointer into the right offset of the map is just not setup. > > > The reclamation fix should be probably something better, as I > > > believe the same applies to GNU_EH_FRAME phdr. > > > > 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 != PT_ARM_EXIDX" additions are not needed > after all. Indeed, all that's needed is the correct pointer value. I'll get a patch committed soon that should fix the issue; please let me know if other issues persist. Rich