[cfe-dev] Security fail (memset being optimized away)

Joerg Sonnenberger via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 3 08:59:27 PST 2019


Please don't start a new thread for every reply, that makes reading the
list unncessary annoying.

On Thu, Jan 03, 2019 at 04:47:32PM +0100, myLC at gmx.de via cfe-dev wrote:
> A few days ago Ilja van Sprundel held a talk at the 35C3 (Chaos Computer Club
> annual convention) calling it "Memsad - why clearing memory is hard".
> It can be found here:
> 
> https://media.ccc.de/v/35c3-9788-memsad
> or here:
> https://www.youtube.com/watch?v=0WzjAKABSDk

This topic is neither new nor surprising. It is the result of a gray
area between desirable optimisations and hard scrubbing requirements by
implementations. The implementation generally used is to have a new
function ("explicitly_memset" or similar) and either implement it in
assembler or use one of various compiler-specific hacks. Memory barriers
like asm volatile ("":::"memory") for example are typically good enough
even with LTO for most GCC compatible compilers. Indirecting through a
volatile global function pointer is another approach, but comes with a
potentially noticable performance hit. It is the most portable solution
though.

Joerg



More information about the cfe-dev mailing list