[PATCH] Clear GL(dl_initfirst) when freeing its link_map memory [BZ# 25396]

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Clear GL(dl_initfirst) when freeing its link_map memory [BZ# 25396]

H.J. Lu-30
--
H.J.

0001-Clear-GL-dl_initfirst-when-freeing-its-link_map-memo.patch (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Clear GL(dl_initfirst) when freeing its link_map memory [BZ# 25396]

Florian Weimer-5
> From de86cd3ee3a4fdc072cbcfa1b87abcdba472263f Mon Sep 17 00:00:00 2001
> From: "H.J. Lu" <[hidden email]>
> Date: Thu, 16 Jan 2020 06:45:36 -0800
> Subject: [PATCH] Clear GL(dl_initfirst) when freeing its link_map memory [BZ#
>  25396]
>
> We should clear GL(dl_initfirst) when freeing its link_map memory.
>
> Tested on Fedora 31/x86-64 with CET.
> ---
>  elf/dl-close.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/elf/dl-close.c b/elf/dl-close.c
> index 104c299209..73b2817bbf 100644
> --- a/elf/dl-close.c
> +++ b/elf/dl-close.c
> @@ -756,6 +756,10 @@ _dl_close_worker (struct link_map *map, bool force)
>    if (imap->l_runpath_dirs.dirs != (void *) -1)
>      free (imap->l_runpath_dirs.dirs);
>  
> +  /* Clear GL(dl_initfirst) when freeing its link_map memory.  */
> +  if (imap == GL(dl_initfirst))
> +    GL(dl_initfirst) = NULL;
> +
>    free (imap);
>   }
>      }

Thanks, looks good to me.

Siddhesh, is this okay for master?  And my test case as well?

  <https://sourceware.org/ml/libc-alpha/2020-01/msg00320.html>

Florian

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Clear GL(dl_initfirst) when freeing its link_map memory [BZ# 25396]

Siddhesh Poyarekar-8
On 16/01/20 8:25 pm, Florian Weimer wrote:

>> From de86cd3ee3a4fdc072cbcfa1b87abcdba472263f Mon Sep 17 00:00:00 2001
>> From: "H.J. Lu" <[hidden email]>
>> Date: Thu, 16 Jan 2020 06:45:36 -0800
>> Subject: [PATCH] Clear GL(dl_initfirst) when freeing its link_map memory [BZ#
>>  25396]
>>
>> We should clear GL(dl_initfirst) when freeing its link_map memory.
>>
>> Tested on Fedora 31/x86-64 with CET.
>> ---
>>  elf/dl-close.c | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/elf/dl-close.c b/elf/dl-close.c
>> index 104c299209..73b2817bbf 100644
>> --- a/elf/dl-close.c
>> +++ b/elf/dl-close.c
>> @@ -756,6 +756,10 @@ _dl_close_worker (struct link_map *map, bool force)
>>    if (imap->l_runpath_dirs.dirs != (void *) -1)
>>      free (imap->l_runpath_dirs.dirs);
>>  
>> +  /* Clear GL(dl_initfirst) when freeing its link_map memory.  */
>> +  if (imap == GL(dl_initfirst))
>> +    GL(dl_initfirst) = NULL;
>> +
>>    free (imap);
>>   }
>>      }
>
> Thanks, looks good to me.
>
> Siddhesh, is this okay for master?  And my test case as well?
>
>   <https://sourceware.org/ml/libc-alpha/2020-01/msg00320.html>
>

OK for master, I've reviewed and approved the test case too.

Thanks,
Siddhesh

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Clear GL(dl_initfirst) when freeing its link_map memory [BZ# 25396]

H.J. Lu-30
On Thu, Jan 16, 2020 at 7:34 AM Siddhesh Poyarekar <[hidden email]> wrote:

>
> On 16/01/20 8:25 pm, Florian Weimer wrote:
> >> From de86cd3ee3a4fdc072cbcfa1b87abcdba472263f Mon Sep 17 00:00:00 2001
> >> From: "H.J. Lu" <[hidden email]>
> >> Date: Thu, 16 Jan 2020 06:45:36 -0800
> >> Subject: [PATCH] Clear GL(dl_initfirst) when freeing its link_map memory [BZ#
> >>  25396]
> >>
> >> We should clear GL(dl_initfirst) when freeing its link_map memory.
> >>
> >> Tested on Fedora 31/x86-64 with CET.
> >> ---
> >>  elf/dl-close.c | 4 ++++
> >>  1 file changed, 4 insertions(+)
> >>
> >> diff --git a/elf/dl-close.c b/elf/dl-close.c
> >> index 104c299209..73b2817bbf 100644
> >> --- a/elf/dl-close.c
> >> +++ b/elf/dl-close.c
> >> @@ -756,6 +756,10 @@ _dl_close_worker (struct link_map *map, bool force)
> >>        if (imap->l_runpath_dirs.dirs != (void *) -1)
> >>          free (imap->l_runpath_dirs.dirs);
> >>
> >> +      /* Clear GL(dl_initfirst) when freeing its link_map memory.  */
> >> +      if (imap == GL(dl_initfirst))
> >> +        GL(dl_initfirst) = NULL;
> >> +
> >>        free (imap);
> >>      }
> >>      }
> >
> > Thanks, looks good to me.
> >
> > Siddhesh, is this okay for master?  And my test case as well?
> >
> >   <https://sourceware.org/ml/libc-alpha/2020-01/msg00320.html>
> >
>
> OK for master, I've reviewed and approved the test case too.
>
>

Done.

Thanks.

--
H.J.