Time to enable partial relro

Pedro Giffuni pfg at FreeBSD.org
Sat Aug 27 18:32:17 UTC 2016



On 08/27/16 12:45, Konstantin Belousov wrote:
> On Sat, Aug 27, 2016 at 11:06:54AM -0500, Pedro Giffuni wrote:
>>
>>
>> On 08/26/16 20:10, Pedro Giffuni wrote:
>>>
>>>
>> ...>> I think we should move forward, just want to make sure it doesn???t
>>>> break some arch completely before moving ahead. While lld is a goal,
>>>> the goal is also to have a ld.bdf installed for 12, iirc, as a fallback.
>>>
>>> And very right you are, this has all the chances of breaking MIPS*:
>>>
>>> "A configure option --enable-relro={yes|no} to decide
>>>  whether -z relro should be the default behaviour for
>>>  the linker in ELF based targets.  If this configure
>>>  option is not specified then relro will be enabled
>>>  automatically for all Linux based targets except FRV,
>>>  HPPA, IA64 and MIPS."
>>>
>>> _____
>>>
>>> I will update the patch to exclude MIPS (and MIPS64 JIC).
>>>
>>> Pedro.
>>>
>>> *https://gcc.gnu.org/ml/gcc/2016-08/msg00134.html
>>>
>>
>> Looking more into this, and the arm report from Mark Millard (thanks!),
>> binutils has tests for RELRO in their testsuite that would be an
>> important indicator before enabling the option.
>>
>> It surprises me that we don't have an easy way to run those checks from
>> the port, so I borrowed the regression-test mode from GCC and I am
>> attaching it.
>>
>> The tests may depend on some gnu-isms but we don't appear to do too
>> well on the tests:
>>
>>                  === ld Summary ===
>>
>> # of expected passes            511
>> # of unexpected failures        78
>> # of expected failures          4
>> # of unresolved testcases       35
>> # of untested testcases         1
>> # of unsupported tests          9
>> /usr/ports/devel/binutils/work/binutils-2.27/ld/ld-new 2.27
>
> And ?  In which way this data is useful or indicative of anything ?

This is just informational. According to the GNU ld commit [1], passing 
the tests is the criteria used to decide whether the RELRO should be 
enabled on a particular platform. We don't complete all the tests and
it appears the tests break before I get to the relro part:

...
.PASS: test-strtol-20.
gmake[2]: Target 'check-host' not remade because of errors.
gmake[1]: *** [Makefile:2204: do-check] Error 2
gmake[1]: Target 'check' not remade because of errors.
*** Error code 2

Stop.
make: stopped in /usr/ports/devel/binutils


> Why this tests are relevant to the proposed change ?

I will drop the proposed change. We should evaluate individually
each platform before enabling RELRO. At this time I am more worried 
about the failing tests and our lack of testing of binutils.

   AFAIK, binutils
> tests typically compare ld output against expected binary.
>
> And, number of the unexpected failures in your showcase is quite worrying.
>

It is. Having a knob in the port to run the tests seems important.

Pedro.


[1] 
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=647e4d46495f2bfb0950fd1066c8a660173cca40


More information about the freebsd-toolchain mailing list