1 |
On Monday 23 January 2012 15:12:47 Francesco Riosa wrote: |
2 |
> 2012/1/23 Mike Gilbert: |
3 |
> > On Mon, Jan 23, 2012 at 2:57 PM, Jason A. Donenfeld wrote: |
4 |
> >> To check for PIE, |
5 |
> >> |
6 |
> >> readelf -h /bin/su | grep Type |
7 |
> >> |
8 |
> >> If it says EXEC, no PIE. If it says DYN, yes PIE. |
9 |
> > |
10 |
> > I'm asking "how does one enable PIE/ASLR", not how to check if it is |
11 |
> > enabled already. |
12 |
> |
13 |
> - PIE should be -fPIC also for the executable, not only for the .so |
14 |
> (has a performance impact) |
15 |
|
16 |
not entirely sure what you're saying here. i'll clarify in general: |
17 |
- build all code going into shared libraries with -fPIC |
18 |
(regardless of hardening, this is Gentoo policy today) |
19 |
- build code going into executables with -fPIE |
20 |
(this is what hardened does, not default Gentoo systems) |
21 |
|
22 |
you could build all code (including executables) with -fPIC, but that has |
23 |
useless overhead compared to -fPIE. it's small but not insignificant. |
24 |
|
25 |
> - ASLR you need "hardened" use for gcc, and the toolchain, pax kernel help |
26 |
> too |
27 |
|
28 |
the hardened toolchain "helps", but it is not required. ASLR is in the |
29 |
mainline Linux kernel and iirc, enabled by default. it is already operating |
30 |
on all shared libraries because those are PIC. |
31 |
-mike |