[PATCH] Check multiple NT_GNU_PROPERTY_TYPE_0 notes [BZ #23509]

H.J. Lu hjl.tools@gmail.com
Tue Aug 14 18:12:00 GMT 2018


On Tue, Aug 14, 2018 at 10:59 AM, Florian Weimer <fweimer@redhat.com> wrote:
> On 08/14/2018 07:32 PM, H.J. Lu wrote:
>
>>   #if CET_ENABLED
>> +  /* Skip if we have seen a NT_GNU_PROPERTY_TYPE_0 note before.  */
>> +  if (l->l_cet != lc_unknown)
>> +    return;
>
>
> Should this set l->l_cet to lc_none before returning?
>
>> +         /* Stop if we see more than one GNU property note which may
>> +            be generated by the older linker.  */
>> +         if (l->l_cet != lc_unknown)
>> +           return;
>
>
> Likewise.
>

_dl_process_cet_property_note is called on on each PT_NOTE segment.
We must keep searching until we found a PT_NOTE segment with a
NT_GNU_PROPERTY_TYPE_0 note:

  /* Skip if we have seen a NT_GNU_PROPERTY_TYPE_0 note before.  */
  if (l->l_cet != lc_unknown)
    return;
...

<<< Found a PT_NOTE segment, which may not contain
the NT_GNU_PROPERTY_TYPE_0 note.

     /* Find the NT_GNU_PROPERTY_TYPE_0 note.  */
      if (note->n_namesz == 4
          && note->n_type == NT_GNU_PROPERTY_TYPE_0
          && memcmp (note + 1, "GNU", 4) == 0)
        {

<<< Now we found a NT_GNU_PROPERTY_TYPE_0 note.

          /* Stop if we see more than one GNU property note which may
             be generated by the older linker.  */
          if (l->l_cet != lc_unknown)  <<<<<<< l_cet starts with lc_unknown.
            return;

          /* Check CET status now.  */
          l->l_cet = lc_none; <<<<<<<<<  Set l_cet to lc_none now.

l->l_cet may be left as lc_unknown if there is no NT_GNU_PROPERTY_TYPE_0
note.

-- 
H.J.



More information about the Libc-alpha mailing list