This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PoC: Function Pointer Protection in C Programs
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: Stephen Röttger <stephen dot roettger at gmail dot com>
- Cc: oss-security at lists dot openwall dot com, gcc at gcc dot gnu dot org
- Date: Thu, 22 Aug 2013 10:32:33 +0200
- Subject: Re: PoC: Function Pointer Protection in C Programs
- References: <5214D201 dot 1010509 at googlemail dot com> <20130821162603 dot GB4369 at domone dot kolej dot mff dot cuni dot cz> <5214F33A dot 3020509 at googlemail dot com>
On Wed, Aug 21, 2013 at 07:04:58PM +0200, Stephen Röttger wrote:
>
> > What is performance impact for program that just qsorts big array? It
> > looks like worst case scenario for me.
>
> I just put together a quick test program that sorts an array of 10^6
> integers and stopped the execution time using "time". The results are as
> follows (+- 0,01s):
>
> protection disabled, -O0:
> ./sort_nofpp_0 0,19s user 0,02s system 98% cpu 0,215 total
>
> protection enabled, -O0
> ./sort_fpp_0 0,54s user 0,01s system 99% cpu 0,549 total
>
> protection disabled, -O3
> ./sort_nofpp_3 0,15s user 0,01s system 98% cpu 0,157 total
>
> protection enabled, -O3
> ./sort_fpp_3 0,51s user 0,00s system 99% cpu 0,511 total
>
> So this makes quite a difference:
> 0,19s -> 0,54s
> 0,15s -> 0,51s
After bit of thought a loops with callback can be optimized by gcc.
It could be possible to teach CSE to rewrite
while(foo){
check(p);
(*p)(x,y,z);
}
into
check(p);
while(foo){
(*p)(x,y,z);
}