Check multiple NT_GNU_PROPERTY_TYPE_0 notes [BZ #23509]
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 8 Nov 2018 18:06:58 +0000 (10:06 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 8 Nov 2018 18:07:10 +0000 (10:07 -0800)
commitd524fa6c35e675eedbd8fe6cdf4db0b49c658026
treed1bc2b6df231383da1f36427fff3c758ba50b69d
parentac8060265bcaca61568ef3a20b9a0140a270af54
Check multiple NT_GNU_PROPERTY_TYPE_0 notes [BZ #23509]

Linkers group input note sections with the same name into one output
note section with the same name.  One output note section is placed in
one PT_NOTE segment.  Since new linkers merge input .note.gnu.property
sections into one output .note.gnu.property section, there is only
one NT_GNU_PROPERTY_TYPE_0 note in one PT_NOTE segment with new linkers.
Since older linkers treat input .note.gnu.property section as a generic
note section and just concatenate all input .note.gnu.property sections
into one output .note.gnu.property section without merging them, we may
see multiple NT_GNU_PROPERTY_TYPE_0 notes in one PT_NOTE segment with
older linkers.

When an older linker is used to created the program on CET-enabled OS,
the linker output has a single .note.gnu.property section with multiple
NT_GNU_PROPERTY_TYPE_0 notes, some of which have IBT and SHSTK enable
bits set even if the program isn't CET enabled.  Such programs will
crash on CET-enabled machines.  This patch updates the note parser:

1. Skip note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
2. Check multiple NT_GNU_PROPERTY_TYPE_0 notes.

[BZ #23509]
* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Skip
note parsing if a NT_GNU_PROPERTY_TYPE_0 note has been processed.
Update the l_cet field when processing NT_GNU_PROPERTY_TYPE_0 note.
Check multiple NT_GNU_PROPERTY_TYPE_0 notes.
* sysdeps/x86/link_map.h (l_cet): Expand to 3 bits,  Add
lc_unknown.
ChangeLog
sysdeps/x86/dl-prop.h
sysdeps/x86/link_map.h