Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Fri, 20 Jan 2012 09:30:52 +0100
From: "gs@...3.at" <gs@...3.at>
To: musl@...ts.openwall.com
CC: Rich Felker <dalias@...ifal.cx>, "retnyg@....net" <retnyg@....net>
Subject: Re: Re: [PATCH] fix lookup of ldso's dynamic section for GOLD
 linker

On 01/20/2012 04:20 AM, Rich Felker wrote:
> On Thu, Jan 19, 2012 at 05:53:10PM +0100, retnyg@....net wrote:
>> here's a better one with only the necessary stuff.
>> also it doesnt use sizeof but the correct value of each program
>> header as stored in the elf header
> Looks roughly correct now and it's clear that it's not changing
> anything about load order. Thanks!
>
>> > From 26754baff1ee5c5a8001c0b3ed5faddcd58b8ca3 Mon Sep 17 00:00:00 2001
>> From: rofl0r<retnyg@....net>
>> Date: Thu, 19 Jan 2012 14:54:39 +0100
>> Subject: [PATCH] fix lookup of ldso's dynamic section for GOLD linker
>>
>> the previous code worked only with the ld linker.
>> with the old technique, lib_dyn[DT_STRTAB] et al were 0.
>> ---
>>   src/ldso/dynlink.c |   12 +++++++++++-
>>   1 files changed, 11 insertions(+), 1 deletions(-)
>>
>> diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
>> index 86d4b80..ff12a78 100644
>> --- a/src/ldso/dynlink.c
>> +++ b/src/ldso/dynlink.c
>> @@ -498,8 +498,18 @@ void *__dynlink(int argc, char **argv, size_t *got)
>>   		}
>>   	}
>>
>> +	got[0] += aux[AT_BASE];
>> +	
> Note that got[0] is still used later as the dynamic vector address,
> but your patch does not set it correctly when the original value was
> not the load-address-relative pointer to it...
i wasn't sure about what it is used for, and since your original code 
increased it, i just did the same.
your new code now does not use "got" anywhere.
if that's ok, maybe (void) it; so that the compiler does not warn about 
unused parameters...
>>   	/* Relocate ldso's DYNAMIC pointer and load vector */
>> -	decode_vec((void *)(got[0] += aux[AT_BASE]), lib_dyn, DYN_CNT);
>> +	ehdr = (void*) aux[AT_BASE];
>> +	phdr = (Phdr*) ((char*) ehdr + ehdr->e_phoff);
>> +	
>> +	for(i = 0; i<  ehdr->e_phnum; i++, phdr = (void *)((char *) phdr + ehdr->e_phentsize)) {
>> +		if (phdr->p_type == PT_DYNAMIC) {
>> +			decode_vec((void *) ((char*) ehdr + phdr->p_vaddr), lib_dyn, DYN_CNT);
>> +			break;
>> +		}
>> +	}
> This looks correct. I'm making some relatively minor cosmetic changes.
> By the way, in the future please attach patches rather than sending
> them inline so the tabs don't get ruined, lines don't get wrapped,
> etc. Mail bodies are generally not patch-clean.
>
> See the attached patch and let me know if it looks ok..
>
> Rich
your patch looks ok and works well here, with both ld and gold and even 
with LD_PRELOAD.
unsure about PIE though.

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.