#
1.3 |
|
21-Jun-2014 |
matthew |
Protect explicit_bzero() from link-time optimization
Modern compiler toolchains are capable of optimizing even across translation unit boundaries, so simply moving the memory clearing into a separate function is not guaranteed to clear memory.
To avoid this, we take advantage of ELF weak symbol semantics, and insert a call to an empty, weakly named function. The semantics of calling this function aren't determinable until load time, so the compiler and linker need to keep the memset() call.
There are still ways a toolchain might defeat this trick (e.g., optimistically expecting the weak symbol to not be overloaded, and only calling memset() if it is; promoting weak symbols to strong symbols at link-time when emitting a static binary because they won't be interposed; implementing load-time optimizations). But at least for the foreseeable future, these seem unlikely.
ok deraadt
|
#
1.1 |
|
10-Jan-2011 |
tedu |
add a new function, explicit_bzero, to be used for erasing "secret" stuff. unlike normal bzero, we guarantee that the compiler will not optimize out calls to this function for otherwise dead variables. to be adjusted as needed when compilers and linkers get smarter. ok deraadt miod
|