public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>,
	Andreas Schwab <schwab@linux-m68k.org>
Cc: John Mellor-Crummey <johnmc@rice.edu>,
	Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH 1/5] elf: Fix audit regression
Date: Thu, 8 Jul 2021 09:13:03 -0300	[thread overview]
Message-ID: <1f7a81aa-6799-5974-7398-9544687628c8@linaro.org> (raw)
In-Reply-To: <87a6mx28i6.fsf@oldenburg.str.redhat.com>



On 07/07/2021 17:07, Florian Weimer via Libc-alpha wrote:
> * Florian Weimer:
> 
>> * Andreas Schwab:
>>
>>> On Jul 07 2021, Adhemerval Zanella via Libc-alpha wrote:
>>>
>>>> @@ -771,7 +771,7 @@ dl_open_worker (void *a)
>>>>      {
>>>>        struct link_map *libc_map = GL(dl_ns)[args->nsid].libc_map;
>>>>  #ifdef SHARED
>>>> -      bool initial = libc_map->l_ns == LM_ID_BASE;
>>>> +      bool initial = libc_map != NULL ? libc_map->l_ns == LM_ID_BASE : false;
>>>
>>>          bool initial = libc_map != NULL && libc_map->l_ns == LM_ID_BASE;
>>
>> True … but:
>>
>> This is only used by dlopen/dlmopen, right?  And even if dlmopen is
>> called from an auditor (to load another libc), it is *never* the initial
>> libc in the base namespace.
>>
>> The actual base namespace libc is handled in elf/rtld.c:dl_main:
>>
>>   /* Relocation is complete.  Perform early libc initialization.  This
>>      is the initial libc, even if audit modules have been loaded with
>>      other libcs.  */
>>   _dl_call_libc_early_init (GL(dl_ns)[LM_ID_BASE].libc_map, true);
>>
>> And I think the dl_open_worker should mirror that and just do:
>>
>>   if (!args->libc_already_loaded)
>>     /* This is never the initial libc because it has been loaded via
>>        dlmopen.  */
>>     _dl_call_libc_early_init (libc_map, false);
> 
> Eh, or rather:
> 
>   if (!args->libc_already_loaded)
>     {
>       struct link_map *libc_map = GL(dl_ns)[args->nsid].libc_map;
>       /* This is never the initial libc because it has been loaded via
>          dlmopen.  */
>       _dl_call_libc_early_init (libc_map, false);
>     }
> 
> (_dl_call_libc_early_init checks for a null link map.)

I think this make sense and it also simplifes the code a bit. I will
adjust the patch.

  reply	other threads:[~2021-07-08 12:13 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-07 18:26 [PATCH 0/5] Some rtld-audit fixes Adhemerval Zanella
2021-07-07 18:26 ` [PATCH 1/5] elf: Fix audit regression Adhemerval Zanella
2021-07-07 19:02   ` Florian Weimer
2021-07-07 19:07     ` Adhemerval Zanella
2021-07-07 19:51   ` Andreas Schwab
2021-07-07 19:57     ` Adhemerval Zanella
2021-07-07 20:02     ` Florian Weimer
2021-07-07 20:07       ` Florian Weimer
2021-07-08 12:13         ` Adhemerval Zanella [this message]
2021-07-07 18:26 ` [PATCH 2/5] elf: Avoid unnecessary slowdown from profiling with audit (BZ#15533) Adhemerval Zanella
2021-07-07 19:20   ` Florian Weimer
2021-07-07 20:05     ` Adhemerval Zanella
2021-07-07 20:15       ` Florian Weimer
2021-07-07 20:53         ` John Mellor-Crummey
2021-07-19 13:17         ` Adhemerval Zanella
2021-07-07 18:26 ` [PATCH 3/5] elf: Add audit tests for modules with TLSDESC Adhemerval Zanella
2021-07-07 18:26 ` [PATCH 4/5] elf: Do not fail for failed dlmopen on audit modules (BZ #28061) Adhemerval Zanella
2021-07-07 18:26 ` [PATCH 5/5] elf: Suppress audit calls when a (new) namespace is empty (BZ #28062) Adhemerval Zanella
2021-07-07 19:02 ` [PATCH 0/5] Some rtld-audit fixes John Mellor-Crummey
2021-07-07 19:09   ` Adhemerval Zanella
2021-07-07 19:22     ` John Mellor-Crummey
2021-07-08  6:25       ` Florian Weimer
2021-07-08  8:03         ` John Mellor-Crummey
2021-07-08  8:21           ` Florian Weimer
2021-07-08  0:09     ` John Mellor-Crummey
2021-07-08  0:11       ` John Mellor-Crummey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f7a81aa-6799-5974-7398-9544687628c8@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=johnmc@rice.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@linux-m68k.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).