Hi Joel,

no, I don't care about the inlines...

Regarding, memset-optimization, I found the gcc-explorer quite nice for 
experimenting...

You will see that:
http://gcc.godbolt.org/#{%22version%22%3A3%2C%22filterAsm%22%3A{%22labels%22%3Atrue%2C%22directives%22%3Atrue%2C%22commentOnly%22%3Atrue%2C%22colouriseAsm%22%3Atrue}%2C%22compilers%22%3A[{%22source%22%3A%22%2F%2F%20Type%20your%20code%20here%2C%20or%20load%20an%20example.\n\n%23include%20%3Cstdlib.h%3E\n%23include%20%3Cstdio.h%3E\n%23include%20%3Cstdint.h%3E\n%23include%20%3Cstring.h%3E\n\nvoid%20*smemset%28void%20*s%2C%20int%20c%2C%20size_t%20n%29\n{\n%20%20\t\tvolatile%20void%20*s1%20%3D%20s%3B\n%20%20%20%20%20%20%20%20return%20memset%28%28void%20*%29s1%2C%20c%2C%20n%29%3B\n}\n\n%23define%20OVERFLOW_TEST%28a%2Cb%29%20%20%20%20%20%20%28%28%28a%20%2B%20b%29%20%3C%3D%20a%29%20%26%26%20%28%28a%20%2B%20b%29%20%3C%3D%20b%29%29\n\nint\nmain%28int%20argc%2C%20char%20**argv%29\n{\n%20%20\t\t\n%20%20%20%20%20%20%20%20char%20*test%20%3D%20%28char%20*%29%20malloc%2820%29%3B\n%20%20\n%20%20\t\tmemcpy%28test%2C%20\%22hello%20my%20friends...\\0\%22%2C%2020%29%3B\n%20%20\n%20%20\t\tprintf%28\%22%25
 
s\\n\%22%2Ctest%29%3B\n\n%20%20%20%20%20%20%20%20smemset%28test%2C%200%2C%2020%29%3B\n\n%20%20%20%20%20%20%20%20free%28test%29%3B\n\n%20%20%20%20%20%20%20%20return%200%3B\n}\n%22%2C%22compiler%22%3A%22%2Fusr%2Fbin%2Fclang%2B%2B%22%2C%22options%22%3A%22-O2%20-march%3Dnative%20-m32%22}]}

even a temporary volatile conversion will make stuff break...
smemset() ist just never called... :-/
GCC will actually call it for some reason... ;-?

Good luck...

Andreas


________________________________________
Von: Joel Schopp [[email protected]]
Gesendet: Mittwoch, 21. August 2013 18:26
An: Fuchs, Andreas
Cc: [email protected]; Yunlian Jiang; Richard Maciel Costa
Betreff: Re: AW: [TrouSerS-tech] [PATCH] make trousers compile with clang

Comments inline below

On 08/21/2013 02:24 AM, Fuchs, Andreas wrote:
> Hi Joel,
>
> the thing here is that disabling O0 attributes is almost always a security 
> concern.
> The reason is that GCC and Clang will "optimize out" a memset(0) that comes
> before a free since "that does not change program's behaviour".
> OpenSSL and other just try to be so complex that the compiler will not 
> recognize
> this pattern, but this is a "cats and mice game" (german saying)... ;-)

First, I assume you have no objections to the removal of inline for
read_data and write_data?  These generate actual compiler errors for
clang while the attribute just generates a warning.

>
> The file spi_utils.h / ps_utils.c for example use O0 in order to prevent 
> information
> leak on free calls.
> Specifically, the last commit to spi_utils.h is
> "[29a8b1] tspi: add a memset that shouldn't be optimized out"
> and goes back to some discussion between myself and Kent...

Declaring the variables as volatile should resolve this problem and be
more reliable and portable.  I'll resend this patch with that change.


------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and 
AppDynamics. Performance Central is your source for news, insights, 
analysis and resources for efficient Application Performance Management. 
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
TrouSerS-tech mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/trousers-tech

Reply via email to