This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [BZ #18422] elf/tst-audit tests fail without PLT entries


On 05/26/2015 07:19 AM, H.J. Lu wrote:
> On Tue, May 26, 2015 at 1:00 AM, Andreas Schwab <schwab@suse.de> wrote:
>> "Carlos O'Donell" <carlos@redhat.com> writes:
>>
>>> In summary:
>>> - My next worry is about free of calloc'd data that is now using dl-minimal.c
>>
>> Anything allocated with dl-minimal must strictly be kept inside ld.so
>> and never be freed.
> 
> The calloc call is made at:
> 
>    if (__glibc_unlikely (consider_profiling)
>         && l->l_info[DT_PLTRELSZ] != NULL)
>       {
>         /* Allocate the array which will contain the already found
>            relocations.  If the shared object lacks a PLT (for example
>            if it only contains lead function) the l_info[DT_PLTRELSZ]
>            will be NULL.  */
>         size_t sizeofrel = l->l_info[DT_PLTREL]->d_un.d_val == DT_RELA
>                            ? sizeof (ElfW(Rela))
>                            : sizeof (ElfW(Rel));
>         size_t relcount = l->l_info[DT_PLTRELSZ]->d_un.d_val / sizeofrel;
>         l->l_reloc_result = calloc (sizeof (l->l_reloc_result[0]), relcount);
> 
>         if (l->l_reloc_result == NULL)
>           {
>             errstring = N_("\
> %s: out of memory to store relocation results for %s\n");
>             _dl_fatal_printf (errstring, RTLD_PROGNAME, l->l_name);
>           }
>       }
> 
> ld.so never frees  l->l_reloc_result.

Thanks.

The only other place I was worried about was TLS data structures, but
there we already use dl_initial_tls to indicate the data structure was
allocated early (specifically for use by auditors) and we do not pass
it to realloc because it was allocated by dl-minimal, thus we are OK
there also.

After your changes in binutils is the test at all useful?

We are no longer able to interpose calloc to catch early TLS init,
therefore we are no longer testing early TLS init and the comments
in the test need to be changed to match.

The new test is:
"Test that calloc is called at least once after dlopen and initialization
 of TLS varibles in the DSO."

Why do we care about this?

Is there any way to still test that early TLS initialization has occurred
when using LD_AUDIT?

Would't such a test look like this?

- Create auditor that uses TLS in audit funciton.
- Interpose calloc.
- Check that things don't crash.

We already have a test for this, it's tst-audit9 (Bug 16613).

OK to checkin your change to tst-audit2 if you change the test comment
to reflect the change in what is being tested:

"Test that interposed calloc is called by the dynamic loader, and that
 TLS is fully initialized by then."

Thanks for working through this.

Cheers,
Carlos.
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]