Open GoogleCodeExporter opened 9 years ago
Can you elaborate on the benefits of using these flags? Also, the CPU bound
tests (LRANGE) are about 10% slower in the benchmarks you show. That's not
really insignificant.
Original comment by pcnoordh...@gmail.com
on 20 Nov 2010 at 9:49
-fstack-protector, like the name suggests, protects the stack against stack
smashing and stack buffer overflows.
for more detailed information, please see:
http://www.trl.ibm.com/projects/security/ssp/
http://linuxfromscratch.xtra-net.org/hlfs/view/unstable/glibc-2.4/chapter02/ssp.
html
FORTIFY_SOURCE is described in:
https://fedoraproject.org/wiki/Security/Features#Compile_Time_Buffer_Checks_.28F
ORTIFY_SOURCE.29
this shouldn't have any impact in performance, since all the checks are compile
time.
I will address PIE in another comment.
Original comment by miguel.filipe
on 21 Nov 2010 at 1:48
About -pie:
PIE: position independent code is used to obtain better address space layout
randomization (ASLR,
http://en.wikipedia.org/wiki/Address_space_layout_randomization)
This enables ASLR for data and bss segments of the executable.
Example of the difference in address space with and without PIE on a normal
linux binary:
#include <stdio.h>
#include <stdlib.h>
char bss;
char data = 'a';
int test(void)
{
char a;
char *s;
s = (char *) malloc(sizeof(char));
printf("heap: %p\tstack: %p\tdata: %p\tbss: %p\n", s,&a, &data, &bss);
free(s);
return 0;
}
int main(void)
{
test();
return 0;
}
compiled without PIE:
miguel@thinkpad ~/code/c (master) $ gcc -o mem mem.c
miguel@thinkpad ~/code/c (master) $ for i in `seq 1 5`; do ./mem; done
heap: 0x1b56010 stack: 0x7fff5439a80f data: 0x402030 bss: 0x402048
heap: 0x22f1010 stack: 0x7fff270c78df data: 0x402030 bss: 0x402048
heap: 0xd0b010 stack: 0x7fff4826877f data: 0x402030 bss: 0x402048
heap: 0x196e010 stack: 0x7fff808e398f data: 0x402030 bss: 0x402048
heap: 0xd70010 stack: 0x7fffd59c835f data: 0x402030 bss: 0x402048
compiled with PIE:
miguel@thinkpad ~/code/c (master) $ gcc -o mem mem.c -fPIC -pie
miguel@thinkpad ~/code/c (master) $ for i in `seq 1 5`; do ./mem; done
heap: 0x7f73c2a7e010 stack: 0x7fff3b62d01f data: 0x7f73c1556038 bss:
0x7f73c1556050
heap: 0x7f79bb64a010 stack: 0x7fffd766e06f data: 0x7f79bb537038 bss:
0x7f79bb537050
heap: 0x7f3a8b0ab010 stack: 0x7fff04655fef data: 0x7f3a8a795038 bss:
0x7f3a8a795050
heap: 0x7facc8689010 stack: 0x7fff16340ddf data: 0x7facc845a038 bss:
0x7facc845a050
heap: 0x7f4f119e5010 stack: 0x7fff1328591f data: 0x7f4f11705038 bss:
0x7f4f11705050
Original comment by miguel.filipe
on 21 Nov 2010 at 1:54
I can triage the performance issue. Its probably due to -fstack-protector.
If PIE & FORTIFY_SOURCE don't have significant performance impact, i'm
proposing putting those in the CFLAGS.
Regarding -fstack-protector, it could eventually be made optional, just like
tcmalloc..
I just proposed this things as a proactive security measure, since this is C
code listening on the network..
Original comment by miguel.filipe
on 22 Nov 2010 at 5:35
Original issue reported on code.google.com by
miguel.filipe
on 19 Nov 2010 at 11:49