[PATCH v10 2/4] elf: Fix initial-exec TLS access on audit modules (BZ #28096)
Adhemerval Zanella
adhemerval.zanella@linaro.org
Tue Jan 18 13:47:23 GMT 2022
On 18/01/2022 10:46, Adhemerval Zanella wrote:
>
>
> On 18/01/2022 10:33, Adhemerval Zanella wrote:
>>
>>
>> On 18/01/2022 10:29, Florian Weimer wrote:
>>> * Adhemerval Zanella:
>>>
>>>>>> So we need to avoid initialization only for the libc.so loading by
>>>>>> audit libraries, the default one should still be initialized (marked
>>>>>> as [INIT]). Later when new threads are created we need to initialized
>>>>>> everything.
>>>>>
>>>>> That's what I tried to express with the LM_ID_BASE check.
>>>>
>>>> The problem is 'map->l_ns == LM_ID_BASE && !init_tls' will not initilize
>>>> the required libc.so for main application during audit module loading.
>>>> With tst-audit21:
>>>>
>>>> 1593586: [rtld.c:965] load_audit_module
>>>> 1593586: [rtld.c:972] load_audit_module
>>>> 1593586: [rtld.c:2464] dl_main
>>>> 1593586: [../elf/dl-tls.c:605] map->l_name= map->l_ns=0 map->l_auditing=0 init_tls=0
>>>> 1593586: [../elf/dl-tls.c:610] map->l_name=[...]/elf/tst-auditmod21a.so map->l_ns=1 map->l_auditing=1 init_tls=0 [INIT]
>>>> 1593586: [../elf/dl-tls.c:610] map->l_name=[...]/libc.so.6 map->l_ns=1 map->l_auditing=1 init_tls=0 [INIT]
>>>> 1593586: [../elf/dl-tls.c:605] map->l_name=[...]/libc.so.6 map->l_ns=0 map->l_auditing=0 init_tls=0
>>>> 1593586: [../elf/dl-tls.c:627]
>>>> 1593586: [rtld.c:2466] dl_main
>>>> Segmentation fault (core dumped)
>>>
>>> Looks like the condition is simply reversed? [INIT] should only appear
>>> for map->l_ns == 0, right?
>>
>> Hum, 'if (map->l_ns != LM_ID_BASE && !init_tls)' seems correct indeed.
>> Let me run a full make check to certify it.
>
> Yes, it is correct. I will remove the 'l_auditing' field.
Oops, the 'l_auditing' usage I meant.
More information about the Libc-alpha
mailing list