Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Aug 2016 16:35:41 +0200
From:      Ed Schouten <ed@nuxi.nl>
To:        Warner Losh <imp@bsdimp.com>
Cc:        Pedro Giffuni <pfg@freebsd.org>,  "freebsd-toolchain@FreeBSD.org" <freebsd-toolchain@freebsd.org>
Subject:   Re: Time to enable partial relro
Message-ID:  <CABh_MKk6ru%2BxZxmgSeOswnTLv9FaUOrw91a9u_FmdY=t342cHg@mail.gmail.com>
In-Reply-To: <CANCZdfqAmhN1owbo_rDt5xjC%2BbboOHrgu2xDHeZi1P02rX7EwQ@mail.gmail.com>
References:  <b75890eb-d8bd-759e-002f-ab0c16db0975@FreeBSD.org> <CANCZdfqAmhN1owbo_rDt5xjC%2BbboOHrgu2xDHeZi1P02rX7EwQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
2016-08-26 16:18 GMT+02:00 Warner Losh <imp@bsdimp.com>:
>> GNU RELRO support was committed in r230784 (2012-01-30) but we never enabled
>> it by default.
>
> So what's the summary of why we'd want to do that? What benefit does it bring?
> Sure, other folks do it, but why?

In a nutshell:

ELF files that contain relocations (shared libraries, dynamically
linked and/or position-independent executables) typically contain
pages of memory that can be marked read-only (i.e., they only contain
constants). Unfortunately, they had to be marked for writing, for the
reason that rtld had to walk over them to apply the relocations on
startup. GNU added an extension to their linker, making it group
together all of such constants in consecutive pages, while also making
it add a special record to the ELF file (RELRO). This record can be
used by rtld to mprotect(PROT_READ) the range after relocating is
finished.

In other words, it means that global constants actually become
constant again. It makes it easier to detect programming mistakes
(accidentally discarding const qualifiers and writing).

-- 
Ed Schouten <ed@nuxi.nl>
Nuxi, 's-Hertogenbosch, the Netherlands
KvK-nr.: 62051717



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CABh_MKk6ru%2BxZxmgSeOswnTLv9FaUOrw91a9u_FmdY=t342cHg>